From: "Metzger, Markus T" <markus.t.metzger@intel.com>
To: Enze Li <enze.li@hotmail.com>
Cc: "enze.li@gmx.com" <enze.li@gmx.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PING] [PATCH] gdb: initialize the data_head variable to eliminate compilation warnings
Date: Wed, 6 Jul 2022 14:02:10 +0000 [thread overview]
Message-ID: <DM8PR11MB574963B2FF3329BDA45F2778DE809@DM8PR11MB5749.namprd11.prod.outlook.com> (raw)
In-Reply-To: <OS3P286MB2152EF4E796B72F866DE34AFF0809@OS3P286MB2152.JPNP286.PROD.OUTLOOK.COM>
Hello Enze,
>> On a machine with gcc 12, I get this warning:
>>
>> CXX nat/linux-btrace.o
>> In function ‘btrace_error linux_read_bts(btrace_data_bts*,
>> btrace_target_info*, btrace_read_type)’,
>> inlined from ‘btrace_error linux_read_btrace(btrace_data*,
>> btrace_target_info*, btrace_read_type)’ at ../gdb/nat/linux-
>> btrace.c:935:29:
>> ../gdb/nat/linux-btrace.c:865:21: warning: ‘data_head’ may be used
>> uninitialized [-Wmaybe-uninitialized]
>> 865 | pevent->last_head = data_head;
>> | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
That's a false positive. Since RETRIES > 0, the loop is executed at least
once and DATA_HEAD is initialized.
>> diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
>> index b0d6dcd7cf1..c31fb5ffe43 100644
>> --- a/gdb/nat/linux-btrace.c
>> +++ b/gdb/nat/linux-btrace.c
>> @@ -789,7 +789,7 @@ linux_read_bts (struct btrace_data_bts *btrace,
>> struct perf_event_buffer *pevent;
>> const uint8_t *begin, *end, *start;
>> size_t buffer_size, size;
>> - __u64 data_head, data_tail;
>> + __u64 data_head = 0, data_tail;
>> unsigned int retries = 5;
>>
>> pevent = &tinfo->variant.bts.bts;
OK to pacify GCC. Thanks for the patch. LGTM.
regards,
markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
next prev parent reply other threads:[~2022-07-06 14:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-11 10:36 Enze Li
2022-07-06 13:53 ` [PING] " Enze Li
2022-07-06 14:02 ` Metzger, Markus T [this message]
2022-07-08 13:47 ` Enze Li
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=DM8PR11MB574963B2FF3329BDA45F2778DE809@DM8PR11MB5749.namprd11.prod.outlook.com \
--to=markus.t.metzger@intel.com \
--cc=enze.li@gmx.com \
--cc=enze.li@hotmail.com \
--cc=gdb-patches@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).