]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
lib/glob: clean up "bool abuse" in pointer arithmetic
authorJosh Law <objecting@objecting.org>
Sun, 1 Mar 2026 20:38:45 +0000 (20:38 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 28 Mar 2026 04:19:38 +0000 (21:19 -0700)
Replace the implicit 'bool' to 'int' conversion with an explicit ternary
operator.  This makes the pointer arithmetic clearer and avoids relying on
boolean memory representation for logic flow.

Link: https://lkml.kernel.org/r/20260301203845.2617217-1-objecting@objecting.org
Signed-off-by: Josh Law <objecting@objecting.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/glob.c

index 877bdd0884a6163048a7962087cf4013b90a6439..69311568ad3dc75265b6b421ce27c0393b4012ff 100644 (file)
@@ -73,7 +73,7 @@ bool __pure glob_match(char const *pat, char const *str)
                        if (c == '\0')  /* No possible match */
                                return false;
                        bool match = false, inverted = (*pat == '!');
-                       char const *class = pat + inverted;
+                       char const *class = inverted ? pat + 1 : pat;
                        unsigned char a = *class++;
 
                        /*