Re: [PATCH v2 00/48] Use g_assert_not_reached instead of (g_)assert(0, false)

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

 



On 9/12/24 18:37, Xingtao Yao (Fujitsu) wrote:


-----Original Message-----
From: qemu-devel-bounces+yaoxt.fnst=fujitsu.com@xxxxxxxxxx
<qemu-devel-bounces+yaoxt.fnst=fujitsu.com@xxxxxxxxxx> On Behalf Of
Pierrick Bouvier
Sent: Thursday, September 12, 2024 3:39 PM
To: qemu-devel@xxxxxxxxxx
Cc: Jason Wang <jasowang@xxxxxxxxxx>; Alex Bennée <alex.bennee@xxxxxxxxxx>;
Laurent Vivier <lvivier@xxxxxxxxxx>; Marcelo Tosatti <mtosatti@xxxxxxxxxx>;
Nicholas Piggin <npiggin@xxxxxxxxx>; Klaus Jensen <its@xxxxxxxxxxxxx>; WANG
Xuerui <git@xxxxxxxxxx>; Halil Pasic <pasic@xxxxxxxxxxxxx>; Rob Herring
<robh@xxxxxxxxxx>; Michael Rolnik <mrolnik@xxxxxxxxx>; Zhao Liu
<zhao1.liu@xxxxxxxxx>; Peter Maydell <peter.maydell@xxxxxxxxxx>; Richard
Henderson <richard.henderson@xxxxxxxxxx>; Fabiano Rosas <farosas@xxxxxxx>;
Corey Minyard <minyard@xxxxxxx>; Keith Busch <kbusch@xxxxxxxxxx>; Thomas
Huth <thuth@xxxxxxxxxx>; Maciej S. Szmigiero <maciej.szmigiero@xxxxxxxxxx>;
Harsh Prateek Bora <harshpb@xxxxxxxxxxxxx>; Kevin Wolf <kwolf@xxxxxxxxxx>;
Paolo Bonzini <pbonzini@xxxxxxxxxx>; Jesper Devantier <foss@xxxxxxxxxxx>;
Hyman Huang <yong.huang@xxxxxxxxxx>; Philippe Mathieu-Daudé
<philmd@xxxxxxxxxx>; Palmer Dabbelt <palmer@xxxxxxxxxxx>;
qemu-s390x@xxxxxxxxxx; Laurent Vivier <laurent@xxxxxxxxx>;
qemu-riscv@xxxxxxxxxx; Richard W.M. Jones <rjones@xxxxxxxxxx>; Liu Zhiwei
<zhiwei_liu@xxxxxxxxxxxxxxxxx>; Aurelien Jarno <aurelien@xxxxxxxxxxx>; Daniel P.
Berrangé <berrange@xxxxxxxxxx>; Marcel Apfelbaum
<marcel.apfelbaum@xxxxxxxxx>; kvm@xxxxxxxxxxxxxxx; Christian Borntraeger
<borntraeger@xxxxxxxxxxxxx>; Akihiko Odaki <akihiko.odaki@xxxxxxxxxx>;
Daniel Henrique Barboza <dbarboza@xxxxxxxxxxxxxxxx>; Hanna Reitz
<hreitz@xxxxxxxxxx>; Ani Sinha <anisinha@xxxxxxxxxx>;
qemu-ppc@xxxxxxxxxx; Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>;
Alistair Francis <alistair.francis@xxxxxxx>; Bin Meng <bmeng.cn@xxxxxxxxx>;
Michael S. Tsirkin <mst@xxxxxxxxxx>; Helge Deller <deller@xxxxxx>; Peter Xu
<peterx@xxxxxxxxxx>; Daniel Henrique Barboza <danielhb413@xxxxxxxxx>;
Dmitry Fleytman <dmitry.fleytman@xxxxxxxxx>; Nina Schoetterl-Glausch
<nsg@xxxxxxxxxxxxx>; Yanan Wang <wangyanan55@xxxxxxxxxx>;
qemu-arm@xxxxxxxxxx; Igor Mammedov <imammedo@xxxxxxxxxx>;
Jean-Christophe Dubois <jcd@xxxxxxxxxxxxxxx>; Eric Farman
<farman@xxxxxxxxxxxxx>; Sriram Yagnaraman
<sriram.yagnaraman@xxxxxxxxxxxx>; qemu-block@xxxxxxxxxx; Stefan Berger
<stefanb@xxxxxxxxxxxxxxxxxx>; Joel Stanley <joel@xxxxxxxxx>; Eduardo Habkost
<eduardo@xxxxxxxxxxx>; David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>; Fam
Zheng <fam@xxxxxxxxxx>; Weiwei Li <liwei1518@xxxxxxxxx>; Markus
Armbruster <armbru@xxxxxxxxxx>; Pierrick Bouvier <pierrick.bouvier@xxxxxxxxxx>
Subject: [PATCH v2 00/48] Use g_assert_not_reached instead of (g_)assert(0,
false)

This series cleans up all usages of assert/g_assert who are supposed to stop
execution of QEMU. We replace those by g_assert_not_reached().
It was suggested recently when cleaning codebase to build QEMU with gcc
and tsan:
https://lore.kernel.org/qemu-devel/54bb02a6-1b12-460a-97f6-3f478ef766c6@lin
aro.org/.

In more, cleanup useless break and return after g_assert_not_reached();
I found that not all of the break or return after g_assert_not_reached() were cleaned up, don't they need to be cleaned up?

And finally, ensure with scripts/checkpatch.pl that we don't reintroduce
(g_)assert(false) in the future.

New commits (removing return) need review.

Tested that it build warning free with gcc and clang.

v2
- align backslashes for some changes
- add summary in all commits message
- remove redundant comment

v1
https://lore.kernel.org/qemu-devel/20240910221606.1817478-1-pierrick.bouvier@
linaro.org/T/#t

Pierrick Bouvier (48):
   docs/spin: replace assert(0) with g_assert_not_reached()
   hw/acpi: replace assert(0) with g_assert_not_reached()
   hw/arm: replace assert(0) with g_assert_not_reached()
   hw/char: replace assert(0) with g_assert_not_reached()
   hw/core: replace assert(0) with g_assert_not_reached()
   hw/net: replace assert(0) with g_assert_not_reached()
   hw/watchdog: replace assert(0) with g_assert_not_reached()
   migration: replace assert(0) with g_assert_not_reached()
   qobject: replace assert(0) with g_assert_not_reached()
   system: replace assert(0) with g_assert_not_reached()
   target/ppc: replace assert(0) with g_assert_not_reached()
   tests/qtest: replace assert(0) with g_assert_not_reached()
   tests/unit: replace assert(0) with g_assert_not_reached()
   include/hw/s390x: replace assert(false) with g_assert_not_reached()
   block: replace assert(false) with g_assert_not_reached()
   hw/hyperv: replace assert(false) with g_assert_not_reached()
   hw/net: replace assert(false) with g_assert_not_reached()
   hw/nvme: replace assert(false) with g_assert_not_reached()
   hw/pci: replace assert(false) with g_assert_not_reached()
   hw/ppc: replace assert(false) with g_assert_not_reached()
   migration: replace assert(false) with g_assert_not_reached()
   target/i386/kvm: replace assert(false) with g_assert_not_reached()
   tests/qtest: replace assert(false) with g_assert_not_reached()
   accel/tcg: remove break after g_assert_not_reached()
   block: remove break after g_assert_not_reached()
   hw/acpi: remove break after g_assert_not_reached()
   hw/gpio: remove break after g_assert_not_reached()
   hw/misc: remove break after g_assert_not_reached()
   hw/net: remove break after g_assert_not_reached()
   hw/pci-host: remove break after g_assert_not_reached()
   hw/scsi: remove break after g_assert_not_reached()
   hw/tpm: remove break after g_assert_not_reached()
   target/arm: remove break after g_assert_not_reached()
   target/riscv: remove break after g_assert_not_reached()
   tests/qtest: remove break after g_assert_not_reached()
   ui: remove break after g_assert_not_reached()
   fpu: remove break after g_assert_not_reached()
   tcg/loongarch64: remove break after g_assert_not_reached()
   include/qemu: remove return after g_assert_not_reached()
   hw/hyperv: remove return after g_assert_not_reached()
   hw/net: remove return after g_assert_not_reached()
   hw/pci: remove return after g_assert_not_reached()
   hw/ppc: remove return after g_assert_not_reached()
   migration: remove return after g_assert_not_reached()
   qobject: remove return after g_assert_not_reached()
   qom: remove return after g_assert_not_reached()
   tests/qtest: remove return after g_assert_not_reached()
   scripts/checkpatch.pl: emit error when using assert(false)

  docs/spin/aio_notify_accept.promela     |  6 +++---
  docs/spin/aio_notify_bug.promela        |  6 +++---
  include/hw/s390x/cpu-topology.h         |  2 +-
  include/qemu/pmem.h                     |  1 -
  accel/tcg/plugin-gen.c                  |  1 -
  block/qcow2.c                           |  2 +-
  block/ssh.c                             |  1 -
  hw/acpi/aml-build.c                     |  3 +--
  hw/arm/highbank.c                       |  2 +-
  hw/char/avr_usart.c                     |  2 +-
  hw/core/numa.c                          |  2 +-
  hw/gpio/nrf51_gpio.c                    |  1 -
  hw/hyperv/hyperv_testdev.c              |  7 +++----
  hw/hyperv/vmbus.c                       | 15 ++++++---------
  hw/misc/imx6_ccm.c                      |  1 -
  hw/misc/mac_via.c                       |  2 --
  hw/net/e1000e_core.c                    |  4 +---
  hw/net/i82596.c                         |  2 +-
  hw/net/igb_core.c                       |  4 +---
  hw/net/net_rx_pkt.c                     |  3 +--
  hw/net/vmxnet3.c                        |  1 -
  hw/nvme/ctrl.c                          |  8 ++++----
  hw/pci-host/gt64120.c                   |  2 --
  hw/pci/pci-stub.c                       |  6 ++----
  hw/ppc/ppc.c                            |  1 -
  hw/ppc/spapr_events.c                   |  3 +--
  hw/scsi/virtio-scsi.c                   |  1 -
  hw/tpm/tpm_spapr.c                      |  1 -
  hw/watchdog/watchdog.c                  |  2 +-
  migration/dirtyrate.c                   |  3 +--
  migration/migration-hmp-cmds.c          |  2 +-
  migration/postcopy-ram.c                | 21 +++++++--------------
  migration/ram.c                         |  8 +++-----
  qobject/qlit.c                          |  2 +-
  qobject/qnum.c                          | 12 ++++--------
  qom/object.c                            |  1 -
  system/rtc.c                            |  2 +-
  target/arm/hyp_gdbstub.c                |  1 -
  target/i386/kvm/kvm.c                   |  4 ++--
  target/ppc/dfp_helper.c                 |  8 ++++----
  target/ppc/mmu_helper.c                 |  2 +-
  target/riscv/monitor.c                  |  1 -
  tests/qtest/acpi-utils.c                |  1 -
  tests/qtest/ipmi-bt-test.c              |  2 +-
  tests/qtest/ipmi-kcs-test.c             |  4 ++--
  tests/qtest/migration-helpers.c         |  1 -
  tests/qtest/numa-test.c                 | 10 +++++-----
  tests/qtest/rtl8139-test.c              |  2 +-
  tests/unit/test-xs-node.c               |  4 ++--
  ui/qemu-pixman.c                        |  1 -
  fpu/softfloat-parts.c.inc               |  2 --
  target/riscv/insn_trans/trans_rvv.c.inc |  2 --
  tcg/loongarch64/tcg-target.c.inc        |  1 -
  scripts/checkpatch.pl                   |  3 +++
  54 files changed, 72 insertions(+), 120 deletions(-)

--
2.39.2



Which one did you find? Using which grep command?




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux