Received: from eggs.gnu.org ([208.118.235.92]:52798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtlzU-0001AC-57 for qemu-devel@nongnu.org; Fri, 11 Jan 2013 16:18:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TtlzR-00026x-5y for qemu-devel@nongnu.org; Fri, 11 Jan 2013 16:18:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtlzQ-00026p-TY for qemu-devel@nongnu.org; Fri, 11 Jan 2013 16:18:13 -0500 Date: Fri, 11 Jan 2013 19:19:48 -0200 From: Eduardo Habkost Message-ID: <20130111211948.GT10683@otherpad.lan.raisama.net> References: <1357928108-21066-1-git-send-email-ehabkost@redhat.com> <1357928108-21066-4-git-send-email-ehabkost@redhat.com> <50F07EBD.9010109@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50F07EBD.9010109@redhat.com> Subject: Re: [Qemu-devel] [libvirt] [PATCH 03/10] vl.c: Isolate code specific to "-numa node" option type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: libvir-list@redhat.com, Chegu Vinod , qemu-devel@nongnu.org, Anthony Liguori On Fri, Jan 11, 2013 at 02:06:05PM -0700, Eric Blake wrote: > On 01/11/2013 11:15 AM, Eduardo Habkost wrote: > > Extract the code that's specific for the "node" -numa option type (the > > only one, today) to a separate function. > > > > The extracted code will eventually become a function specific for a > > "numa-node" config section, independent from the numa_add() code. > > > + if (get_param_value(option, 128, "nodeid", optarg) == 0) { > > + nodenr = nb_numa_nodes; > > + } else { > > + nodenr = strtoull(option, NULL, 10); > > } > > strtoull() needs additional error checking after the fact, to make sure > I didn't pass an empty string, trailing garbage, or so many digits I > triggered overflow. > > > > + if (get_param_value(option, 128, "cpus", optarg) != 0) { > > + value = strtoull(option, &endptr, 10); > > + if (*endptr == '-') { > > + endvalue = strtoull(endptr+1, &endptr, 10); > > } else { > > - nodenr = strtoull(option, NULL, 10); > > + endvalue = value; > > } > > More uses of strtoull() that aren't guarding against all possible errors. All this code gets replaced in patch 09/10. The only remaining strtoull() call gets error-checking at patch 06/10. -- Eduardo