From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1F3CBA0351; Thu, 3 Mar 2022 14:31:16 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ABD1540687; Thu, 3 Mar 2022 14:31:15 +0100 (CET) Received: from out162-62-57-137.mail.qq.com (out162-62-57-137.mail.qq.com [162.62.57.137]) by mails.dpdk.org (Postfix) with ESMTP id AD43040141 for ; Thu, 3 Mar 2022 14:31:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1646314270; bh=m7VhL6TNrLU9LZGjx28MJ9RgbxJOzXiBTyOKXIpuLQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NJqQfjXIiZ1mOKt2NAEce7xwXy2B4XTzoj+m9F1XcNow+uNVm+CH+d+mLm2BHvpV7 a/xZ2WCsIbNiFH2kdHRA0vsILbxwSWSBKSH6cVsSHZf2bLXm1tI7fRLZUBRx5zgAlZ 0WX3lYiq7biluJ44OUumiXKv/zDCBRtAXcWH5HaA= Received: from localhost.localdomain ([111.193.130.237]) by newxmesmtplogicsvrszc9.qq.com (NewEsmtp) with SMTP id 7C5A88E7; Thu, 03 Mar 2022 21:31:05 +0800 X-QQ-mid: xmsmtpt1646314265trf4everz Message-ID: X-QQ-XMAILINFO: MaZu5Xhaz90xwkOFWbWmnoJah92hJi/i6SqAtonWFfXa98rWYE5yeDgbufC8Yo v6jcStEX6xApp4GmAnP7aF+gmJivvFAWwQbSLkJc1462BvF7q9BT+YzAREaQNXMKgKoeBxK1lZjb mDANjx5i9ZUjJUf/vnEeiMDhgiSA9G8S9gIaqGvq0bSLD/v/OBqjVmxVz9ZG8+d3TzxThLHwfzax wrJY/9vGWTtAvYWCvYzSN+WfYMpybXgt6bYP9V6U+uYso+djOUO/6FW5mO4CjVaOn35ed9+xXa3Q /CJsEDZY8o3RcIZmRJ3dgGFF5E7hT/6Rv9eFTb+j2X80kgI9JB2FTBeoPvohXTYhBLH1xwXupCtY SJmu6kRnb+QZAQT3QwyXNGDIgDVlmB2KCxZ1dUK0+PoTRFyzKIsw54L8b/v2Zsej37NN8w7eQAdT DRI3YQHeh+YbUbZ48we0Pv9/xFHBVE0mGPKhIC1W00xY/ahLK2VRjTSe2Hd+ea6Y5PjUcw0MFSPK 2Zh2iRNWYSbUX0PJakE7WMd+bgkMD43rSnHCpGJjWceEV1c39P09+jVJca0X80yE7sDbrVggSMHN 5aGGAavhYYB2RpTHKdiuHx1B3juu0LvA3ibqH0p7gXDnmKpx5SV0wGhCJI0o41eFD7AYBFmjKmjg /iC/BBHv8HvpxEG/6tyTxuQGzfGQ6xztY6LfAplr6ZmNGqZNjI1kq/zthgnyfWLW8pw4nN408aEb TrCDkZdxgEibNzNSc8rA/3bSOGONc6YT+m1A7YrcyDxbLWGdL5sXuKAxH977Qo09VeEfP4kawJcm RWFQCIrQDK2O5oJCGs2W91zgeGvYLt1agseG++Z4SigEohwUalXAJstAP/Xua68f0W2Fra8ScMNn k3EvDVyUhM2OYSKWkVesYR2hoymmqKvuHfKg484Dbb From: Weiguo Li To: ferruh.yigit@intel.com Cc: jiawenwu@trustnetic.com, dev@dpdk.org, david.marchand@redhat.com, aconole@redhat.com, julia.lawall@inria.fr Subject: Re: [PATCH] net/txgbe: fix a bit with boolean operator Date: Thu, 3 Mar 2022 21:31:00 +0800 X-OQ-MSGID: <20220303133100.663532-1-liwg06@foxmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On March 2, 2022, 5:23 p.m Ferruh Yigit wrote: > On 3/2/2022 8:02 AM, Jiawen Wu wrote: > > On March 1, 2022 2:09 PM, Weiguo Li wrote: > >> Since boolean value is in 0 and 1, it's strange to combines a boolean > > value with > >> a bit operator. > >> > >> Thus it's highly possible a typo error with "if (A & !B)", and more > > probably to > >> use "if (A & ~B)" instead. > >> > >> Fixes: c1d4e9d37abdc6 ("net/txgbe: add queue stats mapping") > >> > >> Signed-off-by: Weiguo Li > >> --- > >> drivers/net/txgbe/txgbe_ethdev.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/net/txgbe/txgbe_ethdev.c > >> b/drivers/net/txgbe/txgbe_ethdev.c > >> index 19d4444748..f0994f028d 100644 > >> --- a/drivers/net/txgbe/txgbe_ethdev.c > >> +++ b/drivers/net/txgbe/txgbe_ethdev.c > >> @@ -376,7 +376,7 @@ txgbe_dev_queue_stats_mapping_set(struct > >> rte_eth_dev *eth_dev, > >> if (hw->mac.type != txgbe_mac_raptor) > >> return -ENOSYS; > >> > >> - if (stat_idx & !QMAP_FIELD_RESERVED_BITS_MASK) > >> + if (stat_idx & ~QMAP_FIELD_RESERVED_BITS_MASK) > >> return -EIO; > >> > >> PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat > >> index %d", > >> -- > >> 2.25.1 > > > > Thanks. > > > > Acked-by: Jiawen Wu > > > > Hi Weiguo, > > Good catch, I wonder how did you detect this? > > If there is an automated way, maybe we can consider using > it in our CI. > Hi Ferruh, It's found by a coccinell script: @fix_bit_boolean @ expression E; constant C; @@ ( !E & !C | - !E & C + !(E & C) | - E & !C + E & ~C ) the idea came from a demo script in coccinelle website: (https://coccinelle.gitlabpages.inria.fr/website/rules/notand.html) @@ expression E; constant C; @@ ( !E & !C | - !E & C + !(E & C) ) The difference is in the last two lines and by which found the problem. I'd be happy if it would used in CI. Maybe better to let Julia know, since she's the original author. cc Julia -Weiguo