qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 02/14] libqtest: Use qemu_strtoul()
Date: Thu,  8 Feb 2018 21:09:30 +0100	[thread overview]
Message-ID: <1518120582-26647-3-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1518120582-26647-1-git-send-email-thuth@redhat.com>

From: Eric Blake <eblake@redhat.com>

This will keep checkpatch happy when the next patch does code motion.
Fix the include order to match HACKING when adding the needed header.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/libqtest.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index 0ec8af2..5d90cdc 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -15,12 +15,13 @@
  *
  */
 #include "qemu/osdep.h"
-#include "libqtest.h"
 
 #include <sys/socket.h>
 #include <sys/wait.h>
 #include <sys/un.h>
 
+#include "libqtest.h"
+#include "qemu/cutils.h"
 #include "qapi/error.h"
 #include "qapi/qmp/json-parser.h"
 #include "qapi/qmp/json-streamer.h"
@@ -360,12 +361,14 @@ redo:
     g_string_free(line, TRUE);
 
     if (strcmp(words[0], "IRQ") == 0) {
-        int irq;
+        long irq;
+        int ret;
 
         g_assert(words[1] != NULL);
         g_assert(words[2] != NULL);
 
-        irq = strtoul(words[2], NULL, 0);
+        ret = qemu_strtol(words[2], NULL, 0, &irq);
+        g_assert(!ret);
         g_assert_cmpint(irq, >=, 0);
         g_assert_cmpint(irq, <, MAX_IRQ);
 
@@ -727,11 +730,13 @@ void qtest_outl(QTestState *s, uint16_t addr, uint32_t value)
 static uint32_t qtest_in(QTestState *s, const char *cmd, uint16_t addr)
 {
     gchar **args;
-    uint32_t value;
+    int ret;
+    unsigned long value;
 
     qtest_sendf(s, "%s 0x%x\n", cmd, addr);
     args = qtest_rsp(s, 2);
-    value = strtoul(args[1], NULL, 0);
+    ret = qemu_strtoul(args[1], NULL, 0, &value);
+    g_assert(!ret && value <= UINT32_MAX);
     g_strfreev(args);
 
     return value;
@@ -782,11 +787,13 @@ void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value)
 static uint64_t qtest_read(QTestState *s, const char *cmd, uint64_t addr)
 {
     gchar **args;
+    int ret;
     uint64_t value;
 
     qtest_sendf(s, "%s 0x%" PRIx64 "\n", cmd, addr);
     args = qtest_rsp(s, 2);
-    value = strtoull(args[1], NULL, 0);
+    ret = qemu_strtou64(args[1], NULL, 0, &value);
+    g_assert(!ret);
     g_strfreev(args);
 
     return value;
-- 
1.8.3.1

  parent reply	other threads:[~2018-02-08 20:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-08 20:09 [Qemu-devel] [PATCH 00/14] qtest patches Thomas Huth
2018-02-08 20:09 ` [Qemu-devel] [PATCH 01/14] tests: Clean up wait for event Thomas Huth
2018-02-08 20:09 ` Thomas Huth [this message]
2018-02-08 20:09 ` [Qemu-devel] [PATCH 03/14] libqos: Track QTestState with QPCIBus Thomas Huth
2018-02-08 20:09 ` [Qemu-devel] [PATCH 04/14] libqos: Use explicit QTestState for fw_cfg operations Thomas Huth
2018-02-08 20:09 ` [Qemu-devel] [PATCH 05/14] libqos: Use explicit QTestState for rtas operations Thomas Huth
2018-02-08 20:09 ` [Qemu-devel] [PATCH 06/14] libqos: Use explicit QTestState for i2c operations Thomas Huth
2018-02-08 20:09 ` [Qemu-devel] [PATCH 07/14] libqos: Use explicit QTestState for ahci operations Thomas Huth
2018-02-08 20:09 ` [Qemu-devel] [PATCH 08/14] libqos: Use explicit QTestState for remaining libqos operations Thomas Huth
2018-02-08 20:09 ` [Qemu-devel] [PATCH 09/14] qmp-test: Drop dependence on global_qtest Thomas Huth
2018-02-08 20:09 ` [Qemu-devel] [PATCH 10/14] tests/boot-sector: " Thomas Huth
2018-02-08 20:09 ` [Qemu-devel] [PATCH 11/14] wdt_ib700-test: " Thomas Huth
2018-02-08 20:09 ` [Qemu-devel] [PATCH 12/14] tests/boot-serial: Enable the boot-serial test on SPARC machines, too Thomas Huth
2018-02-08 22:40   ` Eric Blake
2018-02-08 20:09 ` [Qemu-devel] [PATCH 13/14] tests/boot-serial: Add tests for PowerPC Mac machines Thomas Huth
2018-02-08 22:41   ` Eric Blake
2018-02-08 20:09 ` [Qemu-devel] [PATCH 14/14] tests/boot-serial-test: Add support for the aarch64 virt machine Thomas Huth
2018-02-08 22:44   ` Eric Blake
2018-02-08 22:46 ` [Qemu-devel] [PATCH 00/14] qtest patches Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1518120582-26647-3-git-send-email-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).