Skip to contentSkip to conversation

lib: remove back_str initialization

PATCH Applied Tom Rix 2 participants 2 messages Apr 2, 2022 – Apr 5, 2022 Library code

lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 lib: remove back_str initialization

Clang static analysis reports this false positive glob.c:48:32: warning: Assigned value is garbage
or undefined

  char const *back_pat = NULL, *back_str = back_str;
                                ^~~~~~~~   ~~~~~~~~

back_str is set after back_pat and it's use is protected by the !back_pat check. It is not necessary to initialize back_str, so remove the initialization.

---
 lib/glob.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/glob.c +1 -1
index 85ecbda45cd8..15b73f490720 100644
@@ -45,7 +45,7 @@ bool __pure glob_match(char const *pat, char const *str)
 	 * (no exception for /), it can be easily proved that there's
 	 * never a need to backtrack multiple levels.
 	 */
-	char const *back_pat = NULL, *back_str = back_str;
+	char const *back_pat = NULL, *back_str;
 
 	/*
 	 * Loop over each token (character or class) in pat, matching
Signature · 1 line
2.27.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Tom Rix

Clang static analysis reports this false positive glob.c:48:32: warning: Assigned value is garbage
or undefined

Quoted 8 lines
  char const *back_pat = NULL, *back_str = back_str;
                                ^~~~~~~~   ~~~~~~~~

back_str is set after back_pat and it's use is protected by the !back_pat check. It is not necessary to initialize back_str, so remove the initialization.

Thanks for the patch!

Andrew, would you mind picking this up for us, please?

Quoted 21 lines
---
 lib/glob.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/glob.c +1 -2
index 85ecbda45cd8..15b73f490720 100644
@@ -45,7 +45,7 @@ bool __pure glob_match(char const *pat, char const *str)
         * (no exception for /), it can be easily proved that there's
         * never a need to backtrack multiple levels.
         */
-       char const *back_pat = NULL, *back_str = back_str;
+       char const *back_pat = NULL, *back_str;
 
        /*
         * Loop over each token (character or class) in pat, matching
--

2.27.0

Signature · 2 lines
Thanks,
~Nick Desaulniers