From: Andrew Burgess <aburgess@redhat.com>
To: Tom Tromey <tromey@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [pushed] Fix maybe-uninitialized warning in py-infthread.c
Date: Mon, 28 Feb 2022 17:59:48 +0000 [thread overview]
Message-ID: <20220228175948.GB1212730@redhat.com> (raw)
In-Reply-To: <20220228175438.289669-1-tromey@adacore.com>
* Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> [2022-02-28 10:54:38 -0700]:
> I got this warning from py-infthread.c using the Fedora 34 system GCC:
>
> ../../binutils-gdb/gdb/python/py-infthread.c:102:30: warning: ‘extra_info’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>
> I think this happens because GDB_PY_HANDLE_EXCEPTION expands to an
> 'if' whose condition is always true -- but GCC can't know this. This
> patch avoids the warning by adding a harmless initialization.
Thanks for fixing this.
Andrew
> ---
> gdb/python/py-infthread.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
> index 66c3efdf6cc..c94d5b0ddab 100644
> --- a/gdb/python/py-infthread.c
> +++ b/gdb/python/py-infthread.c
> @@ -87,7 +87,9 @@ thpy_get_details (PyObject *self, void *ignore)
>
> THPY_REQUIRE_VALID (thread_obj);
>
> - const char *extra_info;
> + /* GCC can't tell that extra_info will always be assigned after the
> + 'catch', so initialize it. */
> + const char *extra_info = nullptr;
> try
> {
> extra_info = target_extra_thread_info (thread_obj->thread);
> --
> 2.31.1
>
prev parent reply other threads:[~2022-02-28 17:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-28 17:54 Tom Tromey
2022-02-28 17:59 ` Andrew Burgess [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=20220228175948.GB1212730@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).