Linux CAN drivers development
 help / color / mirror / Atom feed
* re: can: kvaser_usb: Consolidate and unify state change handling
@ 2015-02-05  8:12 Dan Carpenter
  2015-02-05  8:17 ` Marc Kleine-Budde
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2015-02-05  8:12 UTC (permalink / raw)
  To: ahmed.darwish; +Cc: linux-can

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-02-05  8:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-05  8:12 can: kvaser_usb: Consolidate and unify state change handling Dan Carpenter
2015-02-05  8:17 ` Marc Kleine-Budde
2015-02-05  8:30   ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox