qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v5 07/13] libqtest: Inline qtest_query_target_en


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH v5 07/13] libqtest: Inline qtest_query_target_endianness()
Date: Fri, 18 Aug 2017 18:46:26 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 08/18/2017 06:15 PM, Eric Blake wrote:
There was only one caller; it's easier to inline things.

What's the benefit of this change? Having a separate function ease code reading. You might add the 'inline' qualifier but the compiler is smart enough to inline it.

Instead of this change I'd inline it and remove the return value, having a void function initializing s->big_endian. Matter of taste I think :)


Signed-off-by: Eric Blake <address@hidden>
---
  tests/libqtest.c | 22 ++++++----------------
  1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index 5d16351e24..b6dd26e54a 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -244,20 +244,6 @@ redo:
      return words;
  }

-static int qtest_query_target_endianness(QTestState *s)
-{
-    gchar **args;
-    int big_endian;
-
-    qtest_sendf(s, "endianness\n");
-    args = qtest_rsp(s, 1);
-    g_assert(strcmp(args[1], "big") == 0 || strcmp(args[1], "little") == 0);
-    big_endian = strcmp(args[1], "big") == 0;
-    g_strfreev(args);
-
-    return big_endian;
-}
-
  static void cleanup_sigabrt_handler(void)
  {
      sigaction(SIGABRT, &sigact_old, NULL);
@@ -288,6 +274,7 @@ QTestState *qtest_init_without_qmp_handshake(const char 
*extra_args)
      gchar *qmp_socket_path;
      gchar *command;
      const char *qemu_binary;
+    gchar **args;

      qemu_binary = getenv("QTEST_QEMU_BINARY");
      if (!qemu_binary) {
@@ -351,8 +338,11 @@ QTestState *qtest_init_without_qmp_handshake(const char 
*extra_args)
      }

      /* ask endianness of the target */
-
-    s->big_endian = qtest_query_target_endianness(s);
+    qtest_sendf(s, "endianness\n");
+    args = qtest_rsp(s, 1);
+    g_assert(strcmp(args[1], "big") == 0 || strcmp(args[1], "little") == 0);
+    s->big_endian = strcmp(args[1], "big") == 0;
+    g_strfreev(args);

      return s;
  }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]