From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLU9W-0001oH-Ci for qemu-devel@nongnu.org; Wed, 11 Feb 2015 05:04:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLU9T-0007jE-6K for qemu-devel@nongnu.org; Wed, 11 Feb 2015 05:04:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37625) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLU9S-0007iv-Uz for qemu-devel@nongnu.org; Wed, 11 Feb 2015 05:04:11 -0500 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 t1BA49j7014358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 11 Feb 2015 05:04:10 -0500 Date: Wed, 11 Feb 2015 11:04:07 +0100 From: Kevin Wolf Message-ID: <20150211100407.GB5572@noname.str.redhat.com> References: <1423586055-4932-1-git-send-email-armbru@redhat.com> <1423586055-4932-2-git-send-email-armbru@redhat.com> <54DA3DD7.4050308@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="x+6KMIRAuhnl3hBn" Content-Disposition: inline In-Reply-To: <54DA3DD7.4050308@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/9] error: New convenience function error_report_err() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Markus Armbruster , qemu-devel@nongnu.org --x+6KMIRAuhnl3hBn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 10.02.2015 um 18:20 hat Eric Blake geschrieben: > On 02/10/2015 09:34 AM, Markus Armbruster wrote: > > I've typed error_report("%s", error_get_pretty(ERR)) too many times > > already, and I've fixed too many instances of qerror_report_err(ERR) > > to error_report("%s", error_get_pretty(ERR)) as well. Capture the > > pattern in a convenience function. > >=20 > > Since it's almost invariably followed by error_free(), stuff that into > > the convenience function as well. > >=20 >=20 > > @@ -2234,8 +2225,7 @@ static int sd_snapshot_create(BlockDriverState *b= s, QEMUSnapshotInfo *sn_info) > > =20 > > ret =3D do_sd_create(s, &new_vid, 1, &local_err); > > if (ret < 0) { > > - error_report("%s", error_get_pretty(local_err));; > > - error_free(local_err); > > + error_report_err(local_err); > > error_report("failed to create inode for snapshot. %s", > > strerror(errno)); >=20 > Pre-existing bug, so maybe worth a separate patch. This looks fishy: > are we guaranteed that errno is unchanged by error_report_err()? errno doesn't seem to contain anything meaningful here in the first place, so I think that line should simply be removed. > On the > surface, error_vreport() and friends do NOT try to preserve errno; maybe > your new function should guarantee that errno is not clobbered? (in > libvirt, we've explicitly made error-reporting convenience functions > document that they do not clobber errno, because it is much easier for > callers to report an error then return an errno value without having to > save errno locally) Isn't something going wrong if you report an error and pass it on at the same time? I always thought that the error reporting should be at the end of the error handling code. > > @@ -152,6 +152,12 @@ const char *error_get_pretty(Error *err) > > return err->msg; > > } > > =20 > > +void error_report_err(Error *err) > > +{ > > + error_report("%s", error_get_pretty(err)); > > + error_free(err); > > +} > > + >=20 > If it were me, I'd split this patch in two, one that introduces the new > function (with no clients), and the other which is a strict Coccinelle > touchup to use it, so that readers don't have to hunt for the meat of > the change. Yes, I thought the same. Kevin --x+6KMIRAuhnl3hBn Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJU2ykXAAoJEH8JsnLIjy/WLGsQAKTzO1abcBOLWGirse4gApS8 bpzlXZwuJN2xbENHy2372zpB8OKAs+BZOOzM3OFZH4PFcdIpNkpFLjWlf2IJcqhj upbbrDQeAjWWbHCJZ9Lr9XfzntNumuV0o/znxVO0JbW9IcPg+ldNbmxo8lQf1wO3 lFESQAJx2JGS9OLjoaDQ56YhrJIzQO1MH9FvOoefOi6i6tXi6GYtFVq55yjbavc/ WtqzVxo3dCAFLClHAOGwEq1Y6axeQKynS41qgovBgbVor/vaWquPYteQxDP6wS8j 1hwlihKGsDWprKJ8IQHn2+UnRF6qzf4t/KxH7OLg1IV/RUTydmeUvgZitIhd7c1q LdejhYiwVD51xUo5feT6CXw9SP/zvVQXN3aq0LuvD0CADpPMAQXkIPKdNznUqT5V wUcFkNu29WXqXaETwA+FyVg0aaQ/xPOsrdbNL9n1Qytkr9Xte1BmMTDN9gtWDQRu K0j14NqyXmCoC/R10o0htoBp1V71MQ/QZmAMkiDRGRiloaZUaiAfGSInaf5NWX1d ztujHvnorEBv8tN8GJl0sl5ZD2xKxv70cBvK2Dd3Po6W7GucBMUh9nZE+fgq1/eg NOFPeQGoiw5vKQmD8dgaNgGLx7Q/IalQOZfwSojWvjPq1Nh9V0EDSKs3Hz7+IErE WsNMVPsDqNtm0f+WTQxm =62Wv -----END PGP SIGNATURE----- --x+6KMIRAuhnl3hBn--