Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp621189pxb; Thu, 25 Feb 2021 10:37:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMsNencSGYnek/iVpsqYqaqxl5HMPh5INJuWvua+hTvqjiND/BI3Nr8Op6hfu1TxyYJbsh X-Received: by 2002:a17:906:1182:: with SMTP id n2mr4026942eja.234.1614278268681; Thu, 25 Feb 2021 10:37:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614278268; cv=none; d=google.com; s=arc-20160816; b=ZwbkT3AMfAce7ibKzqOG58UTC3XE6+YUOzzEH+yYcGXdJ/OxdeuyZQgACd4DMzrmyv 2TTEWEFoXJ6Oy6QzNZJ1xnQbmCmM6qCZfxXm2AOIabZ/X2tH4o6ic+0n6351T41V3aTv e8QsJwwa++5BNITBiiOMzDf4taXj6A2SitxSaMFsbP+6hrh7u29Eew/GAwA+IRvb7X+1 TQg2bjPG4K10QYtXCZZbSACGvYRm4vzEP/BEbbBoylK7WlM6KtQ1jO9HSIq3RXoFCT58 hRCSjv4Foy4rN/zDf0qZwnsMUmwCfePsJv0xFXWZ+RmkSHdVrzDBYhvJuQcQEZadPHWZ 7XYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=IXUGtt0n0ti/k68D5JWnC7o9QJqBp6hq/Iar914Vl6Q=; b=QHuQOAcZKdA0woGLHpBy8IbGlW8kkG895hNCrzhr3ks2drrpK2b2EFwbpFC9qzhWAO Od5lcI9FmP7wO8hp7vMzscENYql91+M2xinSYTRQAfyXwgcVQl0p9K+lq3PQSqTlzOhj xttXXeD1T40kFC/zzVaZD3OD7flYHTqeSlc2aUQtDvOXztLmU5AcIPFoW4JfRmUPMTc1 Z9E1zAZMJUTdaK0DtvtHw/bKc7L3nMtgJ/lYZU+zSh08UVr4TceXEmjMwlAPIFn6J3P0 XHYIrjeddph68TlX+1J0tbhxZjvCbqXgKJFmNZRVUTuuOEnYkAJlX3jeN9SOFz1o99x8 Guww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e10si1876479ejk.173.2021.02.25.10.37.23; Thu, 25 Feb 2021 10:37:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232923AbhBYSfH (ORCPT + 99 others); Thu, 25 Feb 2021 13:35:07 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:47412 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233671AbhBYSd3 (ORCPT ); Thu, 25 Feb 2021 13:33:29 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lFLRJ-0002oE-GG; Thu, 25 Feb 2021 18:32:41 +0000 From: Colin King To: Jakub Kicinski , Kalle Valo , "David S . Miller" , Matthias Brugger , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mt7601u: fix always true expression Date: Thu, 25 Feb 2021 18:32:41 +0000 Message-Id: <20210225183241.1002129-1-colin.king@canonical.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Colin Ian King 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: c869f77d6abb ("add mt7601u driver") Signed-off-by: Colin Ian King --- drivers/net/wireless/mediatek/mt7601u/eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt7601u/eeprom.c b/drivers/net/wireless/mediatek/mt7601u/eeprom.c index c868582c5d22..aa3b64902cf9 100644 --- a/drivers/net/wireless/mediatek/mt7601u/eeprom.c +++ b/drivers/net/wireless/mediatek/mt7601u/eeprom.c @@ -99,7 +99,7 @@ mt7601u_has_tssi(struct mt7601u_dev *dev, u8 *eeprom) { u16 nic_conf1 = get_unaligned_le16(eeprom + MT_EE_NIC_CONF_1); - return ~nic_conf1 && (nic_conf1 & MT_EE_NIC_CONF_1_TX_ALC_EN); + return (u16)~nic_conf1 && (nic_conf1 & MT_EE_NIC_CONF_1_TX_ALC_EN); } static void -- 2.30.0