From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5271 invoked by alias); 1 Mar 2013 18:56:18 -0000 Received: (qmail 5190 invoked by uid 22791); 1 Mar 2013 18:56:16 -0000 X-SWARE-Spam-Status: No, hits=-8.0 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Mar 2013 18:56:11 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r21IuBUA020975 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 1 Mar 2013 13:56:11 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r21Iu9pm017559; Fri, 1 Mar 2013 13:56:10 -0500 Message-ID: <5130F9C9.4080407@redhat.com> Date: Fri, 01 Mar 2013 18:56:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Keith Seitz CC: "gdb-patches@sourceware.org ml" Subject: Re: [RFA] Constify find_condition_and_thread References: <5130F0FD.2040203@redhat.com> In-Reply-To: <5130F0FD.2040203@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 X-SW-Source: 2013-03/txt/msg00038.txt.bz2 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, ©, 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