mbox series

[00/39] Use g_assert_not_reached instead of (g_)assert(0, false)

Message ID 20240910221606.1817478-1-pierrick.bouvier@linaro.org (mailing list archive)
Headers show
Series Use g_assert_not_reached instead of (g_)assert(0, false) | expand

Message

Pierrick Bouvier Sept. 10, 2024, 10:15 p.m. UTC
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@linaro.org/.

In more, cleanup useless break after g_assert_not_reached();

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

Pierrick Bouvier (39):
  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()
  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 +-
 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              |  6 +++---
 hw/hyperv/vmbus.c                       | 12 ++++++------
 hw/misc/imx6_ccm.c                      |  1 -
 hw/misc/mac_via.c                       |  2 --
 hw/net/e1000e_core.c                    |  2 +-
 hw/net/i82596.c                         |  2 +-
 hw/net/igb_core.c                       |  2 +-
 hw/net/net_rx_pkt.c                     |  3 +--
 hw/nvme/ctrl.c                          |  8 ++++----
 hw/pci-host/gt64120.c                   |  2 --
 hw/pci/pci-stub.c                       |  4 ++--
 hw/ppc/spapr_events.c                   |  2 +-
 hw/scsi/virtio-scsi.c                   |  1 -
 hw/tpm/tpm_spapr.c                      |  1 -
 hw/watchdog/watchdog.c                  |  2 +-
 migration/dirtyrate.c                   |  2 +-
 migration/migration-hmp-cmds.c          |  2 +-
 migration/postcopy-ram.c                | 14 +++++++-------
 migration/ram.c                         |  6 +++---
 qobject/qlit.c                          |  2 +-
 qobject/qnum.c                          |  8 ++++----
 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/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 +++
 49 files changed, 72 insertions(+), 90 deletions(-)

Comments

Philippe Mathieu-Daudé Sept. 11, 2024, 8:39 a.m. UTC | #1
On 11/9/24 00:15, Pierrick Bouvier wrote:

> Pierrick Bouvier (39):
>    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()
>    scripts/checkpatch.pl: emit error when using assert(false)

I'm queuing reviewed patches 4,5,7,10,27,28,30,36 so you don't
have to carry them in v2.

Regards,

Phil.
Pierrick Bouvier Sept. 11, 2024, 3:34 p.m. UTC | #2
On 9/11/24 01:39, Philippe Mathieu-Daudé wrote:
> On 11/9/24 00:15, Pierrick Bouvier wrote:
> 
>> Pierrick Bouvier (39):
>>     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()
>>     scripts/checkpatch.pl: emit error when using assert(false)
> 
> I'm queuing reviewed patches 4,5,7,10,27,28,30,36 so you don't
> have to carry them in v2.
> 
> Regards,
> 
> Phil.

Just for the sake of simplicity, and to not miss anything (on my side), 
I'll keep those in v2. When rebasing, once merged on master, they will 
be skipped automatically.

Thanks,
Pierrick