public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: GDB Patches <gdb-patches@sourceware.org>,  Eli Zaretskii <eliz@gnu.org>
Subject: Re: [PATCH] Fix warning on gdb/compile/compile.c (C++-ify "triplet_rx")
Date: Wed, 17 Jan 2018 23:48:00 -0000	[thread overview]
Message-ID: <87o9lscahp.fsf@redhat.com> (raw)
In-Reply-To: <ecd8ed6b330969687106225b887f76bc@polymtl.ca> (Simon Marchi's	message of "Wed, 17 Jan 2018 18:42:15 -0500")

On Wednesday, January 17 2018, Simon Marchi wrote:

> On 2018-01-17 18:07, Sergio Durigan Junior wrote:
>> On Wednesday, January 17 2018, Simon Marchi wrote:
>>
>>> 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  <sergiodj@redhat.com>
>>>>
>>>> 	* 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.
>>
>> Thanks, Simon.
>>
>> Pushed to master:
>>
>> 7d937cad0acdccd0ff485435fbe16f005e994c66
>>
>> Is it OK to push this to the 8.1 branch as well?  If so, I'm not sure I
>> should create a bug for this, or just go ahead and push it.
>
> Yes, it is fine to go to the 8.1 branch.  A PR is not necessary right
> now.  They are only necessary after there was an initial release on
> the branch, to track what fixes were made on top of that initial
> version.

Awesome.  In this case, pushed to the 8.1 branch:

2a54d2158beeb2833cb3fb4da68e7c55e341159a

Thanks,

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/

  reply	other threads:[~2018-01-17 23:48 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <announce.20180105041805.3FC35808E9@joel.gnat.com>
2018-01-16 17:31 ` [ANNOUNCEMENT] GDB 8.1 release branch created! Eli Zaretskii
2018-01-16 19:02   ` Sergio Durigan Junior
2018-01-16 19:46     ` [PATCH] Fix warning on gdb/compile/compile.c (C++-ify "triplet_rx") Sergio Durigan Junior
2018-01-17 15:33       ` Eli Zaretskii
2018-01-17 17:17       ` Simon Marchi
2018-01-17 23:07         ` Sergio Durigan Junior
2018-01-17 23:42           ` Simon Marchi
2018-01-17 23:48             ` Sergio Durigan Junior [this message]
2018-01-16 20:32     ` [PATCH] Fix unitialized warning on gdb/typeprint.c:whatis_exp Sergio Durigan Junior
2018-01-17 15:34       ` Eli Zaretskii
2018-01-17 16:48       ` Pedro Alves
2018-01-17 18:03         ` Sergio Durigan Junior
2018-01-20  1:03       ` [PATCH] Fix segfault when using 'set print object on' + whatis <struct> Sergio Durigan Junior
2018-01-22 17:42         ` [PATCH v2] Fix segfault when using 'set print object on' + whatis <struct> (Re: [PATCH] Fix segfault when using 'set print object on' + whatis <struct>) Pedro Alves
2018-01-22 18:04           ` Sergio Durigan Junior
2018-01-22 19:53             ` Pedro Alves
2018-01-22 20:11               ` Sergio Durigan Junior
2018-01-16 20:36     ` [ANNOUNCEMENT] GDB 8.1 release branch created! Sergio Durigan Junior
2018-01-17  3:36       ` Eli Zaretskii
2018-01-17 16:46         ` Sergio Durigan Junior
2018-01-17 11:04       ` Pedro Alves
2018-01-17 16:38         ` Sergio Durigan Junior
2018-01-17 16:46           ` Eli Zaretskii
2018-01-17 16:50             ` Pedro Alves
2018-01-17 18:21               ` Eli Zaretskii
2018-01-18 15:53   ` Eli Zaretskii
2018-01-25 16:58     ` Eli Zaretskii
2018-01-26 14:18       ` Eli Zaretskii
2018-01-26 15:37         ` Simon Marchi
2018-01-26 18:53           ` Eli Zaretskii
2018-01-27 16:42             ` Eli Zaretskii
2018-02-01 15:12               ` Yao Qi
2018-02-01 16:27                 ` Eli Zaretskii
2018-02-01 16:51                   ` Yao Qi
2018-02-01 17:33                     ` Eli Zaretskii
2018-02-01 21:32                       ` Yao Qi
2018-02-02 15:23                         ` Eli Zaretskii
2018-02-02 15:53                           ` Joel Brobecker
2018-02-02 16:27                             ` Simon Marchi
2018-02-02 17:42                             ` Joseph Myers

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=87o9lscahp.fsf@redhat.com \
    --to=sergiodj@redhat.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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).