netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] net: hinic: fix comparison of a uint16_t type with -1
@ 2017-08-23 15:39 Colin King
  2017-08-24  8:48 ` Aviad Krawczyk
  2017-08-24 21:32 ` David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Colin King @ 2017-08-23 15:39 UTC (permalink / raw)
  To: Aviad Krawczyk, netdev; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The comparison of hw_ioctxt.rx_buf_sz_idx == -1 is always false because
rx_buf_sz_idx is a uint16_t. Fix this by explicitly casting -1 to uint16_t.

Detected by CoverityScan, CID#1454559 ("Operands don't affect result")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
index 09dec6de8dd5..71e26070fb7f 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
@@ -352,7 +352,7 @@ static int set_hw_ioctxt(struct hinic_hwdev *hwdev, unsigned int rq_depth,
 		}
 	}
 
-	if (hw_ioctxt.rx_buf_sz_idx == -1)
+	if (hw_ioctxt.rx_buf_sz_idx == (uint16_t)-1)
 		return -EINVAL;
 
 	hw_ioctxt.sq_depth  = ilog2(sq_depth);
-- 
2.14.1


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

end of thread, other threads:[~2017-08-24 21:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-23 15:39 [PATCH][next] net: hinic: fix comparison of a uint16_t type with -1 Colin King
2017-08-24  8:48 ` Aviad Krawczyk
2017-08-24  8:54   ` Colin Ian King
2017-08-24  9:29     ` Dan Carpenter
2017-08-24  9:38       ` Aviad Krawczyk
2017-08-24 21:32 ` David Miller

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).