From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdQ7I-00024B-GW for qemu-devel@nongnu.org; Mon, 04 Nov 2013 14:47:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdQ7B-0000GF-Eh for qemu-devel@nongnu.org; Mon, 04 Nov 2013 14:47:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47382) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdQ7B-0000Fd-56 for qemu-devel@nongnu.org; Mon, 04 Nov 2013 14:47:09 -0500 Message-ID: <5277F987.7080000@redhat.com> Date: Mon, 04 Nov 2013 12:46:15 -0700 From: Eric Blake 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> In-Reply-To: <5276FCFC.3080600@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="F24aCuWq0rRpa3cL4UNcCmr5QEsfEMqcR" 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: Wenchao Xia , Max Reitz , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@gmail.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --F24aCuWq0rRpa3cL4UNcCmr5QEsfEMqcR Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 =3D 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). >> >=20 > 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --F24aCuWq0rRpa3cL4UNcCmr5QEsfEMqcR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSd/mHAAoJEKeha0olJ0NqN7cH/3a7yNNZwHDqMH1GudPTaVNN 1cvzUB1X6brzBRCDKb8TKpjPtqs0ZO6JyLMm+cmPxp+t8XkUA1pl3mLXWLwS4/4g T3RsOZt+AfoJeX15UY6jsaLqYBjiU49o6YcsZmyTzfaSxuRoKii0vyDH24RcmnRy MGaW7OWo3cZzuZQvHR+9Aoi2+YnfpOC6KJFUl6rFwDnAVEj8a3WBt+DclI03hmUt 0TGBgqCoxygxQPO7kpyZzFTr7Bm5IbuM+aWL8praV03MFJ4mTV0xAFIE/XK5EKSf a6qWG6q9/IssRTuGtQvJ7RRwWHk8t4L4Io48fhpTpZgTkRO5WYDrBh1QZQPIy68= =WuXf -----END PGP SIGNATURE----- --F24aCuWq0rRpa3cL4UNcCmr5QEsfEMqcR--