[Qemu-devel] [PATCH v6 26/29] fw_cfg-test: Drop dependence on global_qtest

Eric Blake posted 29 patches 8 years, 1 month ago
There is a newer version of this series
[Qemu-devel] [PATCH v6 26/29] fw_cfg-test: Drop dependence on global_qtest
Posted by Eric Blake 8 years, 1 month ago
As a general rule, we prefer avoiding implicit global state
because it makes code harder to safely copy and paste without
thinking about the global state.  It turns out that with the
recent changes to libqos, fw_cfg-test was not even using
global_qtest any more.  Avoid a pointless strdup while at it.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/fw_cfg-test.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index 47596c57a1..3a8dc7a2cd 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -102,14 +102,11 @@ static void test_fw_cfg_boot_menu(void)
 int main(int argc, char **argv)
 {
     QTestState *s;
-    char *cmdline;
     int ret;

     g_test_init(&argc, &argv, NULL);

-    cmdline = g_strdup_printf("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8 ");
-    s = qtest_start(cmdline);
-    g_free(cmdline);
+    s = qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8");

     fw_cfg = pc_fw_cfg_init(s);

-- 
2.13.5


Re: [Qemu-devel] [PATCH v6 26/29] fw_cfg-test: Drop dependence on global_qtest
Posted by Philippe Mathieu-Daudé 8 years, 1 month ago
On 09/01/2017 03:03 PM, Eric Blake wrote:
> As a general rule, we prefer avoiding implicit global state
> because it makes code harder to safely copy and paste without
> thinking about the global state.  It turns out that with the
> recent changes to libqos, fw_cfg-test was not even using
> global_qtest any more.  Avoid a pointless strdup while at it.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   tests/fw_cfg-test.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
> index 47596c57a1..3a8dc7a2cd 100644
> --- a/tests/fw_cfg-test.c
> +++ b/tests/fw_cfg-test.c
> @@ -102,14 +102,11 @@ static void test_fw_cfg_boot_menu(void)
>   int main(int argc, char **argv)
>   {
>       QTestState *s;
> -    char *cmdline;
>       int ret;
> 
>       g_test_init(&argc, &argv, NULL);
> 
> -    cmdline = g_strdup_printf("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8 ");
> -    s = qtest_start(cmdline);
> -    g_free(cmdline);
> +    s = qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8");
> 
>       fw_cfg = pc_fw_cfg_init(s);
> 

Re: [Qemu-devel] [PATCH v6 26/29] fw_cfg-test: Drop dependence on global_qtest
Posted by Thomas Huth 8 years, 1 month ago
On 01.09.2017 20:03, Eric Blake wrote:
> As a general rule, we prefer avoiding implicit global state
> because it makes code harder to safely copy and paste without
> thinking about the global state.  It turns out that with the
> recent changes to libqos, fw_cfg-test was not even using
> global_qtest any more.  Avoid a pointless strdup while at it.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  tests/fw_cfg-test.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
> index 47596c57a1..3a8dc7a2cd 100644
> --- a/tests/fw_cfg-test.c
> +++ b/tests/fw_cfg-test.c
> @@ -102,14 +102,11 @@ static void test_fw_cfg_boot_menu(void)
>  int main(int argc, char **argv)
>  {
>      QTestState *s;
> -    char *cmdline;
>      int ret;
> 
>      g_test_init(&argc, &argv, NULL);
> 
> -    cmdline = g_strdup_printf("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8 ");
> -    s = qtest_start(cmdline);
> -    g_free(cmdline);
> +    s = qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8");
> 
>      fw_cfg = pc_fw_cfg_init(s);
> 

Why don't you merge this with patch 14/29?

 Thomas

Re: [Qemu-devel] [PATCH v6 26/29] fw_cfg-test: Drop dependence on global_qtest
Posted by Eric Blake 8 years ago
On 09/05/2017 06:05 AM, Thomas Huth wrote:
> On 01.09.2017 20:03, Eric Blake wrote:
>> As a general rule, we prefer avoiding implicit global state
>> because it makes code harder to safely copy and paste without
>> thinking about the global state.  It turns out that with the
>> recent changes to libqos, fw_cfg-test was not even using
>> global_qtest any more.  Avoid a pointless strdup while at it.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>>  tests/fw_cfg-test.c | 5 +----
>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>

>>
> 
> Why don't you merge this with patch 14/29?

Sure.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org