From: Fernando Nasser <fnasser@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: RFA: [ser-unix.c] Fix handling of baud rates
Date: Wed, 25 Apr 2001 15:39:00 -0000 [thread overview]
Message-ID: <3AE751A5.AE7633E4@redhat.com> (raw)
If the user requests an invalid baud rate (with -b or set remotebaud),
GDB will try to set the serial port speed to -1 and eventually dump
core.
The following patch will cause GDB to use only legal values for the
serial line speed. If the speed requested is not one of the valid
speeds, the best speed that is less than the value requested will be
used. However, if the requested speed is less than 50, 50 bauds will be
used.
OK to commit?
--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
Index: ser-unix.c
===================================================================
RCS file: /cvs/src/src/gdb/ser-unix.c,v
retrieving revision 1.12
diff -c -p -r1.12 ser-unix.c
*** ser-unix.c 2001/03/06 08:21:16 1.12
--- ser-unix.c 2001/04/25 21:54:59
*************** rate_to_code (int rate)
*** 741,750 ****
int i;
for (i = 0; baudtab[i].rate != -1; i++)
! if (rate == baudtab[i].rate)
! return baudtab[i].code;
!
! return -1;
}
static int
--- 741,768 ----
int i;
for (i = 0; baudtab[i].rate != -1; i++)
! {
! /* test for perfect macth. */
! if (rate == baudtab[i].rate)
! return baudtab[i].code;
! else
! {
! /* check if it is in between valid values. */
! if (rate < baudtab[i].rate)
! {
! /* set to the valid speed immediately below
! or to B50 if the value requested was less
! than 50 bauds. */
! if (i)
! return baudtab[i - 1].code;
! else
! return baudtab[0].code;
! }
! }
! }
!
! /* If the requested speed was too large, set to the best we can do. */
! return baudtab[i - 1].code;
}
static int
From jtc@redback.com Wed Apr 25 16:44:00 2001
From: jtc@redback.com (J.T. Conklin)
To: Fernando Nasser <fnasser@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: RFA: [ser-unix.c] Fix handling of baud rates
Date: Wed, 25 Apr 2001 16:44:00 -0000
Message-id: <5mu23c4kao.fsf@jtc.redback.com>
References: <3AE751A5.AE7633E4@redhat.com>
X-SW-Source: 2001-04/msg00242.html
Content-length: 1261
>>>>> "Fernando" == Fernando Nasser <fnasser@redhat.com> writes:
Fernando> If the user requests an invalid baud rate (with -b or set
Fernando> remotebaud), GDB will try to set the serial port speed to -1
Fernando> and eventually dump core.
Fernando> The following patch will cause GDB to use only legal values
Fernando> for the serial line speed. If the speed requested is not
Fernando> one of the valid speeds, the best speed that is less than
Fernando> the value requested will be used. However, if the requested
Fernando> speed is less than 50, 50 bauds will be used.
Fernando> OK to commit?
I'm not sure I like the behavior of selecting a rate different than
what the user selected is a good idea.
It appears that the higher layers of the code handle the case when
SERIAL_SETBAUDRATE() returns non-zero, so all that needs to be done is
to return -1 in hardwire_setbaudrate() when rate_to_code returns -1
instead of trying to using that value with cfset{i,o}speed, or masking
it in to termio.c_flag, or setting sgttyb.sg_{i,o}speed. The only
additional thing we might want to do is to set errno to an appropriate
value so the perror_with_name() calls in the upper layers output a
reasonable message.
--jtc
--
J.T. Conklin
RedBack Networks
next reply other threads:[~2001-04-25 15:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-25 15:39 Fernando Nasser [this message]
2001-04-26 0:29 ` Eli Zaretskii
2001-04-26 7:17 ` Fernando Nasser
[not found] ` <1659-Thu26Apr2001173526+0300-eliz@is.elta.co.il>
2001-04-26 7:47 ` Fernando Nasser
2001-04-26 9:44 ` Eli Zaretskii
2001-05-10 12:08 ` RFA: [ser-unix.c] Fix handling of baud rates [REPOST] Fernando Nasser
2001-05-11 1:17 ` Eli Zaretskii
2001-05-11 11:31 ` Fernando Nasser
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3AE751A5.AE7633E4@redhat.com \
--to=fnasser@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox