Clean up header guards again
Subsystems (7)
cover Clean up header guards again
Our use of header guards is rather sloppy. Sloppiness there can lead to confusing compilation errors. This series cleans up existing header guards. In particular, it normalizes guard symbols to follow a common pattern, in the hope of making clashes less likely. It doesn't add new header guards. We have more than 300 headers without a recognizable header guard. A few of them are for multiple inclusion, many don't need header guards because they don't do anything but include, but quite a few probably should have one. Left for another day.
Previously cleaned up in merge commit ec11dc41eec (2022), merge commit 01807c8b0e9 (2019), and merge commit ca3d87d4c84 (2016).
Markus Armbruster (5):
scripts/clean-header-guards: Update exclusions Clean up header guards that don't match their file name Clean up ill-advised or unusual header guards Normalize header guard symbol definition
Clean up decorations and whitespace around header guards
accel/accel-internal.h | 2 +- accel/tcg/tb-internal.h | 4 ++-- backends/tpm/tpm_ioctl.h | 7 ++++--- bsd-user/bsd-proc.h | 6 +++--- crypto/akcipherpriv.h | 2 +- crypto/der.h | 2 +- crypto/tlscredsbox.h | 6 +++--- hw/i386/tdvf-hob.h | 4 ++-- hw/net/e1000x_regs.h | 2 +- hw/net/igb_regs.h | 4 ++-- hw/riscv/riscv-iommu-bits.h | 2 +- hw/riscv/riscv-iommu.h | 4 ++-- include/accel/accel-cpu-target.h | 2 +- include/exec/page-protection.h | 5 +++-- include/exec/replay-core.h | 4 ++-- include/exec/target_long.h | 6 +++--- include/exec/tb-flush.h | 7 ++++--- include/exec/tlb-common.h | 3 ++- include/exec/tswap.h | 2 +- include/gdbstub/helpers.h | 6 +++--- include/gdbstub/syscalls.h | 6 +++--- include/hw/acpi/ich9_tco.h | 6 +++--- include/hw/arm/raspberrypi-fw-defs.h | 7 +++---- include/hw/arm/stm32l4x5_soc.h | 4 ++-- include/hw/audio/virtio-snd.h | 4 ++-- include/hw/char/max78000_uart.h | 2 +- include/hw/core/hw-error.h | 4 ++-- include/hw/core/qdev.h | 4 ++-- include/hw/core/sysemu-cpu-ops.h | 6 +++--- include/hw/fsi/fsi-master.h | 3 ++- include/hw/gpio/pcf8574.h | 6 +++--- include/hw/intc/loongarch_extioi_common.h | 2 +- include/hw/intc/loongarch_pic_common.h | 2 +- include/hw/loongarch/virt.h | 4 ++-- include/hw/misc/allwinner-a10-ccm.h | 2 +- include/hw/misc/sifive_e_aon.h | 4 ++-- include/hw/misc/xlnx-cfi-if.h | 3 ++- include/hw/misc/xlnx-versal-cfu.h | 5 +++-- include/hw/net/xlnx-versal-canfd.h | 4 ++-- include/hw/pci-bridge/cxl_upstream_port.h | 7 ++++--- include/hw/pci-host/fsl_imx8m_phy.h | 4 ++-- include/hw/ppc/pnv_n1_chiplet.h | 2 +- include/hw/ppc/pnv_nest_pervasive.h | 6 +++--- include/hw/ssi/pnv_spi_regs.h | 4 ++-- include/hw/virtio/vdpa-dev.h | 5 +++-- include/hw/virtio/vhost-user-gpio.h | 6 +++--- include/hw/virtio/vhost-user-scmi.h | 6 +++--- include/hw/xen/xen-pvh-common.h | 4 ++-- include/io/channel-null.h | 4 ++-- include/qapi/qmp-registry.h | 4 ++-- include/qemu/mem-reentrancy.h | 2 +- include/qemu/target-info-qapi.h | 4 ++-- include/semihosting/uaccess.h | 2 +- include/system/cpu-timers-internal.h | 6 +++--- include/system/dirtylimit.h | 5 +++-- include/system/ioport.h | 2 +- include/system/spdm-socket.h | 4 ++-- include/tcg/insn-start-words.h | 6 +++--- include/tcg/tcg-temp-internal.h | 2 +- include/user/tswap-target.h | 5 +++-- qga/cutils.h | 6 +++--- target/arm/cpu-features.h | 4 ++-- target/arm/tcg/mte_helper.h | 6 +++--- target/hexagon/idef-parser/parser-helpers.h | 2 +- target/i386/confidential-guest.h | 5 +++-- target/i386/emulate/x86.h | 4 ++-- target/i386/emulate/x86_decode.h | 4 ++-- target/i386/emulate/x86_flags.h | 6 +++--- target/i386/kvm/xen-compat.h | 2 +- target/loongarch/cpu-mmu.h | 2 +- target/loongarch/tcg/tcg_loongarch.h | 4 +++- target/riscv/cpu_vendorid.h | 2 +- target/sparc/translate.h | 5 +++-- target/xtensa/core-lx106/core-isa.h | 7 +++---- scripts/clean-header-guards.pl | 5 +++-- 75 files changed, 163 insertions(+), 149 deletions(-)
Signature · 1 line
2.52.0
PATCH 1/5 scripts/clean-header-guards: Update exclusions
Exclude ebpf/rss.bpf.skeleton.h, because it's generated from tools/ebpf/rss.bpf.c.
Exclude include/hw/xen/interface/, because these headers were imported from Xen.
Exclude tests/tracetool/, because these headers are tracetool reference output.
--- scripts/clean-header-guards.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/clean-header-guards.pl +3 -2
@@ -32,8 +32,9 @@ use warnings; use Getopt::Std; # Stuff we don't want to clean because we import it into our tree: -my $exclude = qr,^(include/standard-headers/|linux-headers/ - |pc-bios/|tests/tcg/|tests/multiboot/),x; +my $exclude = qr,^(ebpf/rss.bpf\.skeleton\.h$|include/standard-headers/ + |include/hw/xen/interface/|linux-headers/|pc-bios/|tests/tcg/ + |tests/multiboot/|tests/tracetool/),x; # Stuff that is expected to fail the preprocessing test: my $exclude_cpp = qr,^include/libdecnumber/decNumberLocal.h,;
Signature · 1 line
2.52.0
Re: [PATCH 1/5] scripts/clean-header-guards: Update exclusions
Quoted 6 lines · Markus Armbruster
Exclude
ebpf/rss.bpf.skeleton.h, because it's generated fromtools/ebpf/rss.bpf.c.Exclude
include/hw/xen/interface/, because these headers were imported from Xen.
Quoted 7 lines
Exclude tests/tracetool/, because these headers are tracetool reference output.
Signed-off-by Markus Armbruster <[email protected]>--- scripts/clean-header-guards.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: 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 :|
PATCH 2/5 Clean up header guards that don't match their file name
In reply to Markus ArmbrusterHeader guard symbols should match their file name to make guard collisions less likely.
Cleaned up with scripts/clean-header-guards.pl, followed by some renaming of new guard symbols picked by the script to better ones.
--- accel/accel-internal.h | 2 +- accel/tcg/tb-internal.h | 4 ++-- crypto/tlscredsbox.h | 6 +++--- hw/i386/tdvf-hob.h | 4 ++-- hw/riscv/riscv-iommu.h | 4 ++-- include/exec/page-protection.h | 5 +++-- include/exec/replay-core.h | 4 ++-- include/hw/acpi/ich9_tco.h | 6 +++--- include/hw/audio/virtio-snd.h | 4 ++-- include/hw/core/hw-error.h | 4 ++-- include/hw/core/qdev.h | 4 ++-- include/hw/core/sysemu-cpu-ops.h | 6 +++--- include/hw/loongarch/virt.h | 4 ++-- include/hw/misc/sifive_e_aon.h | 4 ++-- include/hw/misc/xlnx-versal-cfu.h | 5 +++-- include/hw/net/xlnx-versal-canfd.h | 4 ++-- include/hw/pci-bridge/cxl_upstream_port.h | 7 ++++--- include/hw/pci-host/fsl_imx8m_phy.h | 4 ++-- include/hw/ppc/pnv_nest_pervasive.h | 6 +++--- include/hw/ssi/pnv_spi_regs.h | 4 ++-- include/hw/virtio/vdpa-dev.h | 5 +++-- include/io/channel-null.h | 4 ++-- include/qapi/qmp-registry.h | 4 ++-- include/qemu/target-info-qapi.h | 4 ++-- include/system/cpu-timers-internal.h | 6 +++--- include/system/dirtylimit.h | 5 +++-- include/system/spdm-socket.h | 4 ++-- include/user/tswap-target.h | 5 +++-- target/arm/cpu-features.h | 4 ++-- target/arm/tcg/mte_helper.h | 6 +++--- target/i386/confidential-guest.h | 5 +++-- target/i386/emulate/x86.h | 4 ++-- target/i386/emulate/x86_decode.h | 4 ++-- target/i386/emulate/x86_flags.h | 6 +++--- target/sparc/translate.h | 5 +++-- target/xtensa/core-lx106/core-isa.h | 7 +++---- 36 files changed, 88 insertions(+), 81 deletions(-)
accel/accel-internal.h +1 -1
@@ -14,4 +14,4 @@void accel_init_ops_interfaces (AccelClass *ac); -#endif /* ACCEL_SYSTEM_H */ +#endif /* ACCEL_INTERNAL_H */
accel/tcg/tb-internal.h +2 -2
@@ -6,8 +6,8 @@* SPDX-License-Identifier: LGPL-2.1-or-later */ -#ifndef ACCEL_TCG_TB_INTERNAL_TARGET_H -#define ACCEL_TCG_TB_INTERNAL_TARGET_H +#ifndef ACCEL_TCG_TB_INTERNAL_H +#define ACCEL_TCG_TB_INTERNAL_H #include "exec/translation-block.h"
crypto/tlscredsbox.h +3 -3
@@ -6,8 +6,8 @@* Copyright (c) 2025 Red Hat, Inc. */ -#ifndef QCRYPTO_TLSCREDS_BOX_H -#define QCRYPTO_TLSCREDS_BOX_H +#ifndef QCRYPTO_TLSCREDSBOX_H +#define QCRYPTO_TLSCREDSBOX_H #include "qom/object.h"
@@ -47,4 +47,4 @@ void qcrypto_tls_creds_box_unref(QCryptoTLSCredsBox *credsbox);G_DEFINE_AUTOPTR_CLEANUP_FUNC (QCryptoTLSCredsBox, qcrypto_tls_creds_box_unref); -#endif /* QCRYPTO_TLSCREDS_BOX_H */ +#endif /* QCRYPTO_TLSCREDSBOX_H */
hw/i386/tdvf-hob.h +2 -2
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef HW_I386_TD_HOB_H -#define HW_I386_TD_HOB_H +#ifndef HW_I386_TDVF_HOB_H +#define HW_I386_TDVF_HOB_H #include "hw/i386/tdvf.h" #include "target/i386/kvm/tdx.h"
hw/riscv/riscv-iommu.h +2 -2
@@ -16,8 +16,8 @@* with this program; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef HW_RISCV_IOMMU_STATE_H -#define HW_RISCV_IOMMU_STATE_H +#ifndef HW_RISCV_IOMMU_H +#define HW_RISCV_IOMMU_H #include "qom/object.h" #include "hw/core/qdev-properties.h"
include/exec/page-protection.h +3 -2
@@ -5,8 +5,9 @@* * SPDX-License-Identifier: LGPL-2.1+ */ -#ifndef EXEC_PAGE_PROT_COMMON_H -#define EXEC_PAGE_PROT_COMMON_H + +#ifndef EXEC_PAGE_PROTECTION_H +#define EXEC_PAGE_PROTECTION_H /* same as PROT_xxx */ #define PAGE_READ 0x0001
include/exec/replay-core.h +2 -2
@@ -8,8 +8,8 @@* See the COPYING file in the top-level directory. */ -#ifndef EXEC_REPLAY_H -#define EXEC_REPLAY_H +#ifndef EXEC_REPLAY_CORE_H +#define EXEC_REPLAY_CORE_H #include "qapi/qapi-types-replay.h"
include/hw/acpi/ich9_tco.h +3 -3
@@ -7,8 +7,8 @@* See the COPYING file in the top-level directory. */ -#ifndef HW_ACPI_TCO_H -#define HW_ACPI_TCO_H +#ifndef HW_ACPI_ICH9_TCO_H +#define HW_ACPI_ICH9_TCO_H #include "system/memory.h" #include "migration/vmstate.h"
@@ -80,4 +80,4 @@ void acpi_pm_tco_init(TCOIORegs *tr, MemoryRegion *parent);extern const VMStateDescription vmstate_tco_io_sts; -#endif /* HW_ACPI_TCO_H */ +#endif /* HW_ACPI_ICH9_TCO_H */
include/hw/audio/virtio-snd.h +2 -2
@@ -13,8 +13,8 @@* top-level directory. */ -#ifndef QEMU_VIRTIO_SOUND_H -#define QEMU_VIRTIO_SOUND_H +#ifndef HW_AUDIO_VIRTIO_SND_H +#define HW_AUDIO_VIRTIO_SND_H #include "hw/virtio/virtio.h" #include "qemu/audio.h"
include/hw/core/hw-error.h +2 -2
@@ -1,5 +1,5 @@ -#ifndef QEMU_HW_H -#define QEMU_HW_H +#ifndef HW_CORE_HW_ERROR_H +#define HW_CORE_HW_ERROR_H G_NORETURN void hw_error(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
include/hw/core/qdev.h +2 -2
@@ -1,5 +1,5 @@ -#ifndef QDEV_CORE_H -#define QDEV_CORE_H +#ifndef HW_CORE_QDEV_H +#define HW_CORE_QDEV_H #include "qemu/atomic.h" #include "qemu/queue.h"
include/hw/core/sysemu-cpu-ops.h +3 -3
@@ -7,8 +7,8 @@* See the COPYING file in the top-level directory. */ -#ifndef SYSTEM_CPU_OPS_H -#define SYSTEM_CPU_OPS_H +#ifndef HW_CORE_SYSEMU_CPU_OPS_H +#define HW_CORE_SYSEMU_CPU_OPS_H #include "hw/core/cpu.h"
@@ -93,4 +93,4 @@ typedef struct SysemuCPUOps { } SysemuCPUOps; -#endif /* SYSTEM_CPU_OPS_H */ +#endif /* HW_CORE_SYSEMU_CPU_OPS_H */
include/hw/loongarch/virt.h +2 -2
@@ -5,8 +5,8 @@* Copyright (C) 2021 Loongson Technology Corporation Limited */ -#ifndef HW_LOONGARCH_H -#define HW_LOONGARCH_H +#ifndef HW_LOONGARCH_VIRT_H +#define HW_LOONGARCH_VIRT_H #include "hw/core/boards.h" #include "qemu/queue.h"
include/hw/misc/sifive_e_aon.h +2 -2
@@ -16,8 +16,8 @@* this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef HW_SIFIVE_AON_H -#define HW_SIFIVE_AON_H +#ifndef HW_SIFIVE_E_AON_H +#define HW_SIFIVE_E_AON_H #include "hw/core/sysbus.h" #include "qom/object.h"
include/hw/misc/xlnx-versal-cfu.h +3 -2
@@ -14,8 +14,9 @@* [2] Versal ACAP Register Reference, * https://docs.xilinx.com/r/en-US/am012-versal-register-reference/CFU_CSR-Module */ -#ifndef HW_MISC_XLNX_VERSAL_CFU_APB_H -#define HW_MISC_XLNX_VERSAL_CFU_APB_H + +#ifndef HW_MISC_XLNX_VERSAL_CFU_H +#define HW_MISC_XLNX_VERSAL_CFU_H #include "hw/core/sysbus.h" #include "hw/core/register.h"
include/hw/net/xlnx-versal-canfd.h +2 -2
@@ -25,8 +25,8 @@* THE SOFTWARE. */ -#ifndef HW_CANFD_XILINX_H -#define HW_CANFD_XILINX_H +#ifndef HW_NET_XLNX_VERSAL_CANFD_H +#define HW_NET_XLNX_VERSAL_CANFD_H #include "hw/core/register.h" #include "hw/core/ptimer.h"
include/hw/pci-bridge/cxl_upstream_port.h +4 -3
@@ -1,6 +1,7 @@ -#ifndef CXL_USP_H -#define CXL_USP_H +#ifndef HW_PCI_BRIDGE_CXL_UPSTREAM_PORT_H +#define HW_PCI_BRIDGE_CXL_UPSTREAM_PORT_H +#include "hw/pci/pcie.h" #include "hw/pci/pcie_port.h" #include "hw/cxl/cxl.h"
@@ -20,4 +21,4 @@ typedef struct CXLUpstreamPort { uint64_t sn; } CXLUpstreamPort; -#endif /* CXL_SUP_H */ +#endif /* HW_PCI_BRIDGE_CXL_UPSTREAM_PORT_H */
include/hw/pci-host/fsl_imx8m_phy.h +2 -2
@@ -6,8 +6,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef HW_PCIHOST_FSLIMX8MPCIEPHY_H -#define HW_PCIHOST_FSLIMX8MPCIEPHY_H +#ifndef HW_PCI_HOST_FSL_IMX8M_PHY_H +#define HW_PCI_HOST_FSL_IMX8M_PHY_H #include "hw/core/sysbus.h" #include "qom/object.h"
include/hw/ppc/pnv_nest_pervasive.h +3 -3
@@ -6,8 +6,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef PPC_PNV_NEST_CHIPLET_PERVASIVE_H -#define PPC_PNV_NEST_CHIPLET_PERVASIVE_H +#ifndef HW_PPC_PNV_NEST_PERVASIVE_H +#define HW_PPC_PNV_NEST_PERVASIVE_H #define TYPE_PNV_NEST_CHIPLET_PERVASIVE "pnv-nest-chiplet-pervasive"#define PNV_NEST_CHIPLET_PERVASIVE (obj) OBJECT_CHECK(PnvNestChipletPervasive, (obj), TYPE_PNV_NEST_CHIPLET_PERVASIVE)
@@ -29,4 +29,4 @@ typedef struct PnvNestChipletPervasive { PnvPervasiveCtrlRegs control_regs; } PnvNestChipletPervasive; -#endif /*PPC_PNV_NEST_CHIPLET_PERVASIVE_H */ +#endif /* HW_PPC_PNV_NEST_PERVASIVE_H */
include/hw/ssi/pnv_spi_regs.h +2 -2
@@ -6,8 +6,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef PNV_SPI_CONTROLLER_REGS_H -#define PNV_SPI_CONTROLLER_REGS_H +#ifndef HW_SSI_PNV_SPI_REGS_H +#define HW_SSI_PNV_SPI_REGS_H /* * Macros from target/ppc/cpu.h
include/hw/virtio/vdpa-dev.h +3 -2
@@ -12,8 +12,9 @@* This work is licensed under the terms of the GNU LGPL, version 2 or later. * See the COPYING.LIB file in the top-level directory. */ -#ifndef _VHOST_VDPA_DEVICE_H -#define _VHOST_VDPA_DEVICE_H + +#ifndef HW_VIRTIO_VDPA_DEV_H +#define HW_VIRTIO_VDPA_DEV_H #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-vdpa.h"
include/io/channel-null.h +2 -2
@@ -18,8 +18,8 @@* */ -#ifndef QIO_CHANNEL_FILE_H -#define QIO_CHANNEL_FILE_H +#ifndef QIO_CHANNEL_NULL_H +#define QIO_CHANNEL_NULL_H #include "io/channel.h" #include "qom/object.h"
include/qapi/qmp-registry.h +2 -2
@@ -11,8 +11,8 @@* */ -#ifndef QAPI_QMP_DISPATCH_H -#define QAPI_QMP_DISPATCH_H +#ifndef QAPI_QMP_REGISTRY_H +#define QAPI_QMP_REGISTRY_H #include "monitor/monitor.h" #include "qemu/queue.h"
include/qemu/target-info-qapi.h +2 -2
@@ -6,8 +6,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef QEMU_TARGET_INFO_EXTRA_H -#define QEMU_TARGET_INFO_EXTRA_H +#ifndef QEMU_TARGET_INFO_QAPI_H +#define QEMU_TARGET_INFO_QAPI_H #include "qapi/qapi-types-common.h" #include "qapi/qapi-types-machine.h"
include/system/cpu-timers-internal.h +3 -3
@@ -22,8 +22,8 @@* THE SOFTWARE. */ -#ifndef TIMERS_STATE_H -#define TIMERS_STATE_H +#ifndef SYSTEM_CPU_TIMERS_INTERNAL_H +#define SYSTEM_CPU_TIMERS_INTERNAL_H /* timers state, for sharing between icount and cpu-timers */
@@ -68,4 +68,4 @@ extern TimersState timers_state;*/ int64_t cpu_get_clock_locked (void ); -#endif /* TIMERS_STATE_H */ +#endif /* SYSTEM_CPU_TIMERS_INTERNAL_H */
include/system/dirtylimit.h +3 -2
@@ -9,8 +9,9 @@* This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ -#ifndef QEMU_DIRTYRLIMIT_H -#define QEMU_DIRTYRLIMIT_H + +#ifndef SYSTEM_DIRTYLIMIT_H +#define SYSTEM_DIRTYLIMIT_H #define DIRTYLIMIT_CALC_TIME_MS 1000/* 1000ms */
include/system/spdm-socket.h +2 -2
@@ -20,8 +20,8 @@* THE SOFTWARE. */ -#ifndef SPDM_REQUESTER_H -#define SPDM_REQUESTER_H +#ifndef SYSTEM_SPDM_SOCKET_H +#define SYSTEM_SPDM_SOCKET_H /** * spdm_socket_connect: connect to an external SPDM socket
include/user/tswap-target.h +3 -2
@@ -5,8 +5,9 @@* * SPDX-License-Identifier: LGPL-2.1-or-later */ -#ifndef USER_TSWAP_H -#define USER_TSWAP_H + +#ifndef USER_TSWAP_TARGET_H +#define USER_TSWAP_TARGET_H #include "exec/cpu-defs.h" #include "exec/tswap.h"
target/arm/cpu-features.h +2 -2
@@ -17,8 +17,8 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef TARGET_ARM_FEATURES_H -#define TARGET_ARM_FEATURES_H +#ifndef TARGET_ARM_CPU_FEATURES_H +#define TARGET_ARM_CPU_FEATURES_H #include "hw/core/registerfields.h" #include "qemu/host-utils.h"
target/arm/tcg/mte_helper.h +3 -3
@@ -6,8 +6,8 @@* SPDX-License-Identifier: LGPL-2.1-or-later */ -#ifndef TARGET_ARM_MTE_H -#define TARGET_ARM_MTE_H +#ifndef TARGET_ARM_TCG_MTE_HELPER_H +#define TARGET_ARM_TCG_MTE_HELPER_H #include "exec/mmu-access-type.h"
@@ -63,4 +63,4 @@ int load_tag1(uint64_t ptr, uint8_t *mem);*/ void store_tag1 (uint64_t ptr,uint8_t *mem,int tag); -#endif /* TARGET_ARM_MTE_H */ +#endif /* TARGET_ARM_TCG_MTE_HELPER_H */
target/i386/confidential-guest.h +3 -2
@@ -9,8 +9,9 @@* This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ -#ifndef TARGET_I386_CG_H -#define TARGET_I386_CG_H + +#ifndef TARGET_I386_CONFIDENTIAL_GUEST_H +#define TARGET_I386_CONFIDENTIAL_GUEST_H #include "qom/object.h"
target/i386/emulate/x86.h +2 -2
@@ -16,8 +16,8 @@* License along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef X86_EMU_DEFS_H -#define X86_EMU_DEFS_H +#ifndef TARGET_I386_EMULATE_X86_H +#define TARGET_I386_EMULATE_X86_H typedef struct x86_register { union {
target/i386/emulate/x86_decode.h +2 -2
@@ -15,8 +15,8 @@* License along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef X86_EMU_DECODE_H -#define X86_EMU_DECODE_H +#ifndef TARGET_I386_EMULATE_X86_DECODE_H +#define TARGET_I386_EMULATE_X86_DECODE_H #include "cpu.h" #include "x86.h"
target/i386/emulate/x86_flags.h +3 -3
@@ -21,8 +21,8 @@* x86 eflags functions */ -#ifndef X86_EMU_FLAGS_H -#define X86_EMU_FLAGS_H +#ifndef TARGET_I386_EMULATE_X86_FLAGS_H +#define TARGET_I386_EMULATE_X86_FLAGS_H #include "cpu.h" void lflags_to_rflags (CPUX86State *env);
@@ -68,4 +68,4 @@ void SET_FLAGS_OSZAPC_LOGIC16(CPUX86State *env, uint16_t v1, uint16_t v2,void SET_FLAGS_OSZAPC_LOGIC8 (CPUX86State *env,uint8_t v1,uint8_t v2,uint8_t diff); -#endif /* X86_EMU_FLAGS_H */ +#endif /* TARGET_I386_EMULATE_X86_FLAGS_H */
target/sparc/translate.h +3 -2
@@ -4,8 +4,9 @@* Copyright (c) 2024 Linaro, Ltd * SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef SPARC_TRANSLATION_H -#define SPARC_TRANSLATION_H + +#ifndef SPARC_TRANSLATE_H +#define SPARC_TRANSLATE_H /* Dynamic PC, must exit to main loop. */ #define DYNAMIC_PC 1
target/xtensa/core-lx106/core-isa.h +3 -4
@@ -28,9 +28,8 @@TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef _XTENSA_CORE_CONFIGURATION_H -#define _XTENSA_CORE_CONFIGURATION_H - +#ifndef XTENSA_CORE_LX106_CORE_ISA_H +#define XTENSA_CORE_LX106_CORE_ISA_H /**************************************************************************** Parameters Useful for Any Code, USER or PRIVILEGED
@@ -466,5 +465,5 @@#endif /* !XTENSA_HAL_NON_PRIVILEGED_ONLY */ -#endif /* _XTENSA_CORE_CONFIGURATION_H */ +#endif /* XTENSA_CORE_LX106_CORE_ISA_H */
Signature · 1 line
2.52.0
Re: [PATCH 2/5] Clean up header guards that don't match their file name
Quoted 37 lines · Markus Armbruster
Header guard symbols should match their file name to make guard collisions less likely.
Cleaned up with
scripts/clean-header-guards.pl, followed by some renaming of new guard symbols picked by the script to better ones.Signed-off-by Markus Armbruster <[email protected]>--- accel/accel-internal.h | 2 +- accel/tcg/tb-internal.h | 4 ++-- crypto/tlscredsbox.h | 6 +++--- hw/i386/tdvf-hob.h | 4 ++-- hw/riscv/riscv-iommu.h | 4 ++-- include/exec/page-protection.h | 5 +++-- include/exec/replay-core.h | 4 ++-- include/hw/acpi/ich9_tco.h | 6 +++--- include/hw/audio/virtio-snd.h | 4 ++-- include/hw/core/hw-error.h | 4 ++-- include/hw/core/qdev.h | 4 ++-- include/hw/core/sysemu-cpu-ops.h | 6 +++--- include/hw/loongarch/virt.h | 4 ++-- include/hw/misc/sifive_e_aon.h | 4 ++-- include/hw/misc/xlnx-versal-cfu.h | 5 +++-- include/hw/net/xlnx-versal-canfd.h | 4 ++-- include/hw/pci-bridge/cxl_upstream_port.h | 7 ++++--- include/hw/pci-host/fsl_imx8m_phy.h | 4 ++-- include/hw/ppc/pnv_nest_pervasive.h | 6 +++--- include/hw/ssi/pnv_spi_regs.h | 4 ++-- include/hw/virtio/vdpa-dev.h | 5 +++-- include/io/channel-null.h | 4 ++-- include/qapi/qmp-registry.h | 4 ++-- include/qemu/target-info-qapi.h | 4 ++-- include/system/cpu-timers-internal.h | 6 +++--- include/system/dirtylimit.h | 5 +++-- include/system/spdm-socket.h | 4 ++-- include/user/tswap-target.h | 5 +++-- target/arm/cpu-features.h | 4 ++--
Quoted 8 lines
target/arm/tcg/mte_helper.h | 6 +++--- target/i386/confidential-guest.h | 5 +++-- target/i386/emulate/x86.h | 4 ++-- target/i386/emulate/x86_decode.h | 4 ++-- target/i386/emulate/x86_flags.h | 6 +++--- target/sparc/translate.h | 5 +++-- target/xtensa/core-lx106/core-isa.h | 7 +++---- 36 files changed, 88 insertions(+), 81 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: 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 :|
PATCH 3/5 Clean up ill-advised or unusual header guards
In reply to Markus ArmbrusterLeading underscores are ill-advised because such identifiers are reserved. Trailing underscores are merely ugly. Strip both.
Our header guards commonly end in _H. Normalize the exceptions.
Macros should be ALL_CAPS. Normalize the exception.
Done with scripts/clean-header-guards.pl.
--- backends/tpm/tpm_ioctl.h | 7 ++++--- bsd-user/bsd-proc.h | 6 +++--- hw/net/igb_regs.h | 4 ++-- include/exec/target_long.h | 6 +++--- include/exec/tb-flush.h | 7 ++++--- include/gdbstub/helpers.h | 6 +++--- include/gdbstub/syscalls.h | 6 +++--- include/hw/arm/raspberrypi-fw-defs.h | 7 +++---- include/hw/arm/stm32l4x5_soc.h | 4 ++-- include/hw/gpio/pcf8574.h | 6 +++--- include/hw/virtio/vhost-user-gpio.h | 6 +++--- include/hw/virtio/vhost-user-scmi.h | 6 +++--- include/hw/xen/xen-pvh-common.h | 4 ++-- include/tcg/insn-start-words.h | 6 +++--- qga/cutils.h | 6 +++--- 15 files changed, 44 insertions(+), 43 deletions(-)
backends/tpm/tpm_ioctl.h +4 -3
@@ -5,8 +5,9 @@* * This file is licensed under the terms of the 3-clause BSD license */ -#ifndef _TPM_IOCTL_H_ -#define _TPM_IOCTL_H_ + +#ifndef TPM_IOCTL_H +#define TPM_IOCTL_H #if defined(__CYGWIN__)# define __USE_LINUX_IOCTL_DEFS
@@ -341,4 +342,4 @@ enum { CMD_LOCK_STORAGE, /* 0x13 */ }; -#endif /* _TPM_IOCTL_H_ */ +#endif /* TPM_IOCTL_H */
bsd-user/bsd-proc.h +3 -3
@@ -17,8 +17,8 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef BSD_PROC_H_ -#define BSD_PROC_H_ +#ifndef BSD_PROC_H +#define BSD_PROC_H #include <sys/resource.h>
@@ -411,4 +411,4 @@ static inline abi_long do_bsd_setpriority(abi_long which, abi_long who, return get_errno(setpriority(which, who, prio)); } -#endif /* !BSD_PROC_H_ */ +#endif /* BSD_PROC_H */
hw/net/igb_regs.h +2 -2
@@ -4,8 +4,8 @@* drivers/net/ethernet/intel/igb */ -#ifndef HW_IGB_REGS_H_ -#define HW_IGB_REGS_H_ +#ifndef HW_IGB_REGS_H +#define HW_IGB_REGS_H #include "e1000x_regs.h"
include/exec/target_long.h +3 -3
@@ -7,8 +7,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _TARGET_LONG_H_ -#define _TARGET_LONG_H_ +#ifndef TARGET_LONG_H +#define TARGET_LONG_H /* * Usually this should only be included via cpu-defs.h however for
@@ -41,4 +41,4 @@ typedef uint64_t target_ulong;#error TARGET_LONG_SIZE undefined#endif -#endif /* _TARGET_LONG_H_ */ +#endif /* TARGET_LONG_H */
include/exec/tb-flush.h +4 -3
@@ -5,8 +5,9 @@* * SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _TB_FLUSH_H_ -#define _TB_FLUSH_H_ + +#ifndef TB_FLUSH_H +#define TB_FLUSH_H /** * tb_flush__exclusive_or_serial()
@@ -35,4 +36,4 @@ void queue_tb_flush(CPUState *cs);void tcg_flush_jmp_cache (CPUState *cs); -#endif /* _TB_FLUSH_H_ */ +#endif /* TB_FLUSH_H */
include/gdbstub/helpers.h +3 -3
@@ -9,8 +9,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _GDBSTUB_HELPERS_H_ -#define _GDBSTUB_HELPERS_H_ +#ifndef GDBSTUB_HELPERS_H +#define GDBSTUB_HELPERS_H #include "qemu/bswap.h" #include "qemu/target-info.h"
@@ -115,4 +115,4 @@ static inline uint8_t *gdb_get_reg_ptr(GByteArray *buf, int len)#endif #endif /* COMPILING_PER_TARGET */ -#endif /* _GDBSTUB_HELPERS_H_ */ +#endif /* GDBSTUB_HELPERS_H */
include/gdbstub/syscalls.h +3 -3
@@ -6,8 +6,8 @@* SPDX-License-Identifier: LGPL-2.0-or-later */ -#ifndef _SYSCALLS_H_ -#define _SYSCALLS_H_ +#ifndef SYSCALLS_H +#define SYSCALLS_H /* For gdb file i/o remote protocol open flags. */ #define GDB_O_RDONLY 0
@@ -119,4 +119,4 @@ void gdb_exit(int code);*/ void gdb_qemu_exit (int code); -#endif /* _SYSCALLS_H_ */ +#endif /* SYSCALLS_H */
include/hw/arm/raspberrypi-fw-defs.h +3 -4
@@ -7,9 +7,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_ -#define INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_ - +#ifndef INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H +#define INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H enum rpi_firmware_property_tag { RPI_FWREQ_PROPERTY_END = 0,
@@ -172,4 +171,4 @@ typedef struct rpi_firmware_prop_request { uint8_t payload[0]; } rpi_firmware_prop_request_t; -#endif /* INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_ */ +#endif /* INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H */
include/hw/arm/stm32l4x5_soc.h +2 -2
@@ -21,8 +21,8 @@* https://www.st.com/en/microcontrollers-microprocessors/stm32l4x5/documentation.html */ -#ifndef HW_ARM_STM32L4x5_SOC_H -#define HW_ARM_STM32L4x5_SOC_H +#ifndef HW_ARM_STM32L4X5_SOC_H +#define HW_ARM_STM32L4X5_SOC_H #include "system/memory.h" #include "hw/arm/armv7m.h"
include/hw/gpio/pcf8574.h +3 -3
@@ -7,9 +7,9 @@* Written by Dmitrii Sharikhin <[email protected]> */ -#ifndef _HW_GPIO_PCF8574 -#define _HW_GPIO_PCF8574 +#ifndef HW_GPIO_PCF8574_H +#define HW_GPIO_PCF8574_H #define TYPE_PCF8574 "pcf8574" -#endif /* _HW_GPIO_PCF8574 */ +#endif /* HW_GPIO_PCF8574_H */
include/hw/virtio/vhost-user-gpio.h +3 -3
@@ -6,8 +6,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _QEMU_VHOST_USER_GPIO_H -#define _QEMU_VHOST_USER_GPIO_H +#ifndef QEMU_VHOST_USER_GPIO_H +#define QEMU_VHOST_USER_GPIO_H #include "hw/virtio/virtio.h" #include "hw/virtio/vhost.h"
@@ -21,4 +21,4 @@ struct VHostUserGPIO { VHostUserBase parent_obj; }; -#endif /* _QEMU_VHOST_USER_GPIO_H */ +#endif /* QEMU_VHOST_USER_GPIO_H */
include/hw/virtio/vhost-user-scmi.h +3 -3
@@ -6,8 +6,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _QEMU_VHOST_USER_SCMI_H -#define _QEMU_VHOST_USER_SCMI_H +#ifndef QEMU_VHOST_USER_SCMI_H +#define QEMU_VHOST_USER_SCMI_H #include "hw/virtio/virtio.h" #include "hw/virtio/vhost.h"
@@ -28,4 +28,4 @@ struct VHostUserSCMI { bool started_vu; }; -#endif /* _QEMU_VHOST_USER_SCMI_H */ +#endif /* QEMU_VHOST_USER_SCMI_H */
include/hw/xen/xen-pvh-common.h +2 -2
@@ -6,8 +6,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef XEN_PVH_COMMON_H__ -#define XEN_PVH_COMMON_H__ +#ifndef XEN_PVH_COMMON_H +#define XEN_PVH_COMMON_H #include "system/memory.h" #include "qom/object.h"
include/tcg/insn-start-words.h +3 -3
@@ -4,9 +4,9 @@* Copyright (c) 2008 Fabrice Bellard */ -#ifndef TCG_INSN_START_WORDS -#define TCG_INSN_START_WORDS +#ifndef TCG_INSN_START_WORDS_H +#define TCG_INSN_START_WORDS_H #define INSN_START_WORDS 3 -#endif /* TCG_INSN_START_WORDS */ +#endif /* TCG_INSN_START_WORDS_H */
qga/cutils.h +3 -3
@@ -1,6 +1,6 @@ -#ifndef CUTILS_H_ -#define CUTILS_H_ +#ifndef CUTILS_H +#define CUTILS_H int qga_open_cloexec (const char *name,int flags,mode_t mode); -#endif /* CUTILS_H_ */ +#endif /* CUTILS_H */
Signature · 1 line
2.52.0
Re: [PATCH 3/5] Clean up ill-advised or unusual header guards
Quoted 19 lines · Markus Armbruster
Leading underscores are ill-advised because such identifiers are reserved. Trailing underscores are merely ugly. Strip both.
Our header guards commonly end in _H. Normalize the exceptions.
Macros should be
ALL_CAPS. Normalize the exception.Done with
scripts/clean-header-guards.pl.Signed-off-by Markus Armbruster <[email protected]>--- backends/tpm/tpm_ioctl.h | 7 ++++--- bsd-user/bsd-proc.h | 6 +++--- hw/net/igb_regs.h | 4 ++-- include/exec/target_long.h | 6 +++--- include/exec/tb-flush.h | 7 ++++--- include/gdbstub/helpers.h | 6 +++--- include/gdbstub/syscalls.h | 6 +++--- include/hw/arm/raspberrypi-fw-defs.h | 7 +++----
Quoted 8 lines
include/hw/arm/stm32l4x5_soc.h | 4 ++-- include/hw/gpio/pcf8574.h | 6 +++--- include/hw/virtio/vhost-user-gpio.h | 6 +++--- include/hw/virtio/vhost-user-scmi.h | 6 +++--- include/hw/xen/xen-pvh-common.h | 4 ++-- include/tcg/insn-start-words.h | 6 +++--- qga/cutils.h | 6 +++--- 15 files changed, 44 insertions(+), 43 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: 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 :|
Re: [PATCH 3/5] Clean up ill-advised or unusual header guards
In reply to Markus ArmbrusterThe bsd-user header
Seems like needless churn, though. Better to use #pragma once everywhere instead. There's no varadic include files in the tree as far as I recall...
Warner
Quoted 327 lines · Markus Armbruster
Leading underscores are ill-advised because such identifiers are reserved. Trailing underscores are merely ugly. Strip both.
Our header guards commonly end in _H. Normalize the exceptions.
Macros should be
ALL_CAPS. Normalize the exception.Done with
scripts/clean-header-guards.pl.Signed-off-by Markus Armbruster <[email protected]>--- backends/tpm/tpm_ioctl.h | 7 ++++--- bsd-user/bsd-proc.h | 6 +++--- hw/net/igb_regs.h | 4 ++-- include/exec/target_long.h | 6 +++--- include/exec/tb-flush.h | 7 ++++--- include/gdbstub/helpers.h | 6 +++--- include/gdbstub/syscalls.h | 6 +++--- include/hw/arm/raspberrypi-fw-defs.h | 7 +++---- include/hw/arm/stm32l4x5_soc.h | 4 ++-- include/hw/gpio/pcf8574.h | 6 +++--- include/hw/virtio/vhost-user-gpio.h | 6 +++--- include/hw/virtio/vhost-user-scmi.h | 6 +++--- include/hw/xen/xen-pvh-common.h | 4 ++-- include/tcg/insn-start-words.h | 6 +++--- qga/cutils.h | 6 +++--- 15 files changed, 44 insertions(+), 43 deletions(-)backends/tpm/tpm_ioctl.h +4
-3@@ -5,8 +5,9 @@* * This file is licensed under the terms of the 3-clause BSD license */ -#ifndef _TPM_IOCTL_H_ -#define _TPM_IOCTL_H_ + +#ifndef TPM_IOCTL_H +#define TPM_IOCTL_H #if defined(__CYGWIN__)# define __USE_LINUX_IOCTL_DEFS@@ -341,4 +342,4 @@ enum { CMD_LOCK_STORAGE, /* 0x13 */ }; -#endif /* _TPM_IOCTL_H_ */ +#endif /* TPM_IOCTL_H */ bsd-user/bsd-proc.h +3
-3@@ -17,8 +17,8 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#ifndef BSD_PROC_H_ -#define BSD_PROC_H_ +#ifndef BSD_PROC_H +#define BSD_PROC_H #include <sys/resource.h> @@ -411,4 +411,4 @@ static inline abi_long do_bsd_setpriority(abi_long which, abi_long who, return get_errno(setpriority(which, who, prio)); } -#endif /* !BSD_PROC_H_ */ +#endif /* BSD_PROC_H */ hw/net/igb_regs.h +2
-2@@ -4,8 +4,8 @@* drivers/net/ethernet/intel/igb */ -#ifndef HW_IGB_REGS_H_ -#define HW_IGB_REGS_H_ +#ifndef HW_IGB_REGS_H +#define HW_IGB_REGS_H #include "e1000x_regs.h" include/exec/target_long.h +3
-3@@ -7,8 +7,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _TARGET_LONG_H_ -#define _TARGET_LONG_H_ +#ifndef TARGET_LONG_H +#define TARGET_LONG_H /* * Usually this should only be included via cpu-defs.h however for @@ -41,4 +41,4 @@ typedef uint64_t target_ulong;#error TARGET_LONG_SIZE undefined#endif -#endif /* _TARGET_LONG_H_ */ +#endif /* TARGET_LONG_H */ include/exec/tb-flush.h +4
-3@@ -5,8 +5,9 @@* * SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _TB_FLUSH_H_ -#define _TB_FLUSH_H_ + +#ifndef TB_FLUSH_H +#define TB_FLUSH_H /** * tb_flush__exclusive_or_serial() @@ -35,4 +36,4 @@ void queue_tb_flush(CPUState *cs);void tcg_flush_jmp_cache (CPUState *cs); -#endif /* _TB_FLUSH_H_ */ +#endif /* TB_FLUSH_H */ include/gdbstub/helpers.h +3
-3@@ -9,8 +9,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _GDBSTUB_HELPERS_H_ -#define _GDBSTUB_HELPERS_H_ +#ifndef GDBSTUB_HELPERS_H +#define GDBSTUB_HELPERS_H #include "qemu/bswap.h" #include "qemu/target-info.h" @@ -115,4 +115,4 @@ static inline uint8_t *gdb_get_reg_ptr(GByteArray *buf, int len)#endif #endif /* COMPILING_PER_TARGET */ -#endif /* _GDBSTUB_HELPERS_H_ */ +#endif /* GDBSTUB_HELPERS_H */ include/gdbstub/syscalls.h +3
-3@@ -6,8 +6,8 @@* SPDX-License-Identifier: LGPL-2.0-or-later */ -#ifndef _SYSCALLS_H_ -#define _SYSCALLS_H_ +#ifndef SYSCALLS_H +#define SYSCALLS_H /* For gdb file i/o remote protocol open flags. */ #define GDB_O_RDONLY 0@@ -119,4 +119,4 @@ void gdb_exit(int code);*/ void gdb_qemu_exit (int code); -#endif /* _SYSCALLS_H_ */ +#endif /* SYSCALLS_H */ include/hw/arm/raspberrypi-fw-defs.h +3
-4@@ -7,9 +7,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_ -#define INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_ - +#ifndef INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H +#define INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H enum rpi_firmware_property_tag { RPI_FWREQ_PROPERTY_END = 0,@@ -172,4 +171,4 @@ typedef struct rpi_firmware_prop_request { uint8_t payload[0]; } rpi_firmware_prop_request_t; -#endif /* INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_ */ +#endif /* INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H */ include/hw/arm/stm32l4x5_soc.h +0
-0@@ -21,8 +21,8 @@* https://www.st.com/en/microcontrollers-microprocessors/stm32l4x5/documentation.html
*/include/hw/arm/stm32l4x5_soc.h +2
-2-#ifndef HW_ARM_STM32L4x5_SOC_H -#define HW_ARM_STM32L4x5_SOC_H +#ifndef HW_ARM_STM32L4X5_SOC_H +#define HW_ARM_STM32L4X5_SOC_H #include "system/memory.h" #include "hw/arm/armv7m.h" include/hw/gpio/pcf8574.h +3
-3@@ -7,9 +7,9 @@* Written by Dmitrii Sharikhin <[email protected]> */ -#ifndef _HW_GPIO_PCF8574 -#define _HW_GPIO_PCF8574 +#ifndef HW_GPIO_PCF8574_H +#define HW_GPIO_PCF8574_H #define TYPE_PCF8574 "pcf8574" -#endif /* _HW_GPIO_PCF8574 */ +#endif /* HW_GPIO_PCF8574_H */ include/hw/virtio/vhost-user-gpio.h +3
-3@@ -6,8 +6,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _QEMU_VHOST_USER_GPIO_H -#define _QEMU_VHOST_USER_GPIO_H +#ifndef QEMU_VHOST_USER_GPIO_H +#define QEMU_VHOST_USER_GPIO_H #include "hw/virtio/virtio.h" #include "hw/virtio/vhost.h" @@ -21,4 +21,4 @@ struct VHostUserGPIO { VHostUserBase parent_obj; }; -#endif /* _QEMU_VHOST_USER_GPIO_H */ +#endif /* QEMU_VHOST_USER_GPIO_H */ include/hw/virtio/vhost-user-scmi.h +3
-3@@ -6,8 +6,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _QEMU_VHOST_USER_SCMI_H -#define _QEMU_VHOST_USER_SCMI_H +#ifndef QEMU_VHOST_USER_SCMI_H +#define QEMU_VHOST_USER_SCMI_H #include "hw/virtio/virtio.h" #include "hw/virtio/vhost.h" @@ -28,4 +28,4 @@ struct VHostUserSCMI { bool started_vu; }; -#endif /* _QEMU_VHOST_USER_SCMI_H */ +#endif /* QEMU_VHOST_USER_SCMI_H */ include/hw/xen/xen-pvh-common.h +2
-2@@ -6,8 +6,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef XEN_PVH_COMMON_H__ -#define XEN_PVH_COMMON_H__ +#ifndef XEN_PVH_COMMON_H +#define XEN_PVH_COMMON_H #include "system/memory.h" #include "qom/object.h" include/tcg/insn-start-words.h +3
-3@@ -4,9 +4,9 @@* Copyright (c) 2008 Fabrice Bellard */ -#ifndef TCG_INSN_START_WORDS -#define TCG_INSN_START_WORDS +#ifndef TCG_INSN_START_WORDS_H +#define TCG_INSN_START_WORDS_H #define INSN_START_WORDS 3 -#endif /* TCG_INSN_START_WORDS */ +#endif /* TCG_INSN_START_WORDS_H */ qga/cutils.h +3
-4@@ -1,6 +1,6 @@ -#ifndef CUTILS_H_ -#define CUTILS_H_ +#ifndef CUTILS_H +#define CUTILS_H int qga_open_cloexec (const char *name,int flags,mode_t mode); -#endif /* CUTILS_H_ */ +#endif /* CUTILS_H */ --2.52.0
PATCH 4/5 Normalize header guard symbol definition
In reply to Markus ArmbrusterWe commonly define the header guard symbol without an explicit value. Normalize the exceptions.
Done with scripts/clean-header-guards.pl.
--- include/exec/tlb-common.h | 3 ++- include/hw/misc/xlnx-cfi-if.h | 3 ++- include/qemu/mem-reentrancy.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-)
include/exec/tlb-common.h +2 -1
@@ -16,8 +16,9 @@* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ +#ifndef EXEC_TLB_COMMON_H -#define EXEC_TLB_COMMON_H 1 +#define EXEC_TLB_COMMON_H #define CPU_TLB_ENTRY_BITS (HOST_LONG_BITS == 32 ? 4 : 5)
include/hw/misc/xlnx-cfi-if.h +2 -1
@@ -7,8 +7,9 @@* * SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef XLNX_CFI_IF_H -#define XLNX_CFI_IF_H 1 +#define XLNX_CFI_IF_H #include "qemu/help-texts.h" #include "qom/object.h"
include/qemu/mem-reentrancy.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ #ifndef QEMU_MEM_REENTRANCY_H -#define QEMU_MEM_REENTRANCY_H 1 +#define QEMU_MEM_REENTRANCY_H typedef struct MemReentrancyGuard { bool engaged_in_io;
Signature · 1 line
2.52.0
Re: [PATCH 4/5] Normalize header guard symbol definition
Quoted 11 lines · Markus Armbruster
We commonly define the header guard symbol without an explicit value. Normalize the exceptions.
Done with
scripts/clean-header-guards.pl.Signed-off-by Markus Armbruster <[email protected]>--- include/exec/tlb-common.h | 3 ++- include/hw/misc/xlnx-cfi-if.h | 3 ++- include/qemu/mem-reentrancy.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: 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 :|
PATCH 5/5 Clean up decorations and whitespace around header guards
In reply to Markus ArmbrusterCleaned up with scripts/clean-header-guards.pl.
--- crypto/akcipherpriv.h | 2 +- crypto/der.h | 2 +- hw/net/e1000x_regs.h | 2 +- hw/riscv/riscv-iommu-bits.h | 2 +- include/accel/accel-cpu-target.h | 2 +- include/exec/tswap.h | 2 +- include/hw/char/max78000_uart.h | 2 +- include/hw/fsi/fsi-master.h | 3 ++- include/hw/intc/loongarch_extioi_common.h | 2 +- include/hw/intc/loongarch_pic_common.h | 2 +- include/hw/misc/allwinner-a10-ccm.h | 2 +- include/hw/ppc/pnv_n1_chiplet.h | 2 +- include/semihosting/uaccess.h | 2 +- include/system/ioport.h | 2 +- include/tcg/tcg-temp-internal.h | 2 +- target/hexagon/idef-parser/parser-helpers.h | 2 +- target/i386/kvm/xen-compat.h | 2 +- target/loongarch/cpu-mmu.h | 2 +- target/loongarch/tcg/tcg_loongarch.h | 4 +++- target/riscv/cpu_vendorid.h | 2 +- 20 files changed, 23 insertions(+), 20 deletions(-)
crypto/akcipherpriv.h +1 -1
@@ -52,4 +52,4 @@ struct QCryptoAkCipherDriver { void (*free)(QCryptoAkCipher *akcipher); }; -#endif /* QCRYPTO_AKCIPHER_H */ +#endif /* QCRYPTO_AKCIPHERPRIV_H */
crypto/der.h +1 -1
@@ -261,4 +261,4 @@ size_t qcrypto_der_encode_ctx_buffer_len(QCryptoEncodeContext *ctx);void qcrypto_der_encode_ctx_flush_and_free (QCryptoEncodeContext *ctx,uint8_t *dst); -#endif /* QCRYPTO_ASN1_DECODER_H */ +#endif /* QCRYPTO_ASN1_DECODER_H */
hw/net/e1000x_regs.h +1 -1
@@ -968,4 +968,4 @@ struct e1000_context_desc {#define E1000_VFTA_ENTRY_MASK 0x7F#define E1000_VFTA_ENTRY_BIT_SHIFT_MASK 0x1F -#endif /* HW_E1000_REGS_H */ +#endif /* HW_E1000X_REGS_H */
hw/riscv/riscv-iommu-bits.h +1 -1
@@ -466,4 +466,4 @@ struct riscv_iommu_msi_pte {#define RISCV_IOMMU_MSI_MRIF_NPPN RISCV_IOMMU_PPN_FIELD#define RISCV_IOMMU_MSI_MRIF_NID_MSB BIT_ULL(60) -#endif /* _RISCV_IOMMU_BITS_H_ */ +#endif /* HW_RISCV_IOMMU_BITS_H */
include/accel/accel-cpu-target.h +1 -1
@@ -28,4 +28,4 @@#define ACCEL_CPU_NAME (name) (name "-" TYPE_ACCEL_CPU) DECLARE_CLASS_CHECKERS(AccelCPUClass, ACCEL_CPU, TYPE_ACCEL_CPU) -#endif /* ACCEL_CPU_H */ +#endif /* ACCEL_CPU_TARGET_H */
include/exec/tswap.h +1 -1
@@ -69,4 +69,4 @@ static inline void tswap64s(uint64_t *s) } } -#endif /* TSWAP_H */ +#endif /* TSWAP_H */
include/hw/char/max78000_uart.h +1 -1
@@ -75,4 +75,4 @@ struct Max78000UartState {CharFrontend chr; qemu_irq irq; }; -#endif /* HW_STM32F2XX_USART_H */ +#endif /* HW_MAX78000_UART_H */
include/hw/fsi/fsi-master.h +2 -1
@@ -4,6 +4,7 @@* * IBM Flexible Service Interface Master */ +#ifndef FSI_FSI_MASTER_H #define FSI_FSI_MASTER_H
@@ -29,4 +30,4 @@ typedef struct FSIMasterState { } FSIMasterState; -#endif /* FSI_FSI_H */ +#endif /* FSI_FSI_MASTER_H */
include/hw/intc/loongarch_extioi_common.h +1 -1
@@ -100,4 +100,4 @@ struct LoongArchExtIOICommonClass {int (*pre_save)(void *s); int (*post_load)(void *s, int version_id); }; -#endif /* LOONGARCH_EXTIOI_H */ +#endif /* LOONGARCH_EXTIOI_COMMON_H */
include/hw/intc/loongarch_pic_common.h +1 -1
@@ -79,4 +79,4 @@ struct LoongArchPICCommonClass {int (*pre_save)(LoongArchPICCommonState *s); int (*post_load)(LoongArchPICCommonState *s, int version_id); }; -#endif /* HW_LOONGARCH_PIC_COMMON_H */ +#endif /* HW_LOONGARCH_PIC_COMMON_H */
include/hw/misc/allwinner-a10-ccm.h +1 -1
@@ -64,4 +64,4 @@ struct AwA10ClockCtlState { uint32_t regs[AW_A10_CCM_REGS_NUM]; }; -#endif /* HW_MISC_ALLWINNER_H3_CCU_H */ +#endif /* HW_MISC_ALLWINNER_A10_CCM_H */
include/hw/ppc/pnv_n1_chiplet.h +1 -1
@@ -29,4 +29,4 @@ typedef struct PnvN1Chiplet {#define PNV_PB_SCOM_ES_SIZE 4 PnvPbScom es[PNV_PB_SCOM_ES_SIZE]; } PnvN1Chiplet; -#endif /*PPC_PNV_N1_CHIPLET_H */ +#endif /* PPC_PNV_N1_CHIPLET_H */
include/semihosting/uaccess.h +1 -1
@@ -118,4 +118,4 @@ void uaccess_unlock_user(CPUArchState *env, void *p,ssize_t uaccess_strlen_user (CPUArchState *env,vaddr addr);#define target_strlen (p) uaccess_strlen_user(env, p) -#endif /* SEMIHOSTING_SOFTMMU_UACCESS_H */ +#endif /* SEMIHOSTING_UACCESS_H */
include/system/ioport.h +1 -1
@@ -72,4 +72,4 @@ void portio_list_del(PortioList *piolist);void portio_list_set_enabled (PortioList *piolist,bool enabled);void portio_list_set_address (PortioList *piolist,uint32_t addr); -#endif /* IOPORT_H */ +#endif /* SYSTEM_IOPORT_H */
include/tcg/tcg-temp-internal.h +1 -1
@@ -48,4 +48,4 @@ static inline void tcg_temp_ebb_reset_freed(TCGContext *s) memset(s->free_temps, 0, sizeof(s->free_temps)); } -#endif /* TCG_TEMP_FREE_H */ +#endif /* TCG_TEMP_INTERNAL_H */
target/hexagon/idef-parser/parser-helpers.h +1 -1
@@ -350,4 +350,4 @@ void assert_signedness(Context *c,YYLTYPE *locp, HexSignedness signedness); -#endif /* PARSER_HELPERS_h */ +#endif /* PARSER_HELPERS_H */
target/i386/kvm/xen-compat.h +1 -1
@@ -67,4 +67,4 @@ struct compat_physdev_map_pirq {uint64_t table_base; } __attribute__((packed)); -#endif /* QEMU_I386_XEN_COMPAT_H */ +#endif /* QEMU_I386_KVM_XEN_COMPAT_H */
target/loongarch/cpu-mmu.h +1 -1
@@ -99,4 +99,4 @@ void get_dir_base_width(CPULoongArchState *env, uint64_t *dir_base, uint64_t *dir_width, unsigned int level);hwaddr loongarch_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); -#endif /* LOONGARCH_CPU_MMU_H */ +#endif /* LOONGARCH_CPU_MMU_H */
target/loongarch/tcg/tcg_loongarch.h +3 -1
@@ -4,8 +4,10 @@* * Copyright (c) 2025 Loongson Technology Corporation Limited */ +#ifndef TARGET_LOONGARCH_TCG_LOONGARCH_H #define TARGET_LOONGARCH_TCG_LOONGARCH_H +#include "cpu.h" #include "cpu-mmu.h"
@@ -20,4 +22,4 @@ TLBRet loongarch_get_addr_from_tlb(CPULoongArchState *env,MMUContext *context, MMUAccessType access_type, int mmu_idx); -#endif /* TARGET_LOONGARCH_TCG_LOONGARCH_H */ +#endif /* TARGET_LOONGARCH_TCG_LOONGARCH_H */
target/riscv/cpu_vendorid.h +1 -1
@@ -8,4 +8,4 @@#define VEYRON_V1_MIMPID 0x111#define VEYRON_V1_MVENDORID 0x61f -#endif /* TARGET_RISCV_CPU_VENDORID_H */ +#endif /* TARGET_RISCV_CPU_VENDORID_H */
Signature · 1 line
2.52.0
Re: [PATCH 5/5] Clean up decorations and whitespace around header guards
Quoted 17 lines · Markus Armbruster
Cleaned up with
scripts/clean-header-guards.pl.Signed-off-by Markus Armbruster <[email protected]>--- crypto/akcipherpriv.h | 2 +- crypto/der.h | 2 +- hw/net/e1000x_regs.h | 2 +- hw/riscv/riscv-iommu-bits.h | 2 +- include/accel/accel-cpu-target.h | 2 +- include/exec/tswap.h | 2 +- include/hw/char/max78000_uart.h | 2 +- include/hw/fsi/fsi-master.h | 3 ++- include/hw/intc/loongarch_extioi_common.h | 2 +- include/hw/intc/loongarch_pic_common.h | 2 +- include/hw/misc/allwinner-a10-ccm.h | 2 +- include/hw/ppc/pnv_n1_chiplet.h | 2 +- include/semihosting/uaccess.h | 2 +-
Quoted 8 lines
include/system/ioport.h | 2 +- include/tcg/tcg-temp-internal.h | 2 +- target/hexagon/idef-parser/parser-helpers.h | 2 +- target/i386/kvm/xen-compat.h | 2 +- target/loongarch/cpu-mmu.h | 2 +- target/loongarch/tcg/tcg_loongarch.h | 4 +++- target/riscv/cpu_vendorid.h | 2 +- 20 files changed, 23 insertions(+), 20 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: 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 :|
Quoted 10 lines · Markus Armbruster
Our use of header guards is rather sloppy. Sloppiness there can lead to confusing compilation errors. This series cleans up existing header guards. In particular, it normalizes guard symbols to follow a common pattern, in the hope of making clashes less likely. It doesn't add new header guards. We have more than 300 headers without a recognizable header guard. A few of them are for multiple inclusion, many don't need header guards because they don't do anything but include, but quite a few probably should have one. Left for another day.
Quoted 2 lines
Previously cleaned up in merge commit
ec11dc41eec(2022), merge commit01807c8b0e9(2019), and merge commitca3d87d4c84(2016).
No objection to applying these fixups since you've done the work already.
Based on the repeated cleanups, and your notes above that we still have many problems though, can I again suggest we just adopt the GCC/CLang extension of adding
#pragma once
at the top of every header and burn all the #ifdefs.
It is easy & cheap to verify that it is present on every single .h file, and there are no style variations to get wrong, or closing statements to make inconsistent.
With regards,
Daniel
Signature · 3 lines
|: 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 :|