Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] constify to_attach
Date: Wed, 21 May 2014 19:45:00 -0000	[thread overview]
Message-ID: <537D025D.3090207@redhat.com> (raw)
In-Reply-To: <1400696455-29563-1-git-send-email-tromey@redhat.com>

On 05/21/2014 07:20 PM, Tom Tromey wrote:

> The code in parse_pid_to_attach seems a little bogus to me.  If there
> is a platform with a broken strtoul, we have better methods for fixing
> the issue now.  However, I left the code as is since it is clearly ok
> to do so.

Yeah.  We should probably use get_number or some such that accepts
convenience vars even.

> +parse_pid_to_attach (const char *args)
>  {
>    unsigned long pid;
>    char *dummy;
> @@ -3257,7 +3257,7 @@ parse_pid_to_attach (char *args)
>    if (!args)
>      error_no_arg (_("process-id to attach"));
>  
> -  dummy = args;
> +  dummy = (char *) args;
>    pid = strtoul (args, &dummy, 0);
>    /* Some targets don't set errno on errors, grrr!  */
>    if ((pid == 0 && dummy == args) || dummy != &args[strlen (args)])

errno would be necessary to catch overflow, but not to check whether
the number was syntactically correct.  strtoul always sets *endptr to
point to the address of the first invalid character (and never to NULL).

So you could just remove the 'dummy' assignment.

But I'll understand if you want to keep it.

The patch looks fine to me.

-- 
Pedro Alves


  parent reply	other threads:[~2014-05-21 19:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-21 18:21 Tom Tromey
2014-05-21 18:58 ` Tom Tromey
2014-05-21 21:22   ` Joel Brobecker
2014-05-21 21:36     ` Tom Tromey
2014-05-21 22:05       ` Joel Brobecker
2014-05-21 22:55         ` Tom Tromey
2014-05-21 19:45 ` Pedro Alves [this message]
2014-06-04 17:09   ` Tom Tromey

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=537D025D.3090207@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /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