From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100360 invoked by alias); 17 Jan 2018 17:17:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 100348 invoked by uid 89); 17 Jan 2018 17:17:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*r:112 X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 Jan 2018 17:17:10 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w0HHH3sF020864 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 17 Jan 2018 12:17:08 -0500 Received: by simark.ca (Postfix, from userid 112) id ABC6E1E5B7; Wed, 17 Jan 2018 12:17:03 -0500 (EST) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 7246E1E074; Wed, 17 Jan 2018 12:17:02 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 17 Jan 2018 17:17:00 -0000 From: Simon Marchi To: Sergio Durigan Junior Cc: GDB Patches , Eli Zaretskii Subject: Re: [PATCH] Fix warning on gdb/compile/compile.c (C++-ify "triplet_rx") In-Reply-To: <20180116194641.22361-1-sergiodj@redhat.com> References: <87po69zkxe.fsf@redhat.com> <20180116194641.22361-1-sergiodj@redhat.com> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.2 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 17 Jan 2018 17:17:03 +0000 X-IsSubscribed: yes X-SW-Source: 2018-01/txt/msg00351.txt.bz2 On 2018-01-16 14:46, Sergio Durigan Junior wrote: > This fixes a GCC warning that happens when compiling > gdb/compile/compile.c on some GCC versions (e.g., "gcc (GCC) 7.2.1 > 20180104 (Red Hat 7.2.1-6)"). > > It's a simple patch that converts "triplet_rx" from "char *" to > "std::string", thus guaranteeing that it will be always initialized. > > I've regtested this patch and did not find any regressions. OK to > apply on both master and 8.1 (after creating a bug for it)? > > gdb/ChangeLog: > 2018-01-16 Sergio Durigan Junior > > * compile/compile.c (compile_to_object): Convert "triplet_rx" > to "std::string". > --- > gdb/compile/compile.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c > index 2ee75930ac..47646169c8 100644 > --- a/gdb/compile/compile.c > +++ b/gdb/compile/compile.c > @@ -463,7 +463,7 @@ compile_to_object (struct command_line *cmd, const > char *cmd_string, > char **argv; > int ok; > struct gdbarch *gdbarch = get_current_arch (); > - char *triplet_rx; > + std::string triplet_rx; > char *error_message; > > if (!target_has_execution) > @@ -527,15 +527,15 @@ compile_to_object (struct command_line *cmd, > const char *cmd_string, > } > else > { > - const char *os_rx = osabi_triplet_regexp (gdbarch_osabi > (gdbarch)); > - const char *arch_rx = gdbarch_gnu_triplet_regexp (gdbarch); > + std::string os_rx = osabi_triplet_regexp (gdbarch_osabi > (gdbarch)); > + std::string arch_rx = gdbarch_gnu_triplet_regexp (gdbarch); Making these std::string makes unnecessary copies. You can write the line below like this: triplet_rx = std::string (arch_rx) + "(-[^-]*)?-" + os_rx; Otherwise, LGTM. Simon