Message ID | 20170901180340.30009-12-eblake@redhat.com |
---|---|
State | New |
Headers | show |
Series | Preliminary libqtest cleanups | expand |
On 09/01/2017 03:03 PM, Eric Blake wrote: > There was only one caller; it's easier to inline things. > > Signed-off-by: Eric Blake <eblake@redhat.com> Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > 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; > } >
On 01.09.2017 20:03, Eric Blake wrote: > There was only one caller; it's easier to inline things. > > Signed-off-by: Eric Blake <eblake@redhat.com> > --- > 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; > } Ah, well, now that's another way of getting rid of the forward declaration in the previous patch - so may I suggest to drop the previous patch, and simply do the code inlining here instead? Thomas
On 09/05/2017 04:25 AM, Thomas Huth wrote: > On 01.09.2017 20:03, Eric Blake wrote: >> There was only one caller; it's easier to inline things. >> >> Signed-off-by: Eric Blake <eblake@redhat.com> >> --- >> tests/libqtest.c | 22 ++++++---------------- >> 1 file changed, 6 insertions(+), 16 deletions(-) >> > > Ah, well, now that's another way of getting rid of the forward > declaration in the previous patch - so may I suggest to drop the > previous patch, and simply do the code inlining here instead? Will do.
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; }
There was only one caller; it's easier to inline things. Signed-off-by: Eric Blake <eblake@redhat.com> --- tests/libqtest.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)