Re: [cocci] Possible cocci test & that should be |

Julia Lawall <[email protected]> Wed, 1 Jul 2026 19:07:01 -0400 (EDT)
Newsgroups fr.inria.cocci
Message-ID <[email protected]>

On Wed, 1 Jul 2026, Joe Perches wrote:

> Hi Julia.
>
> A suggestion for a possible (new?) test.
>
> On Tue, 2026-06-30 at 15:08 -0400, Liam R. Howlett (Oracle) wrote:
> > The GFP flags in two tests are obviously incorrect.  Make the tests
> > correctly run by updating the GFP flags.
> > Link: [https://lore.kernel.org/all/[email protected]/](https://lore.kernel.org/all/[email protected]/)
> > Reported-by: Joe Perches <[[email protected]](mailto:[email protected])>
> []
> > diff --git a/tools/testing/radix-tree/maple.c b/tools/testing/radix-tree/maple.c
> []
> > @@ -35234,7 +35234,7 @@ static noinline void __init check_prealloc(struct maple_tree *mt)
> > -	MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_KERNEL & GFP_NOWAIT) == 0);
> > +	MT_BUG_ON(mt, mas_preallocate(&mas, ptr, GFP_NOWAIT) == 0);
>
> Is it possible for cocci to find uses of enums/constants
> that are anded together where the result is a likely
> unintentional 0 where presumably the & should be an | ?

I wonder if it is every useful to do & of two named constants?
I will try.

julia