Received: from eggs.gnu.org ([2001:4830:134:3::10]:45413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btzRw-0002R7-W5 for qemu-devel@nongnu.org; Tue, 11 Oct 2016 11:58:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btzRt-0003ix-O1 for qemu-devel@nongnu.org; Tue, 11 Oct 2016 11:58:41 -0400 References: <1476199177-32411-1-git-send-email-thuth@redhat.com> <1476199177-32411-2-git-send-email-thuth@redhat.com> From: Eric Blake Message-ID: Date: Tue, 11 Oct 2016 10:58:33 -0500 MIME-Version: 1.0 In-Reply-To: <1476199177-32411-2-git-send-email-thuth@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qX57qGuqITp33mmxGgI6OoV1JIo6siMTS" Subject: Re: [Qemu-devel] [PATCH 1/3] tests/boot-sector: Use minimum length for the Forth boot script List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth , qemu-devel@nongnu.org, Peter Maydell , Paolo Bonzini Cc: Victor Kaplansky , Michael Tsirkin , qemu-trivial@nongnu.org, qemu-ppc@nongnu.org, Sascha Silbe , David Gibson This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --qX57qGuqITp33mmxGgI6OoV1JIo6siMTS From: Eric Blake To: Thomas Huth , qemu-devel@nongnu.org, Peter Maydell , Paolo Bonzini Cc: Victor Kaplansky , Michael Tsirkin , qemu-trivial@nongnu.org, qemu-ppc@nongnu.org, Sascha Silbe , David Gibson Message-ID: Subject: Re: [Qemu-devel] [PATCH 1/3] tests/boot-sector: Use minimum length for the Forth boot script References: <1476199177-32411-1-git-send-email-thuth@redhat.com> <1476199177-32411-2-git-send-email-thuth@redhat.com> In-Reply-To: <1476199177-32411-2-git-send-email-thuth@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/11/2016 10:19 AM, Thomas Huth wrote: > The pxe-test is quite slow on ppc64 with tcg. We can speed it up > a little bit by decreasing the size of the file that has to be > loaded via TFTP. >=20 > Signed-off-by: Thomas Huth > --- > tests/boot-sector.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/tests/boot-sector.c b/tests/boot-sector.c > index e3193c0..0168fd0 100644 > --- a/tests/boot-sector.c > +++ b/tests/boot-sector.c > @@ -72,6 +72,7 @@ static uint8_t boot_sector[0x7e000] =3D { The size of 0x7e000... > int boot_sector_init(const char *fname) > { > FILE *f =3D fopen(fname, "w"); > + size_t len =3D sizeof boot_sector; > =20 > if (!f) { > fprintf(stderr, "Couldn't open \"%s\": %s", fname, strerror(er= rno)); > @@ -80,13 +81,12 @@ int boot_sector_init(const char *fname) > =20 > /* For Open Firmware based system, we can use a Forth script inste= ad */ > if (strcmp(qtest_get_arch(), "ppc64") =3D=3D 0) { > - memset(boot_sector, ' ', sizeof boot_sector); > - sprintf((char *)boot_sector, "\\ Bootscript\n%x %x c! %x %x c!= \n", > + len =3D sprintf((char *)boot_sector, "\\ Bootscript\n%x %x c! = %x %x c!\n", =2E..is enough to ensure the sprintf() doesn't overflow. Still, I think an snprintf() would be a bit nicer on maintainers to not have to worry about whether overflow is even possible. > LOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET= , > HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSE= T + 1); Worth reindenting this to match the line above? > } > =20 > - fwrite(boot_sector, 1, sizeof boot_sector, f); > + fwrite(boot_sector, 1, len, f); At any rate, the change makes sense, and I can't find anything technically wrong with it, so feel free to add: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --qX57qGuqITp33mmxGgI6OoV1JIo6siMTS 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/ iQEcBAEBCAAGBQJX/QwpAAoJEKeha0olJ0NqyM8H/3ndZ6V9rSmkUkr/58XnNZ4E AIOXw942IQ1yySW4mdpanqIbEkom2b3CzeVdTcdMZjzQfPvfPL7CUzRK8OlJOiaX /Fm+f+BXCE/4LOtweUN3LuZqWBm8+cBwGSyjoAf0Pb6kzYZsrBCEPgKg61l9qKpU qxHzmG3fbg1ayah7IOlJuqs/QKFt73RCxTy4/AQx9Mi3C5tj6q/rdfG7j2g3elI1 NyBa65w6CONRildZRDBbXF1Gy/nlgTHblBeU2wvGQpPjqAJDrvSK3e6s0LzkqESG QvkmzlewfIoM811gHEQcW8sBNl04RJ+YaiOR26lcqqVv9d+pO86B92Wlgl2SMl0= =fdRg -----END PGP SIGNATURE----- --qX57qGuqITp33mmxGgI6OoV1JIo6siMTS--