From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFI8n-0005v0-3Q for qemu-devel@nongnu.org; Sat, 02 Jan 2016 04:06:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aFI8j-0002b8-TK for qemu-devel@nongnu.org; Sat, 02 Jan 2016 04:06:25 -0500 Received: from mail.weilnetz.de ([37.221.199.173]:42760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aFI8j-0002aK-KB for qemu-devel@nongnu.org; Sat, 02 Jan 2016 04:06:21 -0500 References: <1451721740-6151-1-git-send-email-caoj.fnst@cn.fujitsu.com> From: Stefan Weil Message-ID: <56879302.3050902@weilnetz.de> Date: Sat, 2 Jan 2016 10:06:10 +0100 MIME-Version: 1.0 In-Reply-To: <1451721740-6151-1-git-send-email-caoj.fnst@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="3Dwn4dU3e7WM7BGFqeIAvRRMnMRwo29aC" Subject: Re: [Qemu-devel] [PATCH v3] bugfix: passing reference instead of value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cao jin , qemu-devel@nongnu.org Cc: pbonzini@redhat.com, mst@redhat.com, stefano.stabellini@eu.citrix.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --3Dwn4dU3e7WM7BGFqeIAvRRMnMRwo29aC Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable Am 02.01.2016 um 09:02 schrieb Cao jin: > Fix the bug introduced by 595a4f07: function host_pci_config_read() sho= uld be > pass-by-reference, not value. > > Signed-off-by: Cao jin > --- > v3 changelog: > 1. Remove cpu_to_le32() since the code only runs on X86. > > hw/pci-host/piix.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c > index 715208b..924f0fa 100644 > --- a/hw/pci-host/piix.c > +++ b/hw/pci-host/piix.c > @@ -761,7 +761,7 @@ static const IGDHostInfo igd_host_bridge_infos[] =3D= { > {0xa8, 4}, /* SNB: base of GTT stolen memory */ > }; > =20 > -static int host_pci_config_read(int pos, int len, uint32_t val) > +static int host_pci_config_read(int pos, int len, uint32_t *val) > { > char path[PATH_MAX]; > int config_fd; > @@ -784,12 +784,14 @@ static int host_pci_config_read(int pos, int len,= uint32_t val) > ret =3D -errno; > goto out; > } > + > do { > - rc =3D read(config_fd, (uint8_t *)&val, len); > + rc =3D read(config_fd, (uint8_t *)val, len); The type cast is not needed here, because read accepts any pointer type for the buffer argument. While looking at that code, I noticed more potential issues: * The open statement needs O_RDWR | O_BINARY, otherwise the code won't work on Windows. * The len argument can obviously be 2 or 4. Will endianness handling work for both cases? Regards, Stefan --3Dwn4dU3e7WM7BGFqeIAvRRMnMRwo29aC 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 iQIcBAEBCAAGBQJWh5MJAAoJEOCMIdVndFCtBtwP/A+XzBCJdyboT29C/W6Fjs6D OsiUT7zowdbhlpcIp+xbxg58sHooISs7UWLXYtBRcM+E6hHFcVSuqwDPRjpoMRoh fA2PCj442LqZ7N//o/I0kesBGazyxlSydzA6wBouzgImV7V6gJMfQ7BLfEZB2rPH yj6nq49MBhbOXgJrTBBKYQVII47o32lpeqGKbLO3jriZxjd0kbofOLMcqMZB76Mp ShhVqCZSL7wY2w8872/zFe8nPK/ax9QezqTsU0eYHgd7P9agYVFvfYArThYW7nCy WbzXYz3t/y3B/jlxVWop6cjm2E3LPFy3rCjLZ7WjbCwrwVtwjHceKYClBkNPFvlP AOd0YTJglrvDxLQuOLbtt7Rog6M8dkkpvHySuHKfAzWmhxJIBTaJUdjnQW8BO1Fk lPl3/+WF6d1htBrUDdu4kQcgdfLtpUCajCLLY58XgHKfe+yvRr4DNhAnR5OKc4g/ PiUdHM9RFEix/1Y0irrV5Zk4pqfbMPbz+vNk5kWBYbRp9pxuhWLrh0JjtirlIKFc 6a4x7XoARyL0vCknGaWA5PckIZ790lmYFOfGPtLujNQMqpkYAeeh4qe8zoyWpaQl /8xklM1nnthydal+rN9TJ0yAU/vc0YJXsBB8FlBMpSCe4MeUtxPhhLib/Iwz5kM0 7JFReQlyy0Ih8AfjnOr4 =BfNi -----END PGP SIGNATURE----- --3Dwn4dU3e7WM7BGFqeIAvRRMnMRwo29aC--