From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdWEf-00020B-0M for qemu-devel@nongnu.org; Mon, 04 Nov 2013 21:19:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdWEW-0007Dt-3G for qemu-devel@nongnu.org; Mon, 04 Nov 2013 21:19:16 -0500 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:57775) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdWEV-0007Di-Ec for qemu-devel@nongnu.org; Mon, 04 Nov 2013 21:19:08 -0500 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Nov 2013 07:49:05 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 7CEA6394003F for ; Tue, 5 Nov 2013 07:48:39 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id rA52IxvY47448108 for ; Tue, 5 Nov 2013 07:48:59 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id rA52J2Pv027191 for ; Tue, 5 Nov 2013 07:49:02 +0530 Message-ID: <52785598.7060606@linux.vnet.ibm.com> Date: Tue, 05 Nov 2013 10:19:04 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1381787553-12497-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1381787553-12497-3-git-send-email-xiawenc@linux.vnet.ibm.com> <5274F575.6020106@redhat.com> <5276FCFC.3080600@linux.vnet.ibm.com> <5277F987.7080000@redhat.com> In-Reply-To: <5277F987.7080000@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH V4 2/6] qcow2: add error message in qcow2_write_snapshots() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , Max Reitz , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@gmail.com 于 2013/11/5 3:46, Eric Blake 写道: > On 11/03/2013 06:48 PM, Wenchao Xia wrote: >>> On 14.10.2013 23:52, Wenchao Xia wrote: >>>> The function still returns int since qcow2_snapshot_delete() will >>>> return the number. >>>> > > >>>> @@ -227,24 +239,40 @@ static int >>>> qcow2_write_snapshots(BlockDriverState *bs) >>>> >>>> ret = bdrv_pwrite(bs->file, offset, &h, sizeof(h)); >>>> if (ret < 0) { >>>> + error_setg(errp, >>>> + "Failed in write of snapshot header at %" >>>> + PRIi64 " with size %" PRIu64 ": %d (%s)", >>>> + offset, sizeof(h), ret, strerror(-ret)); >>> >>> Again, on 32 bit systems, sizeof(size_t) is generally 4 and not 8 (you >>> may want to cast sizeof(h) to int and just use %d). >>> >> >> Maybe caset as (int64_t)sizeof(h) to avoid possible incomplete value? > > If we have objects larger than 2G (such that sizeof(h) would require > more than 31 bits), we have other issues to worry about. Casting to int > and using %d is safe enough. > OK, will use %d.