qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org
Cc: "Hanna Reitz" <hreitz@redhat.com>,
	"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
	"Fam Zheng" <fam@euphon.net>, "Song Gao" <gaosong@loongson.cn>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	"Mahmoud Mandour" <ma.mandourr@gmail.com>,
	qemu-block@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>,
	"Greg Kurz" <groug@kaod.org>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Bin Meng" <bmeng.cn@gmail.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Eric Blake" <eblake@redhat.com>,
	"Hyman Huang" <yong.huang@smartx.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Stefano Garzarella" <sgarzare@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Alexandre Iooss" <erdnaxe@crans.org>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"John Snow" <jsnow@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Jesper Devantier" <foss@defmacro.it>,
	"Peter Xu" <peterx@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Klaus Jensen" <its@irrelevant.dk>,
	"Keith Busch" <kbusch@kernel.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Yuval Shaia" <yuval.shaia.ml@gmail.com>,
	"Bin Meng" <bin.meng@windriver.com>,
	"Helge Deller" <deller@gmx.de>
Subject: Re: [PATCH v3 15/22] linux-user/hppa: fix -Werror=maybe-uninitialized false-positive
Date: Mon, 30 Sep 2024 14:18:19 +0200	[thread overview]
Message-ID: <c1eff411-53f7-483c-83e1-ac09cb6b4c89@vivier.eu> (raw)
In-Reply-To: <20240930081458.1926382-16-marcandre.lureau@redhat.com>

CC Helge Deller

Le 30/09/2024 à 10:14, marcandre.lureau@redhat.com a écrit :
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> ../linux-user/hppa/cpu_loop.c: In function ‘hppa_lws’:
> ../linux-user/hppa/cpu_loop.c:106:17: error: ‘ret’ may be used uninitialized [-Werror=maybe-uninitialized]
>    106 |     env->gr[28] = ret;
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   linux-user/hppa/cpu_loop.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c
> index bc093b8fe8..f4da95490e 100644
> --- a/linux-user/hppa/cpu_loop.c
> +++ b/linux-user/hppa/cpu_loop.c
> @@ -43,7 +43,7 @@ static abi_ulong hppa_lws(CPUHPPAState *env)
>           old = tswap32(old);
>           new = tswap32(new);
>           ret = qatomic_cmpxchg((uint32_t *)g2h(cs, addr), old, new);
> -        ret = tswap32(ret);
> +        env->gr[28] = tswap32(ret);
>           break;
>   
>       case 2: /* elf32 atomic "new" cmpxchg */
> @@ -64,19 +64,19 @@ static abi_ulong hppa_lws(CPUHPPAState *env)
>               old = *(uint8_t *)g2h(cs, old);
>               new = *(uint8_t *)g2h(cs, new);
>               ret = qatomic_cmpxchg((uint8_t *)g2h(cs, addr), old, new);
> -            ret = ret != old;
> +            env->gr[28] = ret != old;
>               break;
>           case 1:
>               old = *(uint16_t *)g2h(cs, old);
>               new = *(uint16_t *)g2h(cs, new);
>               ret = qatomic_cmpxchg((uint16_t *)g2h(cs, addr), old, new);
> -            ret = ret != old;
> +            env->gr[28] = ret != old;
>               break;
>           case 2:
>               old = *(uint32_t *)g2h(cs, old);
>               new = *(uint32_t *)g2h(cs, new);
>               ret = qatomic_cmpxchg((uint32_t *)g2h(cs, addr), old, new);
> -            ret = ret != old;
> +            env->gr[28] = ret != old;
>               break;
>           case 3:
>               {
> @@ -97,13 +97,13 @@ static abi_ulong hppa_lws(CPUHPPAState *env)
>                   }
>                   end_exclusive();
>   #endif
> +                env->gr[28] = ret;
>               }
>               break;
>           }
>           break;
>       }
>   
> -    env->gr[28] = ret;
>       return 0;
>   }
>   

Did you try to put a g_assert_not_reached() in a "default:" for "switch(size)"?
This should help the compiler to know that "env->gr[28] = ret;" will not be reached if ret is not set.

Thanks,
Laurent



  reply	other threads:[~2024-09-30 12:19 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30  8:14 [PATCH v3 00/22] -Werror=maybe-uninitialized fixes marcandre.lureau
2024-09-30  8:14 ` [PATCH v3 01/22] util/coroutine: fix -Werror=maybe-uninitialized false-positive marcandre.lureau
2024-09-30  8:14 ` [PATCH v3 02/22] util/timer: " marcandre.lureau
2024-09-30  8:14 ` [PATCH v3 03/22] hw/qxl: fix -Werror=maybe-uninitialized false-positives marcandre.lureau
2024-09-30  8:14 ` [PATCH v3 04/22] nbd: fix -Werror=maybe-uninitialized false-positive marcandre.lureau
2024-09-30  8:14 ` [PATCH v3 05/22] block/mirror: " marcandre.lureau
2024-09-30  8:14 ` [PATCH v3 06/22] " marcandre.lureau
2024-09-30  8:50   ` Vladimir Sementsov-Ogievskiy
2024-09-30  8:14 ` [PATCH v3 07/22] block/stream: fix -Werror=maybe-uninitialized false-positives marcandre.lureau
2024-09-30  8:14 ` [PATCH v3 08/22] hw/ahci: fix -Werror=maybe-uninitialized false-positive marcandre.lureau
2024-09-30  8:14 ` [PATCH v3 09/22] hw/vhost-scsi: fix -Werror=maybe-uninitialized marcandre.lureau
2024-09-30  8:14 ` [PATCH v3 10/22] hw/sdhci: fix -Werror=maybe-uninitialized false-positive marcandre.lureau
2024-09-30 12:59   ` Alex Bennée
2024-09-30  8:14 ` [PATCH v3 11/22] block/block-copy: " marcandre.lureau
2024-09-30  8:51   ` Vladimir Sementsov-Ogievskiy
2024-09-30  8:14 ` [PATCH v3 12/22] migration: fix -Werror=maybe-uninitialized false-positives marcandre.lureau
2024-09-30  8:14 ` [PATCH v3 13/22] hw/virtio-blk: fix -Werror=maybe-uninitialized false-positive marcandre.lureau
2024-09-30  8:14 ` [PATCH v3 14/22] migration: " marcandre.lureau
2024-09-30  8:14 ` [PATCH v3 15/22] linux-user/hppa: " marcandre.lureau
2024-09-30 12:18   ` Laurent Vivier [this message]
2024-09-30 13:26     ` Marc-André Lureau
2024-10-01  9:20       ` Laurent Vivier
2024-09-30  8:14 ` [PATCH v3 16/22] target/loongarch: " marcandre.lureau
2024-10-01 13:31   ` Vladimir Sementsov-Ogievskiy
2024-09-30  8:14 ` [PATCH v3 17/22] tests: " marcandre.lureau
2024-09-30  8:53   ` Vladimir Sementsov-Ogievskiy
2024-09-30  8:14 ` [PATCH v3 18/22] hw/virtio: fix -Werror=maybe-uninitialized marcandre.lureau
2024-09-30  8:28   ` Stefano Garzarella
2024-09-30  8:14 ` [PATCH v3 19/22] RFC: hw/virtio: a potential leak fix marcandre.lureau
2024-09-30 11:02   ` Eugenio Perez Martin
2024-09-30 11:04     ` Eugenio Perez Martin
2024-09-30 11:29       ` Marc-André Lureau
2024-09-30  8:14 ` [PATCH v3 20/22] block: fix -Werror=maybe-uninitialized false-positive marcandre.lureau
2024-10-01 13:34   ` Vladimir Sementsov-Ogievskiy
2024-10-02  8:32   ` Kevin Wolf
2024-09-30  8:14 ` [PATCH v3 21/22] qom/object: fix -Werror=maybe-uninitialized marcandre.lureau
2024-10-01 14:04   ` Vladimir Sementsov-Ogievskiy
2024-10-01 15:22     ` Marc-André Lureau
2024-10-02  7:00       ` Vladimir Sementsov-Ogievskiy
2024-10-02  6:21   ` Markus Armbruster
2024-10-02  7:00     ` Marc-André Lureau
2024-10-02  7:08       ` Markus Armbruster
2024-09-30  8:14 ` [PATCH v3 22/22] fsdep/9p: fix -Werror=maybe-uninitialized false-positive marcandre.lureau
2024-09-30  9:26   ` Christian Schoenebeck via
2024-09-30  9:35     ` Marc-André Lureau
2024-10-01 13:27 ` [PATCH v3 00/22] -Werror=maybe-uninitialized fixes Marc-André Lureau

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=c1eff411-53f7-483c-83e1-ac09cb6b4c89@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=bin.meng@windriver.com \
    --cc=bmeng.cn@gmail.com \
    --cc=deller@gmx.de \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=eperezma@redhat.com \
    --cc=erdnaxe@crans.org \
    --cc=fam@euphon.net \
    --cc=farosas@suse.de \
    --cc=foss@defmacro.it \
    --cc=gaosong@loongson.cn \
    --cc=groug@kaod.org \
    --cc=hreitz@redhat.com \
    --cc=its@irrelevant.dk \
    --cc=jsnow@redhat.com \
    --cc=kbusch@kernel.org \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=ma.mandourr@gmail.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@yandex-team.ru \
    --cc=yong.huang@smartx.com \
    --cc=yuval.shaia.ml@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).