From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGqYG-00038P-CF for qemu-devel@nongnu.org; Wed, 06 Jan 2016 11:03:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aGqYD-0002hW-2M for qemu-devel@nongnu.org; Wed, 06 Jan 2016 11:03:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44707) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGqYC-0002hP-QS for qemu-devel@nongnu.org; Wed, 06 Jan 2016 11:03:04 -0500 References: <1452047951-17429-1-git-send-email-caoj.fnst@cn.fujitsu.com> <1452047951-17429-4-git-send-email-caoj.fnst@cn.fujitsu.com> From: Eric Blake Message-ID: <568D3AB2.8020100@redhat.com> Date: Wed, 6 Jan 2016 09:02:58 -0700 MIME-Version: 1.0 In-Reply-To: <1452047951-17429-4-git-send-email-caoj.fnst@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pLFuBejc25ku39XfVFXqdcc0QQnGF0bIF" Subject: Re: [Qemu-devel] [PATCH v3 3/4] Add Error **errp for xen_pt_config_init() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cao jin , qemu-devel@nongnu.org Cc: stefano.stabellini@eu.citrix.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pLFuBejc25ku39XfVFXqdcc0QQnGF0bIF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/05/2016 07:39 PM, Cao jin wrote: > To catch the error msg. Also modify the caller >=20 > Signed-off-by: Cao jin > --- > hw/xen/xen_pt.c | 7 ++++--- > hw/xen/xen_pt.h | 2 +- > hw/xen/xen_pt_config_init.c | 51 ++++++++++++++++++++++++-------------= -------- > 3 files changed, 32 insertions(+), 28 deletions(-) >=20 > +++ b/hw/xen/xen_pt_config_init.c > @@ -1899,8 +1899,9 @@ static uint8_t find_cap_offset(XenPCIPassthroughS= tate *s, uint8_t cap) > return 0; > } > =20 > -static int xen_pt_config_reg_init(XenPCIPassthroughState *s, > - XenPTRegGroup *reg_grp, XenPTRegInfo= *reg) > +static void xen_pt_config_reg_init(XenPCIPassthroughState *s, > + XenPTRegGroup *reg_grp, XenPTRegInfo= *reg, > + Error **errp) Indentation is now off. > @@ -1967,10 +1970,10 @@ static int xen_pt_config_reg_init(XenPCIPassthr= oughState *s, > val =3D data; > =20 > if (val & ~size_mask) { > - XEN_PT_ERR(&s->dev,"Offset 0x%04x:0x%04x expands past regi= ster size(%d)!\n", > - offset, val, reg->size); > + error_setg(errp, "Offset 0x%04x:0x%04x expands past" > + " register size(%d)!", offset, val, reg->size); Drop the trailing !. Also, while touching this, it's better to have a space before ( in English. > +void xen_pt_config_init(XenPCIPassthroughState *s, Error **errp) > { > int i, rc; > + Error *local_err =3D NULL; Same comments as earlier in the series about using the shorter 'err' instead of 'local_err'. > =20 > QLIST_INIT(&s->reg_grps); > =20 > @@ -2039,11 +2041,12 @@ int xen_pt_config_init(XenPCIPassthroughState *= s) > reg_grp_offset, > ®_grp_entry->size= ); > if (rc < 0) { > - XEN_PT_LOG(&s->dev, "Failed to initialize %d/%ld, type= =3D0x%x, rc:%d\n", > - i, ARRAY_SIZE(xen_pt_emu_reg_grps), > + error_setg(&local_err, "Failed to initialize %d/%ld, t= ype=3D0x%x," > + " rc:%d", i, ARRAY_SIZE(xen_pt_emu_reg_grps= ), This maps ARRAY_SIZE() (which is size_t) to %ld, which can fail to compile on 32-bit platforms (where size_t is not necessarily long). Fix it to %zd while touching it. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --pLFuBejc25ku39XfVFXqdcc0QQnGF0bIF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWjTqyAAoJEKeha0olJ0Nq058IAKBQrxn+OHdXPQWsPFoZiP7g HFR01xuMIzDirxQXW8g06zZuTYd64GKa40bDtM02h6i5JDqnoZHsi5HD8WqmZ4kx rP/RyDikLPNsEop2xhd9XHnaT+L0XIsldSNVUOZv7VQJWx96DqKeCt2pm2cK0imZ 3w80dUQB4T6ykL9NaLuwCPdbsk+jqDiv5ANN6vmUD7LKY9zaYvcPSKHz1feeB+uD MZgYE7MNeCJAzjgyPNC2vQt1Wo0x2fdqZLZjt3D6j3Fj7RzjQMrYgFj3finZ1W5G NPDvy80kliTvxPaprfOILa/9ckoE+ei8sA5Nnd00qx1XXMnTi5KikKkqp/IRXzs= =ZIyr -----END PGP SIGNATURE----- --pLFuBejc25ku39XfVFXqdcc0QQnGF0bIF--