[PATCH v2 00/22] -Werror=maybe-uninitialized fixes

marcandre.lureau@redhat.com posted 22 patches 4 weeks ago
There is a newer version of this series
block/block-copy.c                 |  2 +-
block/file-posix.c                 |  2 +-
block/mirror.c                     |  8 ++++----
block/stream.c                     |  6 +++---
fsdev/9p-iov-marshal.c             |  6 +++---
hw/block/virtio-blk.c              |  2 +-
hw/display/qxl.c                   |  4 ++--
hw/ide/ahci.c                      |  3 ++-
hw/scsi/vhost-scsi.c               |  2 +-
hw/sd/sdhci.c                      |  2 +-
hw/virtio/vhost-shadow-virtqueue.c |  6 ++++--
linux-user/hppa/cpu_loop.c         | 10 +++++-----
migration/dirtyrate.c              |  4 ++--
migration/migration.c              |  2 +-
migration/ram.c                    |  2 +-
nbd/client-connection.c            |  2 +-
qom/object.c                       |  5 ++++-
target/loongarch/gdbstub.c         | 26 ++++++++++++++------------
tests/unit/test-bdrv-drain.c       |  2 +-
tests/unit/test-block-iothread.c   |  2 +-
util/qemu-coroutine.c              |  2 +-
util/qemu-timer.c                  |  6 +++---
22 files changed, 57 insertions(+), 49 deletions(-)
[PATCH v2 00/22] -Werror=maybe-uninitialized fixes
Posted by marcandre.lureau@redhat.com 4 weeks ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Hi,

Depending on -Doptimization=<value>, GCC (14.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

v2:
 - rebased, dropped some patches
 - added some new patches with updated code-base and newer GCC
 - added s-o-b/a-b

Marc-André Lureau (22):
  util/coroutine: fix -Werror=maybe-uninitialized false-positive
  util/timer: fix -Werror=maybe-uninitialized false-positive
  hw/qxl: fix -Werror=maybe-uninitialized false-positives
  nbd: fix -Werror=maybe-uninitialized false-positive
  block/mirror: fix -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
  block/block-copy: fix -Werror=maybe-uninitialized false-positive
  migration: fix -Werror=maybe-uninitialized false-positives
  hw/virtio-blk: fix -Werror=maybe-uninitialized false-positive
  migration: fix -Werror=maybe-uninitialized false-positive
  linux-user/hppa: fix -Werror=maybe-uninitialized false-positive
  target/loongarch: fix -Werror=maybe-uninitialized false-positive
  tests: fix -Werror=maybe-uninitialized false-positive
  hw/virtio: fix -Werror=maybe-uninitialized false-positive
  block: fix -Werror=maybe-uninitialized false-positive
  qom/object: fix -Werror=maybe-uninitialized
  fsdep/9p: fix -Werror=maybe-uninitialized false-positive
  RFC: hw/virtio: a potential leak fix

 block/block-copy.c                 |  2 +-
 block/file-posix.c                 |  2 +-
 block/mirror.c                     |  8 ++++----
 block/stream.c                     |  6 +++---
 fsdev/9p-iov-marshal.c             |  6 +++---
 hw/block/virtio-blk.c              |  2 +-
 hw/display/qxl.c                   |  4 ++--
 hw/ide/ahci.c                      |  3 ++-
 hw/scsi/vhost-scsi.c               |  2 +-
 hw/sd/sdhci.c                      |  2 +-
 hw/virtio/vhost-shadow-virtqueue.c |  6 ++++--
 linux-user/hppa/cpu_loop.c         | 10 +++++-----
 migration/dirtyrate.c              |  4 ++--
 migration/migration.c              |  2 +-
 migration/ram.c                    |  2 +-
 nbd/client-connection.c            |  2 +-
 qom/object.c                       |  5 ++++-
 target/loongarch/gdbstub.c         | 26 ++++++++++++++------------
 tests/unit/test-bdrv-drain.c       |  2 +-
 tests/unit/test-block-iothread.c   |  2 +-
 util/qemu-coroutine.c              |  2 +-
 util/qemu-timer.c                  |  6 +++---
 22 files changed, 57 insertions(+), 49 deletions(-)

-- 
2.45.2.827.g557ae147e6


Re: [PATCH v2 00/22] -Werror=maybe-uninitialized fixes
Posted by Daniel P. Berrangé 4 weeks ago
On Tue, Sep 24, 2024 at 05:05:31PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> Hi,
> 
> Depending on -Doptimization=<value>, GCC (14.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.

In addition we now build with "-ftrivial-auto-var-init=zero", so
any case which is missing an "= NULL" or "= 0"  initialization is
protected.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|