From patchwork Mon Jun 18 20:26:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 27914 Received: (qmail 113015 invoked by alias); 18 Jun 2018 20:26:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 112550 invoked by uid 89); 18 Jun 2018 20:26:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_STOCKGEN, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Jun 2018 20:26:44 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F07D340201A2 for ; Mon, 18 Jun 2018 20:26:42 +0000 (UTC) Received: from psique.yyz.redhat.com (unused-10-15-17-196.yyz.redhat.com [10.15.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8187E111DCEB; Mon, 18 Jun 2018 20:26:40 +0000 (UTC) From: Sergio Durigan Junior To: GDB Patches Cc: Pedro Alves , Sergio Durigan Junior Subject: [PATCH] Silence GCC "uninitialized" warning on minsyms.c:lookup_minimal_symbol_by_pc_section Date: Mon, 18 Jun 2018 16:26:34 -0400 Message-Id: <20180618202634.10452-1-sergiodj@redhat.com> In-Reply-To: <20180325191943.8246-12-palves@redhat.com> References: <20180325191943.8246-12-palves@redhat.com> X-IsSubscribed: yes Commit 20944a6e20324cd897bf6c4c5fd20ef7224dacaa ("Fix stepping past GNU ifunc resolvers (introduce lookup_msym_prefer)") introduced a new way to determine the 'want_type' variable on minsyms.c:lookup_minimal_symbol_by_pc_section. Because the 'lookup_msym_prefer' has a default value, we know that 'want_type' will always be initialized. However, GCC is complaining that the variable can be used uninitialized in the function: ../../gdb/minsyms.c: In function 'bound_minimal_symbol lookup_minimal_symbol_by_pc_section(CORE_ADDR, obj_section*, lookup_msym_prefer)': ../../gdb/minsyms.c:825:40: warning: 'want_type' may be used uninitialized in this function [-Wmaybe-uninitialized] && MSYMBOL_TYPE (&msymbol[hi]) != want_type (This is with gcc-8.1.1-1.fc29.x86_64). This patch fixes it by initializing 'want_type' with 'mst_text', which is the same default value that is passed in the 'lookup_msym_prefer' variable. Even though this can be considered an obvious patch, I'm sending it for approval. gdb/ChangeLog: 2018-06-18 Sergio Durigan Junior * minsyms.c (lookup_minimal_symbol_by_pc_section): Initialize 'want_type' to silence GCC warning. --- gdb/ChangeLog | 5 +++++ gdb/minsyms.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4fc6cf5446..5cf9da8e56 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-06-18 Sergio Durigan Junior + + * minsyms.c (lookup_minimal_symbol_by_pc_section): Initialize + 'want_type' to silence GCC warning. + 2018-06-18 Tom Tromey * solib-aix.c (solib_aix_get_section_offsets): Return diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 4882e58ee4..c9d89dc171 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -683,7 +683,7 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio struct minimal_symbol *best_symbol = NULL; struct objfile *best_objfile = NULL; struct bound_minimal_symbol result; - enum minimal_symbol_type want_type; + enum minimal_symbol_type want_type = mst_text; if (section == NULL) {