From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932161AbdHWPjl (ORCPT ); Wed, 23 Aug 2017 11:39:41 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:53099 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754136AbdHWPjj (ORCPT ); Wed, 23 Aug 2017 11:39:39 -0400 From: Colin King To: Aviad Krawczyk , netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] net: hinic: fix comparison of a uint16_t type with -1 Date: Wed, 23 Aug 2017 16:39:36 +0100 Message-Id: <20170823153936.22857-1-colin.king@canonical.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King 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 --- 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