qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 79854b: block-qdict: Fix -Werror=maybe-uninit


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] 79854b: block-qdict: Fix -Werror=maybe-uninitialized build...
Date: Mon, 21 Mar 2022 10:52:07 -0700

  Branch: refs/heads/staging
  Home:   https://github.com/qemu/qemu
  Commit: 79854b95446396c8e7f397800c5d86c3d9a7540d
      
https://github.com/qemu/qemu/commit/79854b95446396c8e7f397800c5d86c3d9a7540d
  Author: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    M qobject/block-qdict.c

  Log Message:
  -----------
  block-qdict: Fix -Werror=maybe-uninitialized build failure

Building QEMU on Fedora 37 (Rawhide Prerelease) ppc64le failed with the
following error:

    $ ../configure --prefix=/usr/local/qemu-disabletcg 
--target-list=ppc-softmmu,ppc64-softmmu --disable-tcg --disable-linux-user
    ...
    $ make -j$(nproc)
    ...
    In file included from /root/qemu/include/qapi/qmp/qdict.h:16,
                     from /root/qemu/include/block/qdict.h:13,
                     from ../qobject/block-qdict.c:11:
    /root/qemu/include/qapi/qmp/qobject.h: In function ‘qdict_array_split’:
    /root/qemu/include/qapi/qmp/qobject.h:49:17: error: ‘subqdict’ may be used 
uninitialized [-Werror=maybe-uninitialized]
       49 |     typeof(obj) _obj = (obj);                                   \
          |                 ^~~~
    ../qobject/block-qdict.c:227:16: note: ‘subqdict’ declared here
      227 |         QDict *subqdict;
          |                ^~~~~~~~
    cc1: all warnings being treated as errors

Fix build failure by expanding the ternary operation.
Tested with `make check-unit` (the check-block-qdict test passed).

Signed-off-by: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Hanna Reitz <hreitz@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Message-Id: <20220311221634.58288-1-muriloo@linux.ibm.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


  Commit: 15ba4a9f7ba592f2f1a0eb50b20f0ebd4412ab6e
      
https://github.com/qemu/qemu/commit/15ba4a9f7ba592f2f1a0eb50b20f0ebd4412ab6e
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    A scripts/coccinelle/use-g_new-etc.cocci

  Log Message:
  -----------
  scripts/coccinelle: New use-g_new-etc.cocci

This is the semantic patch from commit b45c03f585 "arm: Use g_new() &
friends where that makes obvious sense".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20220315144156.1595462-2-armbru@redhat.com>


  Commit: 1366244ab6d0c83bf0f90270e5bb608651a3cc8f
      
https://github.com/qemu/qemu/commit/1366244ab6d0c83bf0f90270e5bb608651a3cc8f
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    M hw/9pfs/9p-proxy.c
    M hw/9pfs/9p-synth.c
    M hw/9pfs/9p.c
    M hw/9pfs/codir.c
    M tests/qtest/virtio-9p-test.c

  Log Message:
  -----------
  9pfs: Use g_new() & friends where that makes obvious sense

g_new(T, n) is neater than g_malloc(sizeof(T) * n).  It's also safer,
for two reasons.  One, it catches multiplication overflowing size_t.
Two, it returns T * rather than void *, which lets the compiler catch
more type errors.

This commit only touches allocations with size arguments of the form
sizeof(T).

Initial patch created mechanically with:

    $ spatch --in-place --sp-file scripts/coccinelle/use-g_new-etc.cocci \
             --macro-file scripts/cocci-macro-file.h FILES...

This uncovers a typing error:

    ../hw/9pfs/9p.c: In function ‘qid_path_fullmap’:
    ../hw/9pfs/9p.c:855:13: error: assignment to ‘QpfEntry *’ from incompatible 
pointer type ‘QppEntry *’ [-Werror=incompatible-pointer-types]
      855 |         val = g_new0(QppEntry, 1);
          |             ^

Harmless, because QppEntry is larger than QpfEntry.  Manually fixed to
allocate a QpfEntry instead.

Cc: Greg Kurz <groug@kaod.org>
Cc: Christian Schoenebeck <qemu_oss@crudebyte.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <20220315144156.1595462-3-armbru@redhat.com>


  Commit: b21e2380376c470900fcadf47507f4d5ade75e85
      
https://github.com/qemu/qemu/commit/b21e2380376c470900fcadf47507f4d5ade75e85
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    M accel/kvm/kvm-all.c
    M accel/tcg/tcg-accel-ops-mttcg.c
    M accel/tcg/tcg-accel-ops-rr.c
    M audio/audio.c
    M audio/audio_legacy.c
    M audio/dsoundaudio.c
    M audio/jackaudio.c
    M audio/paaudio.c
    M backends/cryptodev.c
    M contrib/vhost-user-gpu/vhost-user-gpu.c
    M cpus-common.c
    M dump/dump.c
    M hw/acpi/hmat.c
    M hw/audio/intel-hda.c
    M hw/char/parallel.c
    M hw/char/riscv_htif.c
    M hw/char/virtio-serial-bus.c
    M hw/core/irq.c
    M hw/core/reset.c
    M hw/display/pxa2xx_lcd.c
    M hw/display/tc6393xb.c
    M hw/display/virtio-gpu.c
    M hw/display/xenfb.c
    M hw/dma/rc4030.c
    M hw/i2c/core.c
    M hw/i2c/i2c_mux_pca954x.c
    M hw/i386/amd_iommu.c
    M hw/i386/intel_iommu.c
    M hw/i386/xen/xen-hvm.c
    M hw/i386/xen/xen-mapcache.c
    M hw/input/lasips2.c
    M hw/input/pckbd.c
    M hw/input/ps2.c
    M hw/input/pxa2xx_keypad.c
    M hw/input/tsc2005.c
    M hw/intc/riscv_aclint.c
    M hw/intc/xics.c
    M hw/m68k/virt.c
    M hw/mips/mipssim.c
    M hw/misc/applesmc.c
    M hw/misc/imx6_src.c
    M hw/misc/ivshmem.c
    M hw/net/virtio-net.c
    M hw/nvme/ns.c
    M hw/pci-host/pnv_phb3.c
    M hw/pci-host/pnv_phb4.c
    M hw/pci/pcie_sriov.c
    M hw/ppc/e500.c
    M hw/ppc/ppc.c
    M hw/ppc/ppc405_boards.c
    M hw/ppc/ppc405_uc.c
    M hw/ppc/ppc4xx_devs.c
    M hw/ppc/ppc_booke.c
    M hw/ppc/spapr.c
    M hw/ppc/spapr_events.c
    M hw/ppc/spapr_hcall.c
    M hw/ppc/spapr_numa.c
    M hw/rdma/vmw/pvrdma_dev_ring.c
    M hw/rdma/vmw/pvrdma_qp_ops.c
    M hw/sh4/r2d.c
    M hw/sh4/sh7750.c
    M hw/sparc/leon3.c
    M hw/sparc64/sparc64.c
    M hw/timer/arm_timer.c
    M hw/timer/slavio_timer.c
    M hw/vfio/pci.c
    M hw/vfio/platform.c
    M hw/virtio/virtio-crypto.c
    M hw/virtio/virtio-iommu.c
    M hw/virtio/virtio.c
    M hw/xtensa/xtfpga.c
    M include/qemu/timer.h
    M linux-user/syscall.c
    M migration/dirtyrate.c
    M migration/multifd-zlib.c
    M migration/ram.c
    M monitor/misc.c
    M monitor/qmp-cmds.c
    M qga/commands-win32.c
    M qga/commands.c
    M qom/qom-qmp-cmds.c
    M replay/replay-char.c
    M replay/replay-events.c
    M softmmu/bootdevice.c
    M softmmu/dma-helpers.c
    M softmmu/memory_mapping.c
    M target/i386/cpu-sysemu.c
    M target/i386/hax/hax-accel-ops.c
    M target/i386/nvmm/nvmm-accel-ops.c
    M target/i386/whpx/whpx-accel-ops.c
    M target/i386/whpx/whpx-all.c
    M target/s390x/cpu-sysemu.c
    M tests/unit/test-hbitmap.c
    M tests/unit/test-qmp-cmds.c
    M tests/unit/test-qobject-output-visitor.c
    M tests/unit/test-vmstate.c
    M ui/vnc-enc-tight.c
    M util/envlist.c
    M util/hbitmap.c
    M util/main-loop.c
    M util/qemu-timer.c
    M util/vfio-helpers.c

  Log Message:
  -----------
  Use g_new() & friends where that makes obvious sense

g_new(T, n) is neater than g_malloc(sizeof(T) * n).  It's also safer,
for two reasons.  One, it catches multiplication overflowing size_t.
Two, it returns T * rather than void *, which lets the compiler catch
more type errors.

This commit only touches allocations with size arguments of the form
sizeof(T).

Patch created mechanically with:

    $ spatch --in-place --sp-file scripts/coccinelle/use-g_new-etc.cocci \
             --macro-file scripts/cocci-macro-file.h FILES...

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20220315144156.1595462-4-armbru@redhat.com>
Reviewed-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>


  Commit: 330724977b10f5b92610817e8b7d1dfed122df87
      
https://github.com/qemu/qemu/commit/330724977b10f5b92610817e8b7d1dfed122df87
  Author: Peter Maydell <peter.maydell@linaro.org>
  Date:   2022-03-21 (Mon, 21 Mar 2022)

  Changed paths:
    M accel/kvm/kvm-all.c
    M accel/tcg/tcg-accel-ops-mttcg.c
    M accel/tcg/tcg-accel-ops-rr.c
    M audio/audio.c
    M audio/audio_legacy.c
    M audio/dsoundaudio.c
    M audio/jackaudio.c
    M audio/paaudio.c
    M backends/cryptodev.c
    M contrib/vhost-user-gpu/vhost-user-gpu.c
    M cpus-common.c
    M dump/dump.c
    M hw/9pfs/9p-proxy.c
    M hw/9pfs/9p-synth.c
    M hw/9pfs/9p.c
    M hw/9pfs/codir.c
    M hw/acpi/hmat.c
    M hw/audio/intel-hda.c
    M hw/char/parallel.c
    M hw/char/riscv_htif.c
    M hw/char/virtio-serial-bus.c
    M hw/core/irq.c
    M hw/core/reset.c
    M hw/display/pxa2xx_lcd.c
    M hw/display/tc6393xb.c
    M hw/display/virtio-gpu.c
    M hw/display/xenfb.c
    M hw/dma/rc4030.c
    M hw/i2c/core.c
    M hw/i2c/i2c_mux_pca954x.c
    M hw/i386/amd_iommu.c
    M hw/i386/intel_iommu.c
    M hw/i386/xen/xen-hvm.c
    M hw/i386/xen/xen-mapcache.c
    M hw/input/lasips2.c
    M hw/input/pckbd.c
    M hw/input/ps2.c
    M hw/input/pxa2xx_keypad.c
    M hw/input/tsc2005.c
    M hw/intc/riscv_aclint.c
    M hw/intc/xics.c
    M hw/m68k/virt.c
    M hw/mips/mipssim.c
    M hw/misc/applesmc.c
    M hw/misc/imx6_src.c
    M hw/misc/ivshmem.c
    M hw/net/virtio-net.c
    M hw/nvme/ns.c
    M hw/pci-host/pnv_phb3.c
    M hw/pci-host/pnv_phb4.c
    M hw/pci/pcie_sriov.c
    M hw/ppc/e500.c
    M hw/ppc/ppc.c
    M hw/ppc/ppc405_boards.c
    M hw/ppc/ppc405_uc.c
    M hw/ppc/ppc4xx_devs.c
    M hw/ppc/ppc_booke.c
    M hw/ppc/spapr.c
    M hw/ppc/spapr_events.c
    M hw/ppc/spapr_hcall.c
    M hw/ppc/spapr_numa.c
    M hw/rdma/vmw/pvrdma_dev_ring.c
    M hw/rdma/vmw/pvrdma_qp_ops.c
    M hw/sh4/r2d.c
    M hw/sh4/sh7750.c
    M hw/sparc/leon3.c
    M hw/sparc64/sparc64.c
    M hw/timer/arm_timer.c
    M hw/timer/slavio_timer.c
    M hw/vfio/pci.c
    M hw/vfio/platform.c
    M hw/virtio/virtio-crypto.c
    M hw/virtio/virtio-iommu.c
    M hw/virtio/virtio.c
    M hw/xtensa/xtfpga.c
    M include/qemu/timer.h
    M linux-user/syscall.c
    M migration/dirtyrate.c
    M migration/multifd-zlib.c
    M migration/ram.c
    M monitor/misc.c
    M monitor/qmp-cmds.c
    M qga/commands-win32.c
    M qga/commands.c
    M qobject/block-qdict.c
    M qom/qom-qmp-cmds.c
    M replay/replay-char.c
    M replay/replay-events.c
    A scripts/coccinelle/use-g_new-etc.cocci
    M softmmu/bootdevice.c
    M softmmu/dma-helpers.c
    M softmmu/memory_mapping.c
    M target/i386/cpu-sysemu.c
    M target/i386/hax/hax-accel-ops.c
    M target/i386/nvmm/nvmm-accel-ops.c
    M target/i386/whpx/whpx-accel-ops.c
    M target/i386/whpx/whpx-all.c
    M target/s390x/cpu-sysemu.c
    M tests/qtest/virtio-9p-test.c
    M tests/unit/test-hbitmap.c
    M tests/unit/test-qmp-cmds.c
    M tests/unit/test-qobject-output-visitor.c
    M tests/unit/test-vmstate.c
    M ui/vnc-enc-tight.c
    M util/envlist.c
    M util/hbitmap.c
    M util/main-loop.c
    M util/qemu-timer.c
    M util/vfio-helpers.c

  Log Message:
  -----------
  Merge tag 'pull-misc-2022-03-21' of git://repo.or.cz/qemu/armbru into staging

Miscellaneous patches patches for 2022-03-21

# gpg: Signature made Mon 21 Mar 2022 14:48:16 GMT
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* tag 'pull-misc-2022-03-21' of git://repo.or.cz/qemu/armbru:
  Use g_new() & friends where that makes obvious sense
  9pfs: Use g_new() & friends where that makes obvious sense
  scripts/coccinelle: New use-g_new-etc.cocci
  block-qdict: Fix -Werror=maybe-uninitialized build failure

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Compare: https://github.com/qemu/qemu/compare/2028ab513bf0...330724977b10



reply via email to

[Prev in Thread] Current Thread [Next in Thread]