Received: by 10.223.176.46 with SMTP id f43csp3072430wra; Mon, 22 Jan 2018 08:00:49 -0800 (PST) X-Google-Smtp-Source: AH8x22505fSHhzALI2zMo1YF3OyIFu2CvS2lvBRT1/Z8ZdS5ryt3ktQ8hh6oJQE3EX6lk0JOosxn X-Received: by 10.107.192.2 with SMTP id q2mr8988661iof.112.1516636847437; Mon, 22 Jan 2018 08:00:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516636847; cv=none; d=google.com; s=arc-20160816; b=uGxFnOU/Ss4t3EOCC/J6/KfsRmIGZupudh1Q6I53h7u+v917PszOq2rHVBrbZ7G8w/ N1AnVsuQwz1Lk3ph4H4I3OIYQObstYd+nVL/dP4dcbY+flbt1d+TiWICerN3V6fjXvyl ORmgS+N5OCJQjj4HJuHZI2jbOghVSOSw6lDGwRPW+fDffqowe0LvSCedAL7f+DyPfIGP 68zQx2bsgo/nLD3Gwehzxs4rtbVZ9c6gy7QDx9Yus+xhcYgJ/SZvBvpsFSXD8HiNh0BG Ha4qkgFbaUnAPWQ7NbIzL4KJMRTN2aOYh7yv83gfrejTrO24HnIm89jf2oDRtbhSWcum uSgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=w7ZFjhn95wSGDHHujqtjURFF7yr9QUrD6z9txD/nZ7E=; b=YkYmN9BEsKzsCgxtlSZpz/W3oDmtiOCAo2BCgXoYZmVeyCWyDM6CRdQKQ0zqpf2qF+ u36qHu5l3FAlG5NmoZ2WSY2U60OUJGTaJpXzLQC+TKh9PATWndWSL0sCNTH+fStnyrec yEjy4ufPsdg1MkK+qfgtskpbyxh+bQTjRPjtODMTOB2mCPamxpXkKtn/8nEr76McWEU0 q2GzPFsH5KjwVVgh6Ji3Ao3pzVNXx50G2EG/ErgYZff5hlG/2F7jhP/ODSQyjlwIHLA3 EKLPwLD0M4dIRlmuS15YQCn0xKXEzVnx09Ofv6IEF4ovt6CY2BjRLZKNtAjcjx++R1i2 3ALg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e101si12921410iod.0.2018.01.22.08.00.32; Mon, 22 Jan 2018 08:00:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751214AbeAVQAH (ORCPT + 99 others); Mon, 22 Jan 2018 11:00:07 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:32928 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751007AbeAVQAF (ORCPT ); Mon, 22 Jan 2018 11:00:05 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 15CC718320; Mon, 22 Jan 2018 17:00:04 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id jj0xjvQPYU4m; Mon, 22 Jan 2018 17:00:00 +0100 (CET) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bastet.se.axis.com (Postfix) with ESMTPS id C16EB1836A; Mon, 22 Jan 2018 17:00:00 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AAB321E079; Mon, 22 Jan 2018 17:00:00 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9E9AB1E077; Mon, 22 Jan 2018 17:00:00 +0100 (CET) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder03.se.axis.com (Postfix) with ESMTP; Mon, 22 Jan 2018 17:00:00 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by seth.se.axis.com (Postfix) with ESMTP id 91BE31CC5; Mon, 22 Jan 2018 17:00:00 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 8B0C3401AF; Mon, 22 Jan 2018 17:00:00 +0100 (CET) From: Niklas Cassel To: Giuseppe Cavallaro , Alexandre Torgue Cc: Niklas Cassel , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next] net: stmmac: do not use a bitwise AND operator with a bool operand Date: Mon, 22 Jan 2018 16:59:50 +0100 Message-Id: <20180122155950.3527-1-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 X-TM-AS-GCONF: 00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Doing a bitwise AND between a bool and an int is generally not a good idea. The bool will be promoted to an int with value 0 or 1, the int is generally regarded as true with a non-zero value, thus ANDing them has the potential to yield an undesired result. This commit fixes the following smatch warnings: drivers/net/ethernet/stmicro/stmmac/enh_desc.c:344 enh_desc_prepare_tx_desc() warn: maybe use && instead of & drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c:337 dwmac4_rd_prepare_tx_desc() warn: maybe use && instead of & drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c:380 dwmac4_rd_prepare_tso_tx_desc() warn: maybe use && instead of & Signed-off-by: Niklas Cassel --- drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | 4 ++-- drivers/net/ethernet/stmicro/stmmac/enh_desc.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c index 2fd8456999f6..c728ffa095de 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c @@ -334,7 +334,7 @@ static void dwmac4_rd_prepare_tx_desc(struct dma_desc *p, int is_fs, int len, if (tx_own) tdes3 |= TDES3_OWN; - if (is_fs & tx_own) + if (is_fs && tx_own) /* When the own bit, for the first frame, has to be set, all * descriptors for the same frame has to be set before, to * avoid race condition. @@ -377,7 +377,7 @@ static void dwmac4_rd_prepare_tso_tx_desc(struct dma_desc *p, int is_fs, if (tx_own) tdes3 |= TDES3_OWN; - if (is_fs & tx_own) + if (is_fs && tx_own) /* When the own bit, for the first frame, has to be set, all * descriptors for the same frame has to be set before, to * avoid race condition. diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c index b47cb5c4da51..6768a25b6aa0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c @@ -341,7 +341,7 @@ static void enh_desc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len, if (tx_own) tdes0 |= ETDES0_OWN; - if (is_fs & tx_own) + if (is_fs && tx_own) /* When the own bit, for the first frame, has to be set, all * descriptors for the same frame has to be set before, to * avoid race condition. -- 2.14.2