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 D4467A04A2; Thu, 3 Mar 2022 17:17:01 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B59E142789; Thu, 3 Mar 2022 17:17:01 +0100 (CET) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mails.dpdk.org (Postfix) with ESMTP id A01FA40687 for ; Thu, 3 Mar 2022 17:17:00 +0100 (CET) Received: by mail-pl1-f175.google.com with SMTP id z2so4960705plg.8 for ; Thu, 03 Mar 2022 08:17:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o/jryMilIWAU+KxCL1mQ9bvZ0VoLpfJMArkJ49cYdpM=; b=g+acayUNyyfP2YZYmG1Kz4YMys6Ih0H5QD89FGplryVF1mfTqpfJX2TWrfyesdtSHo UUg5EtcffkV26qunuz9t4YRg1oPZAQo4K11r1e4YA6qB7qxGQ3YqkZ4nyCmRD0Rq6chq CI439fWvSPjUaeKCafANnjlc2NL+MGeIiJC1HncX+AfDXL83ShdCkLYKajUMizk+/Hvc ROmvbFvIYpQLXrcpOaiceSxj7hd1qTWJPDp3NANEKySAdjCZ0qQpf+EGUYieoBwNv9Gh yNeqn6TeRyCu4V2Z5MMAE3ZMRX+mwupRN+mpuEgdYC8qFFFrGAAtF8+kmSVVHzE8E10C +J6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o/jryMilIWAU+KxCL1mQ9bvZ0VoLpfJMArkJ49cYdpM=; b=CquANHf5PstroPqFaRSQLitBusw2tXKmwbKrz5Xkqbdx3upYbaXEoUPE0SvvtZQANa axemVPIapStOC9lUhmvMezLORP3JH1G52SuguT4yhG4ClDPhMyYGr/Ux2FvxzpdDm9v9 QLATEa0g9mW9F+I2Xrr+E75m/fh6AFjTqaLruxZBPehL3oHULUHvMveQxAgpr7t20Xv9 OgIuzx8EVwYf1h/IAWDxO9lx8EFnoSD6jPzx/e59qkWCxRvmTDWLvibCLhhiBP1U/WHM eNgRam2qvriqB48cyVyadmfINZynOLdaBrcUbczI3R4kLcVyXtNEYGgzrNcLU2WAUOQ6 TZsw== X-Gm-Message-State: AOAM530OsMhctJ3i1rNPAgUB5HHKYtcMQEB4Lhutn94e9CY28ykdfHJ2 w09Ru099uODEFZ9ZR2UIfCkHNA== X-Google-Smtp-Source: ABdhPJyaE3Ks1ZfJZx6WDRqpCaqAgdf89n4c8REc0of/bq8UdJLodFnP/C9HgYHitLEeQjGWbcF9Og== X-Received: by 2002:a17:90a:9306:b0:1bc:9256:5477 with SMTP id p6-20020a17090a930600b001bc92565477mr6202149pjo.170.1646324219761; Thu, 03 Mar 2022 08:16:59 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id u19-20020a056a00099300b004e16e381696sm3086868pfg.195.2022.03.03.08.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 08:16:59 -0800 (PST) Date: Thu, 3 Mar 2022 08:16:56 -0800 From: Stephen Hemminger To: Weiguo Li Cc: ferruh.yigit@intel.com, 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 Message-ID: <20220303081656.75ae8961@hermes.local> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Thu, 3 Mar 2022 21:31:00 +0800 Weiguo Li wrote: > 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 > > Could you add similar script to DPDK cocci scripts please?