From: Roel Kluin <12o3l@tiscali.nl>
To: "Maciej W. Rozycki" <macro@linux-mips.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty_ioctl: Fix the baud_table check in encode_baud_rate
Date: Wed, 17 Oct 2007 01:05:39 +0200 [thread overview]
Message-ID: <471543C3.3050502@tiscali.nl> (raw)
In-Reply-To: <Pine.LNX.4.64N.0710161857280.22596@blysk.ds.pg.gda.pl>
Since you were sending a fix, possibly I shouldn't comment on this. If so please disregard my
suggestion for a trivial cleanup.
Roel
Maciej W. Rozycki wrote:
> +void tty_termios_encode_baud_rate(struct ktermios *termios,
> + speed_t ibaud, speed_t obaud)
> {
> int i = 0;
> int ifound = -1, ofound = -1;
> @@ -251,12 +252,15 @@ void tty_termios_encode_baud_rate(struct
> termios->c_cflag &= ~CBAUD;
>
> do {
> - if (obaud - oclose >= baud_table[i] && obaud + oclose <= baud_table[i]) {
> + if (obaud - oclose <= baud_table[i] &&
> + obaud + oclose >= baud_table[i]) {
if(a - b <= c && a + b >= c)
if(a <= c + b && a + b >= c)
if(c + b >= a && a + b >= c)
if(b >= a - c && b >= c - a)
true, if:
b >= |a - c|
so
if (oclose >= abs(obaud - baud_table[i])) {
should work as well
> termios->c_cflag |= baud_bits[i];
> ofound = i;
> }
> - if (ibaud - iclose >= baud_table[i] && ibaud + iclose <= baud_table[i]) {
> - /* For the case input == output don't set IBAUD bits if the user didn't do so */
> + if (ibaud - iclose <= baud_table[i] &&
> + ibaud + iclose >= baud_table[i]) {
similarly,
if (iclose >= abs(ibaud - baud_table[i])) {
> + /* For the case input == output don't set IBAUD bits
> + if the user didn't do so */
> if (ofound != i || ibinput)
> termios->c_cflag |= (baud_bits[i] << IBSHIFT);
> ifound = i;
next prev parent reply other threads:[~2007-10-16 23:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-16 18:12 [PATCH] tty_ioctl: Fix the baud_table check in encode_baud_rate Maciej W. Rozycki
2007-10-16 23:05 ` Roel Kluin [this message]
2007-10-23 17:32 ` Maciej W. Rozycki
2007-10-17 10:43 ` Alan Cox
2007-10-23 17:27 ` Maciej W. Rozycki
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=471543C3.3050502@tiscali.nl \
--to=12o3l@tiscali.nl \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=macro@linux-mips.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.