linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib: remove back_str initialization
@ 2022-04-02 13:15 Tom Rix
  2022-04-05 18:05 ` Nick Desaulniers
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Rix @ 2022-04-02 13:15 UTC (permalink / raw)
  To: nathan, ndesaulniers; +Cc: linux-kernel, llvm, Tom Rix

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.

Signed-off-by: Tom Rix <trix@redhat.com>
---
 lib/glob.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/glob.c b/lib/glob.c
index 85ecbda45cd8..15b73f490720 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] lib: remove back_str initialization
  2022-04-02 13:15 [PATCH] lib: remove back_str initialization Tom Rix
@ 2022-04-05 18:05 ` Nick Desaulniers
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2022-04-05 18:05 UTC (permalink / raw)
  To: Tom Rix, Andrew Morton; +Cc: nathan, linux-kernel, llvm

On Sat, Apr 2, 2022 at 6:16 AM Tom Rix <trix@redhat.com> wrote:
>
> 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.
>

Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

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

> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>  lib/glob.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/glob.c b/lib/glob.c
> index 85ecbda45cd8..15b73f490720 100644
> --- a/lib/glob.c
> +++ b/lib/glob.c
> @@ -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
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-05 23:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-02 13:15 [PATCH] lib: remove back_str initialization Tom Rix
2022-04-05 18:05 ` Nick Desaulniers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).