unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 49524@debbugs.gnu.org
Subject: bug#49524: 28.0.50; make-serial-process is not portable
Date: Mon, 12 Jul 2021 17:35:40 -0400	[thread overview]
Message-ID: <57a32998-24f8-9e2c-adf5-d4971d3087cc@cornell.edu> (raw)
In-Reply-To: <8bf20bb2-ca96-3ee5-01e2-ec8b00cc8c91@cornell.edu>

On 7/12/2021 9:27 AM, Ken Brown wrote:
> On 7/11/2021 12:24 PM, Eli Zaretskii wrote:
>>> From: Ken Brown <kbrown@cornell.edu>
>>> Date: Sun, 11 Jul 2021 11:24:58 -0400
>>>
>>> Fmake_serial_process calls Fserial_process_configure, which calls
>>> serial_configure, which calls cfsetspeed with the speed argument equal to the
>>> numerical baud rate (e.g., 9600).  But the documentation of cfsetspeed says that
>>> the speed argument must be one of the Bnnn constants defined in termios.h (e.g.,
>>> B9600).  See, for example,
>>>
>>>     https://man7.org/linux/man-pages/man3/termios.3.html
>>>
>>> This incorrect call of cfsetspeed happens to succeed on GNU/Linux because
>>> glibc's cfsetspeed allows the argument to be the numerical baud rate, which it
>>> converts to the appropriate Bnnn constant.  But I don't think emacs should be
>>> relying on this undocumented behavior.  In particular, this doesn't work on
>>> Cygwin.  And it wouldn't even work on GNU/Linux if emacs used the cfsetspeed
>>> replacement defined in sysdep.c instead of glibc's cfsetspeed.
>>>
>>> I think the way to fix this is to imitate the glibc code that converts the baud
>>> rate to a Bnnn constant, but maybe someone has a better idea.
>>
>> Converting in sysdep.c:serial_configure sounds TRT to me.
> 
> Patch attached.

BTW, we've decided to change Cygwin's cfsetspeed to be compatible with glibc's, 
so the problem fixed by my patch won't exist on Cygwin going forward.  And I 
checked FreeBSD out of curiosity and found that there's no issue there either 
because of the way they define the Bnnn constants:

#define	B0	0
#define	B50	50
#define	B75	75
...

So I should probably remove the reference to non-glibc platforms in my commit 
message.

Ken





  reply	other threads:[~2021-07-12 21:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-11 15:24 bug#49524: 28.0.50; make-serial-process is not portable Ken Brown
2021-07-11 16:24 ` Eli Zaretskii
2021-07-12 13:27   ` Ken Brown
2021-07-12 21:35     ` Ken Brown [this message]
2021-07-13 11:19       ` Eli Zaretskii
2021-07-13 13:11         ` Ken Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57a32998-24f8-9e2c-adf5-d4971d3087cc@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=49524@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).