From: Dan Carpenter <dan.carpenter@oracle.com>
To: ahmed.darwish@valeo.com
Cc: linux-can@vger.kernel.org
Subject: re: can: kvaser_usb: Consolidate and unify state change handling
Date: Thu, 5 Feb 2015 11:12:39 +0300 [thread overview]
Message-ID: <20150205081239.GA30683@mwanda> (raw)
Hello Ahmed S. Darwish,
The patch 96d7f10634e6: "can: kvaser_usb: Consolidate and unify state
change handling" from Jan 26, 2015, leads to the following Smatch
warning:
drivers/net/can/usb/kvaser_usb.c:827 kvaser_usb_rx_error_update_can_state()
warn: impossible condition '(es->txerr >= 256) => (0-255 >= 256)'
drivers/net/can/usb/kvaser_usb.c
824 else if (es->status & M16C_STATE_BUS_PASSIVE)
825 new_state = CAN_STATE_ERROR_PASSIVE;
826 else if (es->status & M16C_STATE_BUS_ERROR) {
827 if ((es->txerr >= 256) || (es->rxerr >= 256))
828 new_state = CAN_STATE_BUS_OFF;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dead code. We normally ignore these "impossible condition" warnings if
it feels like the condition makes the code more readable. But in this
case, I wonder if the code works as intended. It's not clear to me.
829 else if ((es->txerr >= 128) || (es->rxerr >= 128))
830 new_state = CAN_STATE_ERROR_PASSIVE;
831 else if ((es->txerr >= 96) || (es->rxerr >= 96))
regards,
dan carpenter
next reply other threads:[~2015-02-05 8:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-05 8:12 Dan Carpenter [this message]
2015-02-05 8:17 ` can: kvaser_usb: Consolidate and unify state change handling Marc Kleine-Budde
2015-02-05 8:30 ` Marc Kleine-Budde
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=20150205081239.GA30683@mwanda \
--to=dan.carpenter@oracle.com \
--cc=ahmed.darwish@valeo.com \
--cc=linux-can@vger.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