From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJqOl-0005Fx-0G for qemu-devel@nongnu.org; Thu, 14 Jan 2016 17:29:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJqOg-0008HG-Nc for qemu-devel@nongnu.org; Thu, 14 Jan 2016 17:29:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51326) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJqOg-0008H6-FY for qemu-devel@nongnu.org; Thu, 14 Jan 2016 17:29:38 -0500 References: <1452689507-8188-1-git-send-email-caoj.fnst@cn.fujitsu.com> <1452689507-8188-3-git-send-email-caoj.fnst@cn.fujitsu.com> From: Eric Blake Message-ID: <5698214D.1080503@redhat.com> Date: Thu, 14 Jan 2016 15:29:33 -0700 MIME-Version: 1.0 In-Reply-To: <1452689507-8188-3-git-send-email-caoj.fnst@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="SM7k7D7q8bqjJSXo5j4SvJMjgm6VXis1B" Subject: Re: [Qemu-devel] [PATCH v5 2/5] Add Error **errp for xen_host_pci_device_get() 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) --SM7k7D7q8bqjJSXo5j4SvJMjgm6VXis1B Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/13/2016 05:51 AM, Cao jin wrote: > To catch the error msg. Also modify the caller >=20 > Signed-off-by: Cao jin > --- > hw/xen/xen-host-pci-device.c | 142 +++++++++++++++++++++--------------= -------- > hw/xen/xen-host-pci-device.h | 5 +- > hw/xen/xen_pt.c | 13 ++-- > 3 files changed, 80 insertions(+), 80 deletions(-) >=20 > diff --git a/hw/xen/xen-host-pci-device.c b/hw/xen/xen-host-pci-device.= c > index 351b61a..3e22de8 100644 > --- a/hw/xen/xen-host-pci-device.c > +++ b/hw/xen/xen-host-pci-device.c > @@ -31,25 +31,20 @@ > #define IORESOURCE_PREFETCH 0x00001000 /* No side effects */ > #define IORESOURCE_MEM_64 0x00100000 > =20 > -static int xen_host_pci_sysfs_path(const XenHostPCIDevice *d, > - const char *name, char *buf, ssize_= t size) > +static void xen_host_pci_sysfs_path(const XenHostPCIDevice *d, > + const char *name, char *buf, ssize= _t size) Changing xen_host_pci_sysfs_path() to return void, by assert()ing on caller error, is not mentioned in the commit message; and if I were doing the series, I probably would have done it as a separate commit. > /* This size should be enough to read a long from a file */ > #define XEN_HOST_PCI_GET_VALUE_BUFFER_SIZE 22 > -static int xen_host_pci_get_value(XenHostPCIDevice *d, const char *nam= e, > - unsigned int *pvalue, int base) > +static void xen_host_pci_get_value(XenHostPCIDevice *d, const char *na= me, > + unsigned int *pvalue, int base, Err= or **errp) > { > buf[rc] =3D 0; > - rc =3D qemu_strtoul(buf, &endptr, base, &value); > - if (!rc) { > - *pvalue =3D value; > + rc =3D qemu_strtoul(buf, &endptr, base, (unsigned long *)pvalue); Ouch. Casting unsigned int * to unsigned long * and then dereferencing it is bogus (you end up having qemu_strtoul() write beyond bounds on platforms where long is larger than int). You'll need to revert this part of the patch, and stick with *pvalue =3D value (and possibly even ad= d a bounds check that value <=3D UINT_MAX). Otherwise looks okay. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --SM7k7D7q8bqjJSXo5j4SvJMjgm6VXis1B 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/ iQEcBAEBCAAGBQJWmCFNAAoJEKeha0olJ0NqguIH/R1xSDCQlvfYylO2qFYRYTJU IfwJl/Fcezy30THmSwzKULlarIi+I0AkxBh6VicRYz55KPW+T7awLTFwtglFpClc QEDHwBWrdFM6GWtAkYYw14wVjuuOnD0LGr0R/XXcGOWZek0iACYdw0L7sXcJFdeg x/5yTmn+ftGQAussHfCTt5V1U5zAKeod5jX2w6UuplujtiFR0VhyVhESM05Uvzss 50FAWSKv3VnfeJ7uVWrNTBNNKIXZsUQGWvgpkTiEFVP93bVG5nxL5HvEYRgVTk7l QI7m35slMgrJSktMDl1KccATF5mA2qFjCcYaE7h25oEdSMu56zERPkH+LpDnrEc= =V4tM -----END PGP SIGNATURE----- --SM7k7D7q8bqjJSXo5j4SvJMjgm6VXis1B--