From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhomL-0002jS-U3 for qemu-devel@nongnu.org; Wed, 07 Sep 2016 22:09:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhomG-00053B-Jn for qemu-devel@nongnu.org; Wed, 07 Sep 2016 22:09:24 -0400 Date: Thu, 8 Sep 2016 11:56:52 +1000 From: David Gibson Message-ID: <20160908015652.GC3883@voom.fritz.box> References: <1473167877-2545-1-git-send-email-lvivier@redhat.com> <1473167877-2545-2-git-send-email-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Qbvjkv9qwOGw/5Fx" Content-Disposition: inline In-Reply-To: <1473167877-2545-2-git-send-email-lvivier@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 1/3] qtest: replace strtoXX() by qemu_strtoXX() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier Cc: thuth@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org --Qbvjkv9qwOGw/5Fx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 06, 2016 at 03:17:55PM +0200, Laurent Vivier wrote: > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > v4: > - add this patch in the series to change all strtoXX() in qtest.c >=20 > qtest.c | 49 ++++++++++++++++++++++++++----------------------- > 1 file changed, 26 insertions(+), 23 deletions(-) >=20 > diff --git a/qtest.c b/qtest.c > index da4826c..4c94708 100644 > --- a/qtest.c > +++ b/qtest.c > @@ -27,6 +27,7 @@ > #include "qemu/config-file.h" > #include "qemu/option.h" > #include "qemu/error-report.h" > +#include "qemu/cutils.h" > =20 > #define MAX_IRQ 256 > =20 > @@ -324,12 +325,13 @@ static void qtest_process_command(CharDriverState *= chr, gchar **words) > } else if (strcmp(words[0], "outb") =3D=3D 0 || > strcmp(words[0], "outw") =3D=3D 0 || > strcmp(words[0], "outl") =3D=3D 0) { > - uint16_t addr; > - uint32_t value; > + unsigned long addr; > + unsigned long value; > =20 > g_assert(words[1] && words[2]); > - addr =3D strtoul(words[1], NULL, 0); > - value =3D strtoul(words[2], NULL, 0); > + g_assert(qemu_strtoul(words[1], NULL, 0, &addr) =3D=3D 0); > + g_assert(qemu_strtoul(words[2], NULL, 0, &value) =3D=3D 0); > + g_assert(addr <=3D 0xffff); > =20 > if (words[0][3] =3D=3D 'b') { > cpu_outb(addr, value); > @@ -343,11 +345,12 @@ static void qtest_process_command(CharDriverState *= chr, gchar **words) > } else if (strcmp(words[0], "inb") =3D=3D 0 || > strcmp(words[0], "inw") =3D=3D 0 || > strcmp(words[0], "inl") =3D=3D 0) { > - uint16_t addr; > + unsigned long addr; > uint32_t value =3D -1U; > =20 > g_assert(words[1]); > - addr =3D strtoul(words[1], NULL, 0); > + g_assert(qemu_strtoul(words[1], NULL, 0, &addr) =3D=3D 0); > + g_assert(addr <=3D 0xffff); > =20 > if (words[0][2] =3D=3D 'b') { > value =3D cpu_inb(addr); > @@ -366,8 +369,8 @@ static void qtest_process_command(CharDriverState *ch= r, gchar **words) > uint64_t value; > =20 > g_assert(words[1] && words[2]); > - addr =3D strtoull(words[1], NULL, 0); > - value =3D strtoull(words[2], NULL, 0); > + g_assert(qemu_strtoull(words[1], NULL, 0, &addr) =3D=3D 0); > + g_assert(qemu_strtoull(words[2], NULL, 0, &value) =3D=3D 0); > =20 > if (words[0][5] =3D=3D 'b') { > uint8_t data =3D value; > @@ -395,7 +398,7 @@ static void qtest_process_command(CharDriverState *ch= r, gchar **words) > uint64_t value =3D UINT64_C(-1); > =20 > g_assert(words[1]); > - addr =3D strtoull(words[1], NULL, 0); > + g_assert(qemu_strtoull(words[1], NULL, 0, &addr) =3D=3D 0); > =20 > if (words[0][4] =3D=3D 'b') { > uint8_t data; > @@ -421,8 +424,8 @@ static void qtest_process_command(CharDriverState *ch= r, gchar **words) > char *enc; > =20 > g_assert(words[1] && words[2]); > - addr =3D strtoull(words[1], NULL, 0); > - len =3D strtoull(words[2], NULL, 0); > + g_assert(qemu_strtoull(words[1], NULL, 0, &addr) =3D=3D 0); > + g_assert(qemu_strtoull(words[2], NULL, 0, &len) =3D=3D 0); > =20 > data =3D g_malloc(len); > cpu_physical_memory_read(addr, data, len); > @@ -443,8 +446,8 @@ static void qtest_process_command(CharDriverState *ch= r, gchar **words) > gchar *b64_data; > =20 > g_assert(words[1] && words[2]); > - addr =3D strtoull(words[1], NULL, 0); > - len =3D strtoull(words[2], NULL, 0); > + g_assert(qemu_strtoull(words[1], NULL, 0, &addr) =3D=3D 0); > + g_assert(qemu_strtoull(words[2], NULL, 0, &len) =3D=3D 0); > =20 > data =3D g_malloc(len); > cpu_physical_memory_read(addr, data, len); > @@ -460,8 +463,8 @@ static void qtest_process_command(CharDriverState *ch= r, gchar **words) > size_t data_len; > =20 > g_assert(words[1] && words[2] && words[3]); > - addr =3D strtoull(words[1], NULL, 0); > - len =3D strtoull(words[2], NULL, 0); > + g_assert(qemu_strtoull(words[1], NULL, 0, &addr) =3D=3D 0); > + g_assert(qemu_strtoull(words[2], NULL, 0, &len) =3D=3D 0); > =20 > data_len =3D strlen(words[3]); > if (data_len < 3) { > @@ -486,12 +489,12 @@ static void qtest_process_command(CharDriverState *= chr, gchar **words) > } else if (strcmp(words[0], "memset") =3D=3D 0) { > uint64_t addr, len; > uint8_t *data; > - uint8_t pattern; > + unsigned long pattern; > =20 > g_assert(words[1] && words[2] && words[3]); > - addr =3D strtoull(words[1], NULL, 0); > - len =3D strtoull(words[2], NULL, 0); > - pattern =3D strtoull(words[3], NULL, 0); > + g_assert(qemu_strtoull(words[1], NULL, 0, &addr) =3D=3D 0); > + g_assert(qemu_strtoull(words[2], NULL, 0, &len) =3D=3D 0); > + g_assert(qemu_strtoul(words[3], NULL, 0, &pattern) =3D=3D 0); > =20 > data =3D g_malloc(len); > memset(data, pattern, len); > @@ -507,8 +510,8 @@ static void qtest_process_command(CharDriverState *ch= r, gchar **words) > gsize out_len; > =20 > g_assert(words[1] && words[2] && words[3]); > - addr =3D strtoull(words[1], NULL, 0); > - len =3D strtoull(words[2], NULL, 0); > + g_assert(qemu_strtoull(words[1], NULL, 0, &addr) =3D=3D 0); > + g_assert(qemu_strtoull(words[2], NULL, 0, &len) =3D=3D 0); > =20 > data_len =3D strlen(words[3]); > if (data_len < 3) { > @@ -532,7 +535,7 @@ static void qtest_process_command(CharDriverState *ch= r, gchar **words) > int64_t ns; > =20 > if (words[1]) { > - ns =3D strtoll(words[1], NULL, 0); > + g_assert(qemu_strtoll(words[1], NULL, 0, &ns) =3D=3D 0); > } else { > ns =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); > } > @@ -544,7 +547,7 @@ static void qtest_process_command(CharDriverState *ch= r, gchar **words) > int64_t ns; > =20 > g_assert(words[1]); > - ns =3D strtoll(words[1], NULL, 0); > + g_assert(qemu_strtoll(words[1], NULL, 0, &ns) =3D=3D 0); > qtest_clock_warp(ns); > qtest_send_prefix(chr); > qtest_sendf(chr, "OK %"PRIi64"\n", --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --Qbvjkv9qwOGw/5Fx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJX0MVkAAoJEGw4ysog2bOSxwsP/joIyC8XK90nyNgOvM93QL44 WG8d4smsW5oWiFa6B7gSQvpXlH11bmoHJ0g2R6KZZcaXNn6jFBPALvxPWyXYBHvD UMYDGV5/58QjdARc9Wz78Xh35j8KTqaD1BrJhi+rJJPssc02ZqUWWH8ypFvRQmft kZQuwr4CISK194QjV7ozbuFhIm/2ArdydLXfhHFu0WSZDDSndpZfqbqaFZ96MboS 8VlNWO6RCcJP//V8O4PDHeRrDGck9XsdSpdBip4c03qJoqgeuBpbJqZsvhsN28wg 17T3fiFA7edRWSXkMvGo4dzKUld4IItTTDPvqHeVCBviYqDJU6FjVxHKEfoz4joh QmDyp+Tp/DpTAYq/PgDx2aIMXDqP3XMXqkwoy1Gm8rewSF9i2+s/Fxxeh0oohFPb gYc7PaVqcGqnvKudw620nQzZ0mzJk8/SavIKAdo6c0r1pNHTBSezwlyfqeHsRraI PiYt6pNCf7cCIaZzphE7gWMr5hCiZ9CEPPrk8Y7ZgSt/hPhTvfKwzegHZ5oFftli mgXc3dccfopB9WXB+Wp07ZGn/dMRYGG1/cXdD4M6e0ZzZaP4J7VEeSB1Ny4ZcSch HYv4Y0oql0P28pSP2EHyYAEUKuCAfQTfI9LC8H46aPtllmb439X4dJb4+lQQh6k1 pEPkGEXH5J5kojGvjWbs =hWpL -----END PGP SIGNATURE----- --Qbvjkv9qwOGw/5Fx--