All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tests/unit: simpler variable sequence for test-io-channel
@ 2022-11-03 10:23 Alex Bennée
  2022-11-03 10:27 ` Philippe Mathieu-Daudé
  2022-11-03 10:28 ` Laurent Vivier
  0 siblings, 2 replies; 5+ messages in thread
From: Alex Bennée @ 2022-11-03 10:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent, Alex Bennée, Daniel P. Berrangé

This avoids some compilers complaining about a potentially
un-initialised [src|dst]argv. In retrospect using GString was overkill
for what we are constructing.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/unit/test-io-channel-command.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/tests/unit/test-io-channel-command.c b/tests/unit/test-io-channel-command.c
index 43e29c8cfb..19f72eab96 100644
--- a/tests/unit/test-io-channel-command.c
+++ b/tests/unit/test-io-channel-command.c
@@ -33,19 +33,13 @@ static void test_io_channel_command_fifo(bool async)
 {
     g_autofree gchar *tmpdir = g_dir_make_tmp("qemu-test-io-channel.XXXXXX", NULL);
     g_autofree gchar *fifo = g_strdup_printf("%s/%s", tmpdir, TEST_FIFO);
-    g_autoptr(GString) srcargs = g_string_new(socat);
-    g_autoptr(GString) dstargs = g_string_new(socat);
-    g_auto(GStrv) srcargv;
-    g_auto(GStrv) dstargv;
+    g_autofree gchar *srcargs = g_strdup_printf("%s - PIPE:%s,wronly", socat, fifo);
+    g_autofree gchar *dstargs = g_strdup_printf("%s PIPE:%s,rdonly -", socat, fifo);
+    g_auto(GStrv) srcargv = g_strsplit(srcargs, " ", -1);
+    g_auto(GStrv) dstargv = g_strsplit(dstargs, " ", -1);
     QIOChannel *src, *dst;
     QIOChannelTest *test;
 
-    g_string_append_printf(srcargs, " - PIPE:%s,wronly", fifo);
-    g_string_append_printf(dstargs, " PIPE:%s,rdonly -", fifo);
-
-    srcargv = g_strsplit(srcargs->str, " ", -1);
-    dstargv = g_strsplit(dstargs->str, " ", -1);
-
     src = QIO_CHANNEL(qio_channel_command_new_spawn((const char **) srcargv,
                                                     O_WRONLY,
                                                     &error_abort));
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] tests/unit: simpler variable sequence for test-io-channel
  2022-11-03 10:23 [PATCH] tests/unit: simpler variable sequence for test-io-channel Alex Bennée
@ 2022-11-03 10:27 ` Philippe Mathieu-Daudé
  2022-11-03 10:28 ` Laurent Vivier
  1 sibling, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-03 10:27 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel
  Cc: laurent, Daniel P. Berrangé, Bernhard Beschow

On 3/11/22 11:23, Alex Bennée wrote:
> This avoids some compilers complaining about a potentially
> un-initialised [src|dst]argv. In retrospect using GString was overkill
> for what we are constructing.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   tests/unit/test-io-channel-command.c | 14 ++++----------
>   1 file changed, 4 insertions(+), 10 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tests/unit: simpler variable sequence for test-io-channel
  2022-11-03 10:23 [PATCH] tests/unit: simpler variable sequence for test-io-channel Alex Bennée
  2022-11-03 10:27 ` Philippe Mathieu-Daudé
@ 2022-11-03 10:28 ` Laurent Vivier
  2022-11-03 11:32   ` Alex Bennée
  1 sibling, 1 reply; 5+ messages in thread
From: Laurent Vivier @ 2022-11-03 10:28 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: Daniel P. Berrangé

Le 03/11/2022 à 11:23, Alex Bennée a écrit :
> This avoids some compilers complaining about a potentially
> un-initialised [src|dst]argv. In retrospect using GString was overkill
> for what we are constructing.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   tests/unit/test-io-channel-command.c | 14 ++++----------
>   1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/tests/unit/test-io-channel-command.c b/tests/unit/test-io-channel-command.c
> index 43e29c8cfb..19f72eab96 100644
> --- a/tests/unit/test-io-channel-command.c
> +++ b/tests/unit/test-io-channel-command.c
> @@ -33,19 +33,13 @@ static void test_io_channel_command_fifo(bool async)
>   {
>       g_autofree gchar *tmpdir = g_dir_make_tmp("qemu-test-io-channel.XXXXXX", NULL);
>       g_autofree gchar *fifo = g_strdup_printf("%s/%s", tmpdir, TEST_FIFO);
> -    g_autoptr(GString) srcargs = g_string_new(socat);
> -    g_autoptr(GString) dstargs = g_string_new(socat);
> -    g_auto(GStrv) srcargv;
> -    g_auto(GStrv) dstargv;
> +    g_autofree gchar *srcargs = g_strdup_printf("%s - PIPE:%s,wronly", socat, fifo);
> +    g_autofree gchar *dstargs = g_strdup_printf("%s PIPE:%s,rdonly -", socat, fifo);
> +    g_auto(GStrv) srcargv = g_strsplit(srcargs, " ", -1);
> +    g_auto(GStrv) dstargv = g_strsplit(dstargs, " ", -1);
>       QIOChannel *src, *dst;
>       QIOChannelTest *test;
>   
> -    g_string_append_printf(srcargs, " - PIPE:%s,wronly", fifo);
> -    g_string_append_printf(dstargs, " PIPE:%s,rdonly -", fifo);
> -
> -    srcargv = g_strsplit(srcargs->str, " ", -1);
> -    dstargv = g_strsplit(dstargs->str, " ", -1);
> -
>       src = QIO_CHANNEL(qio_channel_command_new_spawn((const char **) srcargv,
>                                                       O_WRONLY,
>                                                       &error_abort));

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

Do you want this be merged via trivial branch?

Thanks,
Laurent


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tests/unit: simpler variable sequence for test-io-channel
  2022-11-03 10:28 ` Laurent Vivier
@ 2022-11-03 11:32   ` Alex Bennée
  2022-11-03 16:03     ` Laurent Vivier
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Bennée @ 2022-11-03 11:32 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-devel, Daniel P. Berrangé


Laurent Vivier <laurent@vivier.eu> writes:

> Le 03/11/2022 à 11:23, Alex Bennée a écrit :
>> This avoids some compilers complaining about a potentially
>> un-initialised [src|dst]argv. In retrospect using GString was overkill
>> for what we are constructing.
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>   tests/unit/test-io-channel-command.c | 14 ++++----------
>>   1 file changed, 4 insertions(+), 10 deletions(-)
>> diff --git a/tests/unit/test-io-channel-command.c
>> b/tests/unit/test-io-channel-command.c
>> index 43e29c8cfb..19f72eab96 100644
>> --- a/tests/unit/test-io-channel-command.c
>> +++ b/tests/unit/test-io-channel-command.c
>> @@ -33,19 +33,13 @@ static void test_io_channel_command_fifo(bool async)
>>   {
>>       g_autofree gchar *tmpdir = g_dir_make_tmp("qemu-test-io-channel.XXXXXX", NULL);
>>       g_autofree gchar *fifo = g_strdup_printf("%s/%s", tmpdir, TEST_FIFO);
>> -    g_autoptr(GString) srcargs = g_string_new(socat);
>> -    g_autoptr(GString) dstargs = g_string_new(socat);
>> -    g_auto(GStrv) srcargv;
>> -    g_auto(GStrv) dstargv;
>> +    g_autofree gchar *srcargs = g_strdup_printf("%s - PIPE:%s,wronly", socat, fifo);
>> +    g_autofree gchar *dstargs = g_strdup_printf("%s PIPE:%s,rdonly -", socat, fifo);
>> +    g_auto(GStrv) srcargv = g_strsplit(srcargs, " ", -1);
>> +    g_auto(GStrv) dstargv = g_strsplit(dstargs, " ", -1);
>>       QIOChannel *src, *dst;
>>       QIOChannelTest *test;
>>   -    g_string_append_printf(srcargs, " - PIPE:%s,wronly", fifo);
>> -    g_string_append_printf(dstargs, " PIPE:%s,rdonly -", fifo);
>> -
>> -    srcargv = g_strsplit(srcargs->str, " ", -1);
>> -    dstargv = g_strsplit(dstargs->str, " ", -1);
>> -
>>       src = QIO_CHANNEL(qio_channel_command_new_spawn((const char **) srcargv,
>>                                                       O_WRONLY,
>>                                                       &error_abort));
>
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
>
> Do you want this be merged via trivial branch?

I'm easy either way. I've got a for-7.2/misc-fixes branch which I'll
send once I can figure out whats going on with the avocado console
interaction code.

>
> Thanks,
> Laurent


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tests/unit: simpler variable sequence for test-io-channel
  2022-11-03 11:32   ` Alex Bennée
@ 2022-11-03 16:03     ` Laurent Vivier
  0 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2022-11-03 16:03 UTC (permalink / raw)
  To: Alex Bennée
  Cc: qemu-devel, Daniel P. Berrangé, qemu-trivial@nongnu.org

Le 03/11/2022 à 12:32, Alex Bennée a écrit :
> 
> Laurent Vivier <laurent@vivier.eu> writes:
> 
>> Le 03/11/2022 à 11:23, Alex Bennée a écrit :
>>> This avoids some compilers complaining about a potentially
>>> un-initialised [src|dst]argv. In retrospect using GString was overkill
>>> for what we are constructing.
>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>> ---
>>>    tests/unit/test-io-channel-command.c | 14 ++++----------
>>>    1 file changed, 4 insertions(+), 10 deletions(-)
>>> diff --git a/tests/unit/test-io-channel-command.c
>>> b/tests/unit/test-io-channel-command.c
>>> index 43e29c8cfb..19f72eab96 100644
>>> --- a/tests/unit/test-io-channel-command.c
>>> +++ b/tests/unit/test-io-channel-command.c
>>> @@ -33,19 +33,13 @@ static void test_io_channel_command_fifo(bool async)
>>>    {
>>>        g_autofree gchar *tmpdir = g_dir_make_tmp("qemu-test-io-channel.XXXXXX", NULL);
>>>        g_autofree gchar *fifo = g_strdup_printf("%s/%s", tmpdir, TEST_FIFO);
>>> -    g_autoptr(GString) srcargs = g_string_new(socat);
>>> -    g_autoptr(GString) dstargs = g_string_new(socat);
>>> -    g_auto(GStrv) srcargv;
>>> -    g_auto(GStrv) dstargv;
>>> +    g_autofree gchar *srcargs = g_strdup_printf("%s - PIPE:%s,wronly", socat, fifo);
>>> +    g_autofree gchar *dstargs = g_strdup_printf("%s PIPE:%s,rdonly -", socat, fifo);
>>> +    g_auto(GStrv) srcargv = g_strsplit(srcargs, " ", -1);
>>> +    g_auto(GStrv) dstargv = g_strsplit(dstargs, " ", -1);
>>>        QIOChannel *src, *dst;
>>>        QIOChannelTest *test;
>>>    -    g_string_append_printf(srcargs, " - PIPE:%s,wronly", fifo);
>>> -    g_string_append_printf(dstargs, " PIPE:%s,rdonly -", fifo);
>>> -
>>> -    srcargv = g_strsplit(srcargs->str, " ", -1);
>>> -    dstargv = g_strsplit(dstargs->str, " ", -1);
>>> -
>>>        src = QIO_CHANNEL(qio_channel_command_new_spawn((const char **) srcargv,
>>>                                                        O_WRONLY,
>>>                                                        &error_abort));
>>
>> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
>>
>> Do you want this be merged via trivial branch?
> 
> I'm easy either way. I've got a for-7.2/misc-fixes branch which I'll
> send once I can figure out whats going on with the avocado console
> interaction code.

Applied to my trivial-patches branch.

Thanks,
Laurent




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-03 16:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-03 10:23 [PATCH] tests/unit: simpler variable sequence for test-io-channel Alex Bennée
2022-11-03 10:27 ` Philippe Mathieu-Daudé
2022-11-03 10:28 ` Laurent Vivier
2022-11-03 11:32   ` Alex Bennée
2022-11-03 16:03     ` Laurent Vivier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.