[PATCH 00/19] -Werror=maybe-uninitialized fixes

marcandre.lureau@redhat.com posted 19 patches 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240328102052.3499331-1-marcandre.lureau@redhat.com
Maintainers: John Snow <jsnow@redhat.com>, Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, Keith Busch <kbusch@kernel.org>, Klaus Jensen <its@irrelevant.dk>, Jesper Devantier <foss@defmacro.it>, Yuval Shaia <yuval.shaia.ml@gmail.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Bin Meng <bin.meng@windriver.com>, "Eugenio Pérez" <eperezma@redhat.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Hyman Huang <yong.huang@smartx.com>, Eric Blake <eblake@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Alexandre Iooss <erdnaxe@crans.org>, Mahmoud Mandour <ma.mandourr@gmail.com>, Pierrick Bouvier <pierrick.bouvier@linaro.org>
block/mirror.c                     | 2 +-
block/stream.c                     | 6 +++---
hw/block/virtio-blk.c              | 2 +-
hw/display/qxl.c                   | 4 ++--
hw/ide/ahci.c                      | 3 ++-
hw/nvme/ctrl.c                     | 2 +-
hw/rdma/rdma_backend.c             | 2 +-
hw/scsi/vhost-scsi.c               | 2 +-
hw/sd/sdhci.c                      | 2 +-
hw/virtio/vhost-shadow-virtqueue.c | 6 ++++--
migration/block.c                  | 2 +-
migration/dirtyrate.c              | 4 ++--
migration/migration.c              | 2 +-
migration/ram.c                    | 2 +-
nbd/client-connection.c            | 2 +-
plugins/loader.c                   | 2 +-
tests/unit/test-bdrv-drain.c       | 2 +-
tests/unit/test-block-iothread.c   | 2 +-
util/qemu-coroutine.c              | 2 +-
util/qemu-timer.c                  | 6 +++---
20 files changed, 30 insertions(+), 27 deletions(-)
[PATCH 00/19] -Werror=maybe-uninitialized fixes
Posted by marcandre.lureau@redhat.com 1 month ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Hi,

Depending on -Doptimization=<value>, GCC (13.2.1 here) produces different
maybe-uninitialized warnings:
- g: produces -Werror=maybe-uninitialized errors
- 0: clean build
- 1: produces -Werror=maybe-uninitialized errors
- 2: clean build
- 3: produces few -Werror=maybe-uninitialized errors
- s: produces -Werror=maybe-uninitialized errors

Most are false-positive, because prior LOCK_GUARD should guarantee an
initialization path. Few of them are a bit trickier. Finally, I found
a potential related memory leak.

thanks

Marc-André Lureau (19):
  util/coroutine: fix -Werror=maybe-uninitialized false-positive
  util/timer: with -Werror=maybe-uninitialized false-positive
  hw/qxl: fix -Werror=maybe-uninitialized false-positives
  nbd: with -Werror=maybe-uninitialized false-positive
  block/mirror: fix -Werror=maybe-uninitialized false-positive
  block/stream: fix -Werror=maybe-uninitialized false-positives
  hw/ahci: fix -Werror=maybe-uninitialized false-positive
  hw/vhost-scsi: fix -Werror=maybe-uninitialized
  hw/sdhci: fix -Werror=maybe-uninitialized false-positive
  hw/rdma: fix -Werror=maybe-uninitialized false-positive
  migration/block: fix -Werror=maybe-uninitialized false-positive
  migration: fix -Werror=maybe-uninitialized false-positives
  hw/virtio-blk: fix -Werror=maybe-uninitialized false-positive
  plugins: fix -Werror=maybe-uninitialized false-positive
  migration: fix -Werror=maybe-uninitialized false-positive
  tests: fix -Werror=maybe-uninitialized
  hw/nvme: fix -Werror=maybe-uninitialized
  hw/virtio: fix -Werror=maybe-uninitialized
  RFC: hw/virtio: a potential leak fix

 block/mirror.c                     | 2 +-
 block/stream.c                     | 6 +++---
 hw/block/virtio-blk.c              | 2 +-
 hw/display/qxl.c                   | 4 ++--
 hw/ide/ahci.c                      | 3 ++-
 hw/nvme/ctrl.c                     | 2 +-
 hw/rdma/rdma_backend.c             | 2 +-
 hw/scsi/vhost-scsi.c               | 2 +-
 hw/sd/sdhci.c                      | 2 +-
 hw/virtio/vhost-shadow-virtqueue.c | 6 ++++--
 migration/block.c                  | 2 +-
 migration/dirtyrate.c              | 4 ++--
 migration/migration.c              | 2 +-
 migration/ram.c                    | 2 +-
 nbd/client-connection.c            | 2 +-
 plugins/loader.c                   | 2 +-
 tests/unit/test-bdrv-drain.c       | 2 +-
 tests/unit/test-block-iothread.c   | 2 +-
 util/qemu-coroutine.c              | 2 +-
 util/qemu-timer.c                  | 6 +++---
 20 files changed, 30 insertions(+), 27 deletions(-)

-- 
2.44.0


Re: [PATCH 00/19] -Werror=maybe-uninitialized fixes
Posted by Eric Blake 1 month ago
On Thu, Mar 28, 2024 at 02:20:33PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> Hi,
> 
> Depending on -Doptimization=<value>, GCC (13.2.1 here) produces different
> maybe-uninitialized warnings:
> - g: produces -Werror=maybe-uninitialized errors
> - 0: clean build
> - 1: produces -Werror=maybe-uninitialized errors
> - 2: clean build
> - 3: produces few -Werror=maybe-uninitialized errors
> - s: produces -Werror=maybe-uninitialized errors
> 
> Most are false-positive, because prior LOCK_GUARD should guarantee an
> initialization path. Few of them are a bit trickier. Finally, I found
> a potential related memory leak.
> 
> thanks

Couple of subject lines are inconsistent; I suggest:

> 
> Marc-André Lureau (19):
>   util/coroutine: fix -Werror=maybe-uninitialized false-positive
>   util/timer: with -Werror=maybe-uninitialized false-positive

s/with/fix/

>   hw/qxl: fix -Werror=maybe-uninitialized false-positives
>   nbd: with -Werror=maybe-uninitialized false-positive

s/with/fix/

>   block/mirror: fix -Werror=maybe-uninitialized false-positive
>   block/stream: fix -Werror=maybe-uninitialized false-positives
>   hw/ahci: fix -Werror=maybe-uninitialized false-positive
>   hw/vhost-scsi: fix -Werror=maybe-uninitialized
>   hw/sdhci: fix -Werror=maybe-uninitialized false-positive
>   hw/rdma: fix -Werror=maybe-uninitialized false-positive
>   migration/block: fix -Werror=maybe-uninitialized false-positive
>   migration: fix -Werror=maybe-uninitialized false-positives
>   hw/virtio-blk: fix -Werror=maybe-uninitialized false-positive
>   plugins: fix -Werror=maybe-uninitialized false-positive
>   migration: fix -Werror=maybe-uninitialized false-positive
>   tests: fix -Werror=maybe-uninitialized
>   hw/nvme: fix -Werror=maybe-uninitialized
>   hw/virtio: fix -Werror=maybe-uninitialized
>   RFC: hw/virtio: a potential leak fix
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org