From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKbpc-0001Y2-1k for qemu-devel@nongnu.org; Tue, 26 Mar 2013 17:55:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKbpa-000879-LS for qemu-devel@nongnu.org; Tue, 26 Mar 2013 17:54:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKbpa-00086z-DQ for qemu-devel@nongnu.org; Tue, 26 Mar 2013 17:54:58 -0400 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 r2QLsvNf003135 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 26 Mar 2013 17:54:57 -0400 Message-ID: <51521930.5060207@redhat.com> Date: Tue, 26 Mar 2013 15:54:56 -0600 From: Eric Blake MIME-Version: 1.0 References: <706fbb2daa8c17bc9374e9c05d7da83a1fb6a6a4.1363957855.git.phrdina@redhat.com> In-Reply-To: <706fbb2daa8c17bc9374e9c05d7da83a1fb6a6a4.1363957855.git.phrdina@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2EFJTWWQXCWJEHNAPICRC" Subject: Re: [Qemu-devel] [PATCH v2 09/12] block: update return value from bdrv_snapshot_create List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Hrdina Cc: lcapitulino@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2EFJTWWQXCWJEHNAPICRC Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 03/22/2013 07:16 AM, Pavel Hrdina wrote: > If we provide error message, we should also provide a return code. > In some cases we could not care about any error message and the return > code is enough for as. >=20 > Signed-off-by: Pavel Hrdina > --- > +++ b/qemu-img.c > @@ -1943,6 +1943,7 @@ static int img_snapshot(int argc, char **argv) > int action =3D 0; > qemu_timeval tv; > bool quiet =3D false; > + Error *local_err; > =20 > bdrv_oflags =3D BDRV_O_FLAGS | BDRV_O_RDWR; > /* Parse commandline parameters */ > @@ -2019,10 +2020,10 @@ static int img_snapshot(int argc, char **argv) > sn.date_sec =3D tv.tv_sec; > sn.date_nsec =3D tv.tv_usec * 1000; > =20 > - ret =3D bdrv_snapshot_create(bs, &sn, NULL); > + local_err =3D NULL; > + ret =3D bdrv_snapshot_create(bs, &sn, &local_err); > if (ret) { Isn't it true that 'ret' is non-zero iff 'local_err' is no longer NULL? In which case, why not have the functions return 'void' instead of an integer, and use the null-ness of local_err be your test of whether bdrv_snapshot_create failed. > - error_report("Could not create snapshot '%s': %d (%s)", > - snapshot_name, ret, strerror(-ret)); > + qemu_img_handle_error(local_err); Same question as in 8/12 - you have already guaranteed that qemu_img_handle_error will only be called if local_err is nonnull, so does that helper function have to do a sanity check? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2EFJTWWQXCWJEHNAPICRC 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.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRUhkwAAoJEKeha0olJ0NqQx0H/A4qjKF5fs7qwoBbVnVAA/pT aAXNjwV9q/bBbrYCJqo987TeNxNUdulUU70uir53Ghcu4idPbznc9rSFCubXLbUR rEFp/FANlePmRUj/fO0+WFLizETpIgMW3YJx3/YEhd5IrbjP3Rn+kuaY9g2Vypjj L3AyiuQrZIPYydjYGPXxGfSoRa9n3by/QVupXXlBYIDnJmTh9C9g3Dq9vJQRLopL PtKpofAAGoINZUhyCXO1yqPb3TFIdU1LmBOuOZA4+SDWPsKgtaSea+wGk8KBvFyK o/4+LiRMiYFMC/s9siXAiH6iyyQczAvTLD/5hYl7ZZ3X0gdLlfmAbCA7K+oLbMg= =Fs9h -----END PGP SIGNATURE----- ------enig2EFJTWWQXCWJEHNAPICRC--