From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ad6eO-0002R8-8i for qemu-devel@nongnu.org; Mon, 07 Mar 2016 20:41:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ad6eN-0002rK-En for qemu-devel@nongnu.org; Mon, 07 Mar 2016 20:41:28 -0500 Message-ID: <56DE2E20.2020805@cn.fujitsu.com> Date: Tue, 8 Mar 2016 09:42:56 +0800 From: Changlong Xie MIME-Version: 1.0 References: <1455615450-15138-1-git-send-email-xiecl.fnst@cn.fujitsu.com> <1455615450-15138-3-git-send-email-xiecl.fnst@cn.fujitsu.com> <56DB21B7.7050104@redhat.com> <56DDA5FF.2050900@redhat.com> In-Reply-To: <56DDA5FF.2050900@redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v10 2/3] quorum: implement bdrv_add_child() and bdrv_del_child() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , Max Reitz , qemu devel , Alberto Garcia , Kevin Wolf , Stefan Hajnoczi Cc: qemu block , Jiang Yunhong , Dong Eddie , Markus Armbruster , "Dr. David Alan Gilbert" , Gonglei , zhanghailiang On 03/08/2016 12:02 AM, Eric Blake wrote: > On 03/05/2016 11:13 AM, Max Reitz wrote: > >>> + index = atoi(child->name + 9); >> >> Optional: Assert absence of an error: >> > > Indeed, atoi() is worthless, because it cannot do error detection. > >> unsigned long index; >> char *endptr; >> >> index = strtoul(child->name + 9, &endptr, 10); >> assert(index >= 0 && !*endptr); > > Still incorrect; you aren't handling errno properly for detecting all > errors. Even better is to use qemu_strtoul(), which already handles > proper error detection. > Will fix this in next version, thanks for pointing it out. Thanks -Xie