lib: glob: add explicit include for export.h
PATCH 1/2 lib: glob: add explicit include for export.h
Include <linux/export.h> explicitly instead of relying on it being implicitly included by <linux/module.h> for the EXPORT_SYMBOL macro.
--- lib/glob.c | 1 + 1 file changed, 1 insertion(+)
lib/glob.c +1 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: (GPL-2.0 OR MIT) #include <linux/module.h> #include <linux/glob.h> +#include <linux/export.h> /* * The only reason this code can be compiled as a module is because the
Signature · 1 line
2.43.0
PATCH 2/2 lib: glob: replace bitwise OR with logical operation on boolean
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.
--- lib/glob.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/glob.c +2 -1
@@ -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)
Signature · 1 line
2.43.0
Andrew Morton
maintainerRe: [PATCH 2/2] lib: glob: replace bitwise OR with logical operation on boolean
Quoted 2 lines · On Sun, 1 Mar 2026 15:21:42 +0000 Josh Law <[email protected]> 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.
lib/glob.c bool __pure glob_match(char const *pat, char const *str) · line 103
Quoted 12 lines
lib/glob.c +2
-1@@ -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;
Re: [PATCH 2/2] lib: glob: replace bitwise OR with logical operation on boolean
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 <[email protected]>:
Quoted 24 lines · On Sun, 1 Mar 2026 15:21:42 +0000 Josh Law <[email protected]> wrote:
Quoted 3 lines
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.
lib/glob.c bool __pure glob_match(char const *pat, char const *str) · line 103
Quoted 12 lines
lib/glob.c +2
-1@@ -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;
Andrew Morton
maintainerRe: [PATCH 2/2] lib: glob: replace bitwise OR with logical operation on boolean
Quoted 26 lines · On Sun, 1 Mar 2026 19:40:16 +0000 Josh Law <[email protected]> wrote:
1 Mar 2026 19:25:44 Andrew Morton <[email protected]>:
Quoted 24 lines · On Sun, 1 Mar 2026 15:21:42 +0000 Josh Law <[email protected]> wrote:
Quoted 3 lines
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.
lib/glob.c bool __pure glob_match(char const *pat, char const *str) · line 103
Quoted 12 lines
lib/glob.c +2
-1@@ -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;
OK, please don't top-post and please do wordwrap the email text.
Quoted 3 lines
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
You did't add this. It's existing code which I felt you might want to consider cleaning up.
Re: [PATCH 2/2] lib: glob: replace bitwise OR with logical operation on boolean
In reply to Andrew MortonQuoted 6 lines · On Sun, 1 Mar 2026 11:25:42 -0800 Andrew Morton <[email protected]>…
Quoted 2 lines · On Sun, 1 Mar 2026 15:21:42 +0000 Josh Law <[email protected]> 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.
It might even generate better code.
Compilers have been known to generate 'really crap code(tm)' for boolean arithmetic.
David
Quoted 20 lines
lib/glob.c bool __pure glob_match(char const *pat, char const *str) · line 103
Quoted 13 lines
lib/glob.c +2
-1@@ -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;
Re: [PATCH 2/2] lib: glob: replace bitwise OR with logical operation on boolean
In reply to Josh LawHi Josh,
Quoted 3 lines · Josh Law
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.
Signed-off-by Josh Law <[email protected]>
checkpath.pl reported the following warnings:
WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?)
#81:
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.
WARNING: From:/Signed-off-by: email address mismatch: 'From: Josh Law <[email protected]>' != 'Signed-off-by: Josh Law <[email protected]>'
total: 0 errors, 2 warnings, 0 checks, 9 lines checked
Regards,
Kuan-Wei
Quoted 22 lines
--- lib/glob.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)lib/glob.c +2
-1@@ -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)Signature · 1 line
2.43.0
Re: [PATCH 2/2] lib: glob: replace bitwise OR with logical operation on boolean
Quoted 9 lines · Kuan-Wei Chiu
Hi Josh,
Quoted 3 lines · Josh Law
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.
Signed-off-by Josh Law <[email protected]>checkpath.pl reported the following warnings:
Quoted 8 lines
WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?)
#81:
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.WARNING: From:/Signed-off-by: email address mismatch: 'From: Josh Law <[email protected]>' != 'Signed-off-by: Josh Law <[email protected]>'
total: 0 errors, 2 warnings, 0 checks, 9 lines checked
BTW, both of your patches does not apply cleanly.
Regards,
Kuan-Wei
Re: [PATCH 2/2] lib: glob: replace bitwise OR with logical operation on boolean
Quoted 9 lines
Quoted 9 lines
checkpath.pl reported the following warnings:
WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?)
#81:
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.WARNING: From:/Signed-off-by: email address mismatch: 'From: Josh Law <[email protected]>' != 'Signed-off-by: Josh Law <[email protected]>'
Quoted 7 lines
Quoted 2 lines
total: 0 errors, 2 warnings, 0 checks, 9 lines checked
BTW, both of your patches does not apply cleanly.
Regards,
Kuan-Wei
I think Andrew fixed that....
Including the from lines
V/R