[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v7 07/38] libqtest: Inline qtest_query_target_en
From: |
Thomas Huth |
Subject: |
Re: [Qemu-devel] [PATCH v7 07/38] libqtest: Inline qtest_query_target_endianness() |
Date: |
Tue, 12 Sep 2017 08:32:42 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 11.09.2017 19:19, Eric Blake wrote:
> There was only one caller; it's easier to inline things. (It
> trades one forward declaration for two others, but it's not
> worth the additional churn of topological sorting, even though
> that would be possible.)
>
> Signed-off-by: Eric Blake <address@hidden>
>
> ---
> v7: Drop the topological sorting
> ---
> tests/libqtest.c | 26 +++++++++-----------------
> 1 file changed, 9 insertions(+), 17 deletions(-)
>
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index 95d4159b38..1710d63276 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -49,7 +49,9 @@ static struct sigaction sigact_old;
> g_assert_cmpint(ret, !=, -1); \
> } while (0)
>
> -static int qtest_query_target_endianness(QTestState *s);
> +static void qtest_sendf(QTestState *s, const char *fmt, ...)
> + GCC_FMT_ATTR(2, 3);
> +static gchar **qtest_rsp(QTestState *s, int expected_args);
>
> static int init_socket(const char *socket_path)
> {
> @@ -158,6 +160,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) {
> @@ -221,8 +224,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;
> }
> @@ -367,20 +373,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;
> -}
> -
> typedef struct {
> JSONMessageParser parser;
> QDict *response;
Looking at this patch again, I'm not sure anymore whether this is really
worth the effort. Keeping code that belongs together in a separate
function also makes sense ... Not sure, but I'd maybe rather drop this
patch. But in case you want to keep it:
Reviewed-by: Thomas Huth <address@hidden>
- [Qemu-devel] [PATCH v7 00/38] Preliminary libqtest cleanups, Eric Blake, 2017/09/11
- [Qemu-devel] [PATCH v7 02/38] qtest: Don't perform side effects inside assertion, Eric Blake, 2017/09/11
- [Qemu-devel] [PATCH v7 03/38] numa-test: Use hmp(), Eric Blake, 2017/09/11
- [Qemu-devel] [PATCH v7 05/38] libqtest: Remove dead qtest_instances variable, Eric Blake, 2017/09/11
- [Qemu-devel] [PATCH v7 01/38] test-qga: Kill broken and dead QGA_TEST_SIDE_EFFECTING code, Eric Blake, 2017/09/11
- [Qemu-devel] [PATCH v7 04/38] tests: Clean up wait for event, Eric Blake, 2017/09/11
- [Qemu-devel] [PATCH v7 06/38] libqtest: Use qemu_strtoul(), Eric Blake, 2017/09/11
- [Qemu-devel] [PATCH v7 07/38] libqtest: Inline qtest_query_target_endianness(), Eric Blake, 2017/09/11
- Re: [Qemu-devel] [PATCH v7 07/38] libqtest: Inline qtest_query_target_endianness(),
Thomas Huth <=
- [Qemu-devel] [PATCH v7 08/38] libqos: Track QTestState with QPCIBus, Eric Blake, 2017/09/11
- [Qemu-devel] [PATCH v7 09/38] libqos: Track QTestState with QVirtioBus, Eric Blake, 2017/09/11
- [Qemu-devel] [PATCH v7 10/38] libqos: Move/rename qpci_unplug_acpi_device_test() to pci.c, Eric Blake, 2017/09/11