public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Enze Li <lienze@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb: initialize the data_head variable to eliminate compilation warnings
Date: Fri,  8 Jul 2022 13:49:50 +0000 (GMT)	[thread overview]
Message-ID: <20220708134950.93E0738582BA@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=44ca285b73b68f6a8fa3e89004b510d6b7d98e91

commit 44ca285b73b68f6a8fa3e89004b510d6b7d98e91
Author: Enze Li <enze.li@hotmail.com>
Date:   Sat Jun 11 18:36:48 2022 +0800

    gdb: initialize the data_head variable to eliminate compilation warnings
    
    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;
          |   ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
    ../gdb/nat/linux-btrace.c: In function ‘btrace_error linux_read_btrace(btrace_data*, btrace_target_info*, btrace_read_type)’:
    ../gdb/nat/linux-btrace.c:792:9: note: ‘data_head’ was declared here
      792 |   __u64 data_head, data_tail;
          |         ^~~~~~~~~
    
    Fix this by initializing the 'data_head' variable.
    
    Tested by rebuilding on x86_64 openSUSE Tumbleweed with gcc 12.

Diff:
---
 gdb/nat/linux-btrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;


                 reply	other threads:[~2022-07-08 13:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220708134950.93E0738582BA@sourceware.org \
    --to=lienze@sourceware.org \
    --cc=gdb-cvs@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).