From: Pavel Machek <pavel@ucw.cz>
To: ifaenson@broadcom.com, marcel@holtmann.org,
kernel list <linux-kernel@vger.kernel.org>,
gustavo@padovan.org, johan.hedberg@gmail.com,
linux-bluetooth@vger.kernel.org, sre@kernel.org
Subject: hci_ldisc: suspicious/buggy code
Date: Mon, 17 Oct 2016 23:32:06 +0200 [thread overview]
Message-ID: <20161017213205.GA25141@amd> (raw)
[-- Attachment #1: Type: text/plain, Size: 1239 bytes --]
Hi!
hci_uart_set_flow_control() contains some rather suspicious
code. AFAICT:
set = 0.
Then we do set &= (magic constant). But as set is 0, it stays zero. It
just does not make sense. [Nor does it make sense to do |= on known
value of zero just after else. But that's probably just some artifact
of editing.]
(And if you edit the code anyway, temporary variable to store
TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 | TIOCM_OUT2 | TIOCM_LOOP would
make sense.)
Thanks,
Pavel
/* Flow control or un-flow control the device */
void hci_uart_set_flow_control(struct hci_uart *hu, bool enable)
{
...
unsigned int set = 0;
unsigned int clear = 0;
if (enable) {
...
set &= ~(TIOCM_OUT2 | TIOCM_RTS);
clear = ~set;
set &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |
TIOCM_OUT2 | TIOCM_LOOP;
clear &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |
TIOCM_OUT2 | TIOCM_LOOP;
status = tty->driver->ops->tiocmset(tty, set, clear);
BT_DBG("Clearing RTS: %s", status ? "failed" : "success");
} else {
...
set |= (TIOCM_OUT2 | TIOCM_RTS);
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
next reply other threads:[~2016-10-17 21:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-17 21:32 Pavel Machek [this message]
2016-10-17 21:52 ` hci_ldisc: suspicious/buggy code Pavel Machek
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=20161017213205.GA25141@amd \
--to=pavel@ucw.cz \
--cc=gustavo@padovan.org \
--cc=ifaenson@broadcom.com \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=sre@kernel.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 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 NNTP newsgroup(s).