From: Liam Howlett <liam.howlett@oracle.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [bug report] Maple Tree: add new data structure
Date: Tue, 19 Jul 2022 13:37:37 +0000 [thread overview]
Message-ID: <20220719133731.wmthp47dqdirtc34@revolver> (raw)
In-Reply-To: <YtZ7JO6noz2QduUX@kili>
* Dan Carpenter <dan.carpenter@oracle.com> [220719 05:36]:
> Hello Liam R. Howlett,
>
> The patch 058c2f0f755f: "Maple Tree: add new data structure" from Jul
> 17, 2022, leads to the following Smatch static checker warning:
>
> lib/maple_tree.c:6969 mas_validate_limits()
> warn: add some parenthesis here? '!piv & (i != 0)'
>
> lib/maple_tree.c
> 6952 static void mas_validate_limits(struct ma_state *mas)
> 6953 {
> 6954 int i;
> 6955 unsigned long prev_piv = 0;
> 6956 enum maple_type type = mte_node_type(mas->node);
> 6957 void __rcu **slots = ma_slots(mte_to_node(mas->node), type);
> 6958 unsigned long *pivots = ma_pivots(mas_mn(mas), type);
> 6959
> 6960 /* all limits are fine here. */
> 6961 if (mte_is_root(mas->node))
> 6962 return;
> 6963
> 6964 for (i = 0; i < mt_slots[type]; i++) {
> 6965 unsigned long piv;
> 6966
> 6967 piv = mas_safe_pivot(mas, pivots, i, type);
> 6968
> --> 6969 if (!piv & (i != 0))
>
> Sparse and Smatch both hate this. I think this code is correct and it
> should be:
>
> if ((!piv) & (i != 0))
>
> However the vast majority of the time this warning indicates a
> precendence bug where what was intended was:
>
> if (!(piv & (i != 0)))
Thanks! I caught this with C=1 (sparse). I've been working through
another issue with Hugh that was more pressing. I'll send out a patch
today. The double && will work here but it shouldn't actually make a
difference.
Regards,
Liam
>
>
> I guess it's not common to use booleans for bitwise ANDs...
>
> 6970 break;
> 6971
> 6972 if (!mte_is_leaf(mas->node)) {
>
> regards,
> dan carpenter
prev parent reply other threads:[~2022-07-19 13:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-19 9:36 Dan Carpenter
2022-07-19 13:37 ` Liam Howlett [this message]
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=20220719133731.wmthp47dqdirtc34@revolver \
--to=liam.howlett@oracle.com \
--cc=dan.carpenter@oracle.com \
--cc=linux-mm@kvack.org \
/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