From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrQeb-000765-Qv for qemu-devel@nongnu.org; Fri, 13 Dec 2013 06:11:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VrQeV-0002qo-Qb for qemu-devel@nongnu.org; Fri, 13 Dec 2013 06:11:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:13282) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrQeV-0002qa-IO for qemu-devel@nongnu.org; Fri, 13 Dec 2013 06:11:27 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBDBBPa0029817 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Dec 2013 06:11:26 -0500 Message-ID: <1386928632.8306.14.camel@nilsson.home.kraxel.org> From: Gerd Hoffmann Date: Fri, 13 Dec 2013 10:57:12 +0100 In-Reply-To: <52A8EF33.4020207@redhat.com> References: <1386763230-9202-1-git-send-email-kraxel@redhat.com> <52A8EF33.4020207@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] inet_listen_opts: add error checking List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org Hi, > > WHY is strtol() such a PAINFUL interface to use correctly? And WHY > can't qemu copy libvirt's lead of writing a SANE wrapper function, and > then mandating that the rest of the code base use the sane wrapper > instead of strtol()? > Turns out there already is one, just /me didn't know. So, for the record and the mailing list archives: util/cutil.c provides parse_uint() and parse_uint_full(). The first returns a pointer to the remaining bits to parse, so you can inspect the suffix (if any). The second errors out in case there is trailing garbage, simliar to the libvirt wrapper in case you pass in NULL as end_ptr. cheers, Gerd