From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32060 invoked by alias); 6 Mar 2014 13:24:16 -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 32027 invoked by uid 89); 6 Mar 2014 13:24:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 06 Mar 2014 13:24:10 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B0B9B11617A; Thu, 6 Mar 2014 08:24:08 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 8SB-HDc6YllW; Thu, 6 Mar 2014 08:24:08 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 2B4E211612A; Thu, 6 Mar 2014 08:24:07 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id E9841E0CE3; Thu, 6 Mar 2014 05:24:10 -0800 (PST) Date: Thu, 06 Mar 2014 13:24:00 -0000 From: Joel Brobecker To: Pedro Alves Cc: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH 2/4] Error on bad count number Message-ID: <20140306132410.GE16858@adacore.com> References: <1394023608-10761-1-git-send-email-yao@codesourcery.com> <1394023608-10761-3-git-send-email-yao@codesourcery.com> <20140305142939.GB16858@adacore.com> <531749BA.8050806@redhat.com> <5318456D.3010709@codesourcery.com> <53186842.9030704@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53186842.9030704@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2014-03/txt/msg00154.txt.bz2 > I think that what exact number is used for error return > is mostly irrelevant. The interface of get_number's value > return alone is just not sufficient as is. Not changing > the prototype, we could e.g. in addition of checking for > zero return, have the callers check whether the passed in > char pointer pointer advanced (and make sure get_number > doesn't advance the pointer on invalid input). So the > correct use becomes: > > p = arg; > num = get_number (&p); > if (num == 0 && p == arg) > error (_("Bad number: '%s'"), arg); > > Sort of like strtol vs itoa. There are not so many calls to that routine or (get_number_trailer), so I think it would be easy to change the interface. But better yet, why not throw an error? Most of the current uses just throw an error right after when the returned value was 0. There are some uses where there is no error handling, but I think they need to be reviewed as they could actually benefit from it. After a quick glance, it wasn't obvious to me whether there was a hole in the implementation or not. -- Joel