Re: [bug report] lib: introduce test_meminit module

Alexander Potapenko <[email protected]>
Newsgroups gmane.linux.kernel.janitors
Message-ID <CAG_fn=UfpLZt63zkZutfwY_VpQi65S=B4ZJcgzA=dbRK-XVDcg@mail.gmail.com>
On Thu, Apr 30, 2026 at 8:15 PM Dan Carpenter <[email protected]> wrote:
>
> Hello Alexander Potapenko,
>
> Commit 5015a300a522 ("lib: introduce test_meminit module") from Jul
> 16, 2019 (linux-next), leads to the following Smatch static checker
> warning:
>
>         lib/test_meminit.c:390 test_kmemcache()
>         warn: bool mask is always false 'ctor & zero'
>
> lib/test_meminit.c
>     378 static int __init test_kmemcache(int *total_failures)
>     379 {
>     380         int failures = 0, num_tests = 0;
>     381         int i, flags, size;
>     382         bool ctor, rcu, zero;
>     383
>     384         for (i = 0; i < 10; i++) {
>     385                 size = 8 << i;
>     386                 for (flags = 0; flags < 8; flags++) {
>     387                         ctor = flags & 1;
>     388                         rcu = flags & 2;
>     389                         zero = flags & 4;
> --> 390                         if (ctor & zero)
>                                     ^^^^^^^^^^^
> This is like (BIT(1) & BIT(4)) so it can't be true.  Was && intended?

Whoa, thanks!
I wonder why Clang never complained about that.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.