Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Keith Seitz <keiths@redhat.com>
Cc: "gdb-patches@sourceware.org ml" <gdb-patches@sourceware.org>
Subject: Re: [RFA] Constify find_condition_and_thread
Date: Fri, 01 Mar 2013 18:56:00 -0000	[thread overview]
Message-ID: <5130F9C9.4080407@redhat.com> (raw)
In-Reply-To: <5130F0FD.2040203@redhat.com>

On 03/01/2013 06:18 PM, Keith Seitz wrote:
>        else if (toklen >= 1 && strncmp (tok, "task", toklen) == 0)
>  	{
> -	  char *tmptok;
> +	  char *tmptok, *copy;
>  
>  	  tok = end_tok + 1;
> -	  tmptok = tok;
> -	  *task = strtol (tok, &tok, 0);
> -	  if (tok == tmptok)
> -	    error (_("Junk after task keyword."));
> +	  tmptok = copy = xstrdup (tok);
> +	  *task = strtol (copy, &copy, 0);
> +	  if (copy == tmptok)
> +	    {
> +	      xfree (tmptok);
> +	      error (_("Junk after task keyword."));
> +	    }

Why do we really need the xstrdups in this and the "task" cases?

> +const char *
> +skip_to_space_const (const char *chp)
> +{
> +  if (chp == NULL)
> +    return NULL;
> +  while (*chp && !isspace (*chp))
> +    chp++;
> +  return chp;
> +}

Note we in addition redo skip_to_space as:

char *
skip_to_space (char *chp)
{
  return (char *) skip_to_space_const (chp);
}

(or make that an inline function / #define)
-- 
Pedro Alves


      parent reply	other threads:[~2013-03-01 18:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-01 18:18 Keith Seitz
2013-03-01 18:40 ` Eli Zaretskii
2013-03-01 18:56   ` Pedro Alves
2013-03-01 19:33     ` Tom Tromey
2013-03-02  7:30       ` Eli Zaretskii
2013-03-01 18:56 ` Pedro Alves [this message]

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=5130F9C9.4080407@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@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