public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Eder Zulian <ezulian@redhat.com>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
	yonghong.song@linux.dev, john.fastabend@gmail.com,
	kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
	jolsa@kernel.org, acme@redhat.com, vmalik@redhat.com,
	williams@redhat.com
Subject: Re: [PATCH v2 3/3] libsubcmd: Silence compiler warning
Date: Wed, 23 Oct 2024 18:30:42 -0300	[thread overview]
Message-ID: <ZxlrAiA2t00YMjRz@x1> (raw)
In-Reply-To: <CAEf4BzbOMhw2yRTbN-n65TsDu+Zi8c-A6uVLN4SP7_Xpruttvg@mail.gmail.com>

On Tue, Oct 22, 2024 at 04:18:15PM -0700, Andrii Nakryiko wrote:
> On Tue, Oct 22, 2024 at 10:24 AM Eder Zulian <ezulian@redhat.com> wrote:
> >
> > Initialize the pointer 'o' in options__order to NULL to prevent a
> > compiler warning/error which is observed when compiling with the '-Og'
> > option, but is not emitted by the compiler with the current default
> > compilation options.
> >
> > For example, when compiling libsubcmd with
> >
> >  $ make "EXTRA_CFLAGS=-Og" -C tools/lib/subcmd/ clean all
> >
> > Clang version 17.0.6 and GCC 13.3.1 fail to compile parse-options.c due
> > to following error:
> >
> >   parse-options.c: In function ‘options__order’:
> >   parse-options.c:832:9: error: ‘o’ may be used uninitialized [-Werror=maybe-uninitialized]
> >     832 |         memcpy(&ordered[nr_opts], o, sizeof(*o));
> >         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >   parse-options.c:810:30: note: ‘o’ was declared here
> >     810 |         const struct option *o, *p = opts;
> >         |                              ^
> >   cc1: all warnings being treated as errors
> >
> > Signed-off-by: Eder Zulian <ezulian@redhat.com>
> > ---
> >  tools/lib/subcmd/parse-options.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> 
> First two patches look good, we can take them through bpf-next. What
> do we do with this one? Arnaldo, would you like us to take it through
> bpf-next as well (if yes, please give your ack), or you'd like to take

Yes, please take it thru bpf-next

Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>

- Arnaldo

> it through your tree?
 
> > diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c
> > index eb896d30545b..555d617c1f50 100644
> > --- a/tools/lib/subcmd/parse-options.c
> > +++ b/tools/lib/subcmd/parse-options.c
> > @@ -807,7 +807,7 @@ static int option__cmp(const void *va, const void *vb)
> >  static struct option *options__order(const struct option *opts)
> >  {
> >         int nr_opts = 0, nr_group = 0, nr_parent = 0, len;
> > -       const struct option *o, *p = opts;
> > +       const struct option *o = NULL, *p = opts;
> >         struct option *opt, *ordered = NULL, *group;
> >
> >         /* flatten the options that have parents */
> > --
> > 2.46.2

  reply	other threads:[~2024-10-23 21:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-22 17:23 [PATCH v2 0/3] Fix -Wmaybe-uninitialized warnings/errors Eder Zulian
2024-10-22 17:23 ` [PATCH v2 1/3] resolve_btfids: Fix compiler warnings Eder Zulian
2024-10-22 17:23 ` [PATCH v2 2/3] libbpf: Prevent compiler warnings/errors Eder Zulian
2024-10-22 17:23 ` [PATCH v2 3/3] libsubcmd: Silence compiler warning Eder Zulian
2024-10-22 23:18   ` Andrii Nakryiko
2024-10-23 21:30     ` Arnaldo Carvalho de Melo [this message]
2024-10-23  8:54 ` [PATCH v2 0/3] Fix -Wmaybe-uninitialized warnings/errors Jiri Olsa
2024-10-23 21:50 ` patchwork-bot+netdevbpf

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=ZxlrAiA2t00YMjRz@x1 \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=ezulian@redhat.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=vmalik@redhat.com \
    --cc=williams@redhat.com \
    --cc=yonghong.song@linux.dev \
    /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