]> git.baikalelectronics.ru Git - kernel.git/commit
mt7601u: fix always true expression
authorColin Ian King <colin.king@canonical.com>
Thu, 25 Feb 2021 18:32:41 +0000 (18:32 +0000)
committerKalle Valo <kvalo@codeaurora.org>
Sun, 11 Apr 2021 09:29:47 +0000 (12:29 +0300)
commit90eba2ad81bdea3651dcf1bee5a7be5fb770629f
treec7d8ccbfc342dc0f5d06b083ca4b3611a734520e
parentb183e5ce547323c8dfd015696e58de43506d1dee
mt7601u: fix always true expression

Currently the expression ~nic_conf1 is always true because nic_conf1
is a u16 and according to 6.5.3.3 of the C standard the ~ operator
promotes the u16 to an integer before flipping all the bits. Thus
the top 16 bits of the integer result are all set so the expression
is always true.  If the intention was to flip all the bits of nic_conf1
then casting the integer result back to a u16 is a suitabel fix.

Interestingly static analyzers seem to thing a bitwise ! should be
used instead of ~ for this scenario, so I think the original intent
of the expression may need some extra consideration.

Addresses-Coverity: ("Logical vs. bitwise operator")
Fixes: 4a363cb4f0ef ("add mt7601u driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210225183241.1002129-1-colin.king@canonical.com
drivers/net/wireless/mediatek/mt7601u/eeprom.c