mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Josh Law <hlcj1234567@gmail.com>
Cc: linux-kernel@vger.kernel.org, Josh Law <objecting@objecting.org>
Subject: Re: [PATCH] lib/glob: initialize back_str to silence uninitialized variable warning
Date: Thu, 12 Mar 2026 15:46:54 -0700	[thread overview]
Message-ID: <20260312154654.cb240d04a038e92b17e3f190@linux-foundation.org> (raw)
In-Reply-To: <20260312215249.50165-1-objecting@objecting.org>

On Thu, 12 Mar 2026 21:52:49 +0000 Josh Law <hlcj1234567@gmail.com> wrote:

> back_str is only used when back_pat is non-NULL, and both are always
> set together, so it is safe in practice. Initialize back_str to NULL
> to make this safety invariant explicit and silence compiler/static
> analysis warnings.
> 
> ...
>
> --- a/lib/glob.c
> +++ b/lib/glob.c
> @@ -47,7 +47,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;
> +	char const *back_pat = NULL, *back_str = NULL;
>  

I can certainly believe that some compiler versions will warn about
this, but please always quote the warning/error message when fixing
such things.


      reply	other threads:[~2026-03-12 22:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12 21:52 Josh Law
2026-03-12 22:46 ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260312154654.cb240d04a038e92b17e3f190@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=hlcj1234567@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=objecting@objecting.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®