Skip to contentSkip to conversation

lib/glob: clean up "bool abuse" in pointer arithmetic

PATCH Applied Josh Law 1 participant 1 message Mar 1 Library code

lore
Share & tools
lore

Josh Law

author
#0 lore raw

PATCH 1/1 lib/glob: clean up "bool abuse" in pointer arithmetic

From: Josh Law <[email protected]>

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.

---
 lib/glob.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/glob.c +1 -1
index 877bdd0884a6..69311568ad3d 100644
@@ -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++;
 
 			/*
Signature · 1 line
2.43.0