Re: [PATCH 2/2] lib: glob: replace bitwise OR with logical operation on boolean
From: Josh Law
Date: Sun Mar 01 2026 - 14:40:27 EST
Hm, I see that, I am sorry about that haha, I tested the functionality of the code and it seems all fine, if anything major happens, I'll release another patch fixing this, I am sorry
V/R
1 Mar 2026 19:25:44 Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>:
> On Sun, 1 Mar 2026 15:21:42 +0000 Josh Law <hlcj1234567@xxxxxxxxx> wrote:
>
>> Using bitwise OR (|=) on a boolean variable is valid C, but replacing it with a direct logical assignment makes the intent clearer and appeases strict static analysis tools.
>>
>
> Fair enough.
>
>> --- a/lib/glob.c
>> +++ b/lib/glob.c
>> @@ -96,7 +96,8 @@ bool __pure glob_match(char const *pat, char const *str)
>> class += 2;
>> /* Any special action if a > b? */
>> }
>> - match |= (a <= c && c <= b);
>> + if (a <= c && c <= b)
>> + match = true;
>> } while ((a = *class++) != ']');
>>
>> if (match == inverted)
>
> But if we're concerned about bool abuse, what's this?
>
> bool match = false, inverted = (*pat == '!');
> char const *class = pat + inverted;