DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Weiguo Li <liwg06@foxmail.com>, dpdklab <dpdklab@iol.unh.edu>
Cc: <jiawenwu@trustnetic.com>, <dev@dpdk.org>,
	<david.marchand@redhat.com>, <aconole@redhat.com>,
	<julia.lawall@inria.fr>, Ali Alnubani <alialnu@nvidia.com>
Subject: Re: [PATCH] net/txgbe: fix a bit with boolean operator
Date: Thu, 3 Mar 2022 15:18:30 +0000	[thread overview]
Message-ID: <8d26472c-13bb-8072-66cd-f9361d439aae@intel.com> (raw)
In-Reply-To: <tencent_DBD18893485F8C11CFF8A94FC48E4EE33706@qq.com>

On 3/3/2022 1:31 PM, 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 <liwg06@foxmail.com>
>>>> ---
>>>>    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 <jiawenwu@trustnetic.com>
>>>
>>
>> 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
> 

Thanks Weiguo. cc'ed lab people and Ali too.

Aaron, lab, what do you think, can this be added into CI checks?


  reply	other threads:[~2022-03-03 15:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-01  6:08 Weiguo Li
2022-03-02  8:02 ` Jiawen Wu
2022-03-02 17:23   ` Ferruh Yigit
2022-03-03 13:31     ` Weiguo Li
2022-03-03 15:18       ` Ferruh Yigit [this message]
2022-03-03 16:16       ` Stephen Hemminger
2022-03-02 17:34   ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8d26472c-13bb-8072-66cd-f9361d439aae@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=aconole@redhat.com \
    --cc=alialnu@nvidia.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=dpdklab@iol.unh.edu \
    --cc=jiawenwu@trustnetic.com \
    --cc=julia.lawall@inria.fr \
    --cc=liwg06@foxmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).