All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Bernhard Beschow <shentey@gmail.com>
Cc: qemu-devel@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>,
	qemu-trivial@nongnu.org
Subject: Re: [PATCH] tests/unit/test-io-channel-command: Silence GCC error "maybe-uninitialized"
Date: Wed, 2 Nov 2022 02:39:11 -0400	[thread overview]
Message-ID: <20221102023826-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20221101213937.21149-1-shentey@gmail.com>

On Tue, Nov 01, 2022 at 10:39:36PM +0100, Bernhard Beschow wrote:
> GCC issues a false positive warning, resulting in build failure with -Werror:
> 
>   In file included from /usr/lib/glib-2.0/include/glibconfig.h:9,
>                    from /usr/include/glib-2.0/glib/gtypes.h:34,
>                    from /usr/include/glib-2.0/glib/galloca.h:34,
>                    from /usr/include/glib-2.0/glib.h:32,
>                    from ../src/include/glib-compat.h:32,
>                    from ../src/include/qemu/osdep.h:144,
>                    from ../src/tests/unit/test-io-channel-command.c:21:
>   /usr/include/glib-2.0/glib/gmacros.h: In function ‘test_io_channel_command_fifo’:
>   /usr/include/glib-2.0/glib/gmacros.h:1333:105: error: ‘dstargv’ may be used uninitialized [-Werror=maybe-uninitialized]
>    1333 |   static G_GNUC_UNUSED inline void _GLIB_AUTO_FUNC_NAME(TypeName) (TypeName *_ptr) { if (*_ptr != none) (func) (*_ptr); }     \
>         |                                                                                                         ^
>   ../src/tests/unit/test-io-channel-command.c:39:19: note: ‘dstargv’ was declared here
>      39 |     g_auto(GStrv) dstargv;
>         |                   ^~~~~~~
>   /usr/include/glib-2.0/glib/gmacros.h:1333:105: error: ‘srcargv’ may be used uninitialized [-Werror=maybe-uninitialized]
>    1333 |   static G_GNUC_UNUSED inline void _GLIB_AUTO_FUNC_NAME(TypeName) (TypeName *_ptr) { if (*_ptr != none) (func) (*_ptr); }     \
>         |                                                                                                         ^
>   ../src/tests/unit/test-io-channel-command.c:38:19: note: ‘srcargv’ was declared here
>      38 |     g_auto(GStrv) srcargv;
>         |                   ^~~~~~~
>   cc1: all warnings being treated as errors
> 
> GCC version:
> 
>   $ gcc --version
>   gcc (GCC) 12.2.0
> 
> Fixes: 68406d10859385c88da73d0106254a7f47e6652e ('tests/unit: cleanups for test-io-channel-command')
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>

It's a game of whac-a-mole for sure but what are you gonnu do.

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  tests/unit/test-io-channel-command.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/unit/test-io-channel-command.c b/tests/unit/test-io-channel-command.c
> index 43e29c8cfb..ba0717d3c3 100644
> --- a/tests/unit/test-io-channel-command.c
> +++ b/tests/unit/test-io-channel-command.c
> @@ -35,8 +35,8 @@ static void test_io_channel_command_fifo(bool async)
>      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_auto(GStrv) srcargv = NULL;
> +    g_auto(GStrv) dstargv = NULL;
>      QIOChannel *src, *dst;
>      QIOChannelTest *test;
>  
> -- 
> 2.38.1



  reply	other threads:[~2022-11-02  6:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01 21:39 [PATCH] tests/unit/test-io-channel-command: Silence GCC error "maybe-uninitialized" Bernhard Beschow
2022-11-02  6:39 ` Michael S. Tsirkin [this message]
2022-11-02  6:50 ` Bin Meng
2022-11-02 17:55 ` Laurent Vivier
2022-11-02 20:24 ` Alex Bennée
2022-11-03  9:48   ` Laurent Vivier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221102023826-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=shentey@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.