misc: clean up includes
cover misc: clean up includes
This patchset is the result of running scripts/clean-includes as updated with my changes in the v2 patchset I just posted:
https://patchew.org/QEMU/[email protected]/
It makes the usual set of cleanups to #include lines:
* Ensure .c files include qemu/osdep.h first.
* Including it in a .h is redundant, since the .c already includes it. Drop such inclusions.
* Likewise, including headers qemu/osdep.h includes is redundant. Drop these, too.
I have split the changes it proposes into five categories:
(1) changes to mshv related files
(2) changes to bsd-user files
(3) changes where a .c file included a system header that osdep.h already provides
(4) changes where .h files either included osdep.h or else some system header that osdep.h provides
The only change the updated script proposes which is not in any patch in this series is to hw/virtio/cbor-helpers.c: I am waiting to find out if we should put this file on the exclude-list.
thanks
-- PMM
Peter Maydell (4):
mshv: Clean up includes
bsd-user: Clean up includes
misc: Clean up includes
all: Clean up includes
accel/mshv/irq.c | 3 +-- accel/mshv/mshv-all.c | 1 - bsd-user/bsd-mem.h | 3 --- bsd-user/bsd-proc.c | 1 - bsd-user/freebsd/os-proc.h | 2 -- bsd-user/qemu-bsd.h | 1 - hw/core/machine-qmp-cmds.c | 1 - hw/scsi/lasi_ncr710.h | 1 - hw/scsi/ncr53c710.h | 1 - include/hw/core/loader.h | 1 - include/hw/i386/tdvf.h | 1 - include/hw/ppc/spapr_fadump.h | 1 - include/hw/riscv/iommu.h | 1 - include/system/accel-irq.h | 1 - include/system/mshv.h | 1 - linux-user/alpha/target_proc.h | 1 - qga/commands-windows-ssh.h | 1 - qga/vss-win32/vss-debug.h | 1 - semihosting/arm-compat-semi-stub.c | 1 - target/arm/cpu32-stubs.c | 1 - target/i386/kvm/kvm.c | 1 - target/i386/kvm/vmsr_energy.h | 2 -- target/i386/mshv/mshv-cpu.c | 1 - target/i386/mshv/x86.c | 1 - target/loongarch/csr.c | 1 - target/riscv/csr.c | 1 - tools/i386/qemu-vmsr-helper.c | 1 - util/cpuinfo-aarch64.c | 1 - 28 files changed, 1 insertion(+), 33 deletions(-)
Signature · 1 line
2.47.3
PATCH 1/4 mshv: Clean up includes
This commit was created with scripts/clean-includes:
./scripts/clean-includes '--git' 'mshv' 'accel/mshv' 'target/i386/mshv' 'include/system/mshv.h'
All .c should include qemu/osdep.h first. The script performs three related cleanups:
* Ensure .c files include qemu/osdep.h first.
* Including it in a .h is redundant, since the .c already includes it. Drop such inclusions.
* Likewise, including headers qemu/osdep.h includes is redundant. Drop these, too.
--- accel/mshv/irq.c | 3 +-- accel/mshv/mshv-all.c | 1 - include/system/mshv.h | 1 - target/i386/mshv/mshv-cpu.c | 1 - target/i386/mshv/x86.c | 1 - 5 files changed, 1 insertion(+), 6 deletions(-)
accel/mshv/irq.c +1 -2
@@ -10,8 +10,8 @@* SPDX-License-Identifier: GPL-2.0-or-later */ -#include "linux/mshv.h" #include "qemu/osdep.h" +#include "linux/mshv.h" #include "qemu/error-report.h" #include "hw/hyperv/hvhdk_mini.h" #include "hw/hyperv/hvgdk_mini.h"
@@ -20,7 +20,6 @@#include "system/mshv.h" #include "system/mshv_int.h" #include "trace.h" -#include <stdint.h> #include <sys/ioctl.h> #define MSHV_IRQFD_RESAMPLE_FLAG (1 << MSHV_IRQFD_BIT_RESAMPLE)
accel/mshv/mshv-all.c +0 -1
@@ -41,7 +41,6 @@#include "system/reset.h" #include "trace.h" #include <err.h> -#include <stdint.h> #include <sys/ioctl.h> #define TYPE_MSHV_ACCEL ACCEL_CLASS_NAME("mshv")
include/system/mshv.h +0 -1
@@ -14,7 +14,6 @@#ifndef QEMU_MSHV_H #define QEMU_MSHV_H -#include "qemu/osdep.h" #include "qemu/accel.h" #include "hw/hyperv/hyperv-proto.h" #include "hw/hyperv/hvhdk.h"
target/i386/mshv/mshv-cpu.c +0 -1
@@ -13,7 +13,6 @@#include "qemu/osdep.h" #include "qemu/error-report.h" #include "qemu/memalign.h" -#include "qemu/typedefs.h" #include "system/mshv.h" #include "system/mshv_int.h"
target/i386/mshv/x86.c +0 -1
@@ -13,7 +13,6 @@#include "cpu.h" #include "emulate/x86_decode.h" #include "emulate/x86_emu.h" -#include "qemu/typedefs.h" #include "qemu/error-report.h" #include "system/mshv.h"
Signature · 1 line
2.47.3
Re: [PATCH 1/4] mshv: Clean up includes
Quoted 12 lines · Peter Maydell
This commit was created with
scripts/clean-includes:
./scripts/clean-includes'--git' 'mshv' 'accel/mshv' 'target/i386/mshv' 'include/system/mshv.h'All .c should include
qemu/osdep.hfirst. The script performs three related cleanups:* Ensure .c files include
qemu/osdep.hfirst.
* Including it in a .h is redundant, since the .c already includes it. Drop such inclusions.
* Likewise, including headersqemu/osdep.hincludes is redundant. Drop these, too.
Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>--- accel/mshv/irq.c | 3 +-- accel/mshv/mshv-all.c | 1 - include/system/mshv.h | 1 - target/i386/mshv/mshv-cpu.c | 1 - target/i386/mshv/x86.c | 1 - 5 files changed, 1 insertion(+), 6 deletions(-)
PATCH 2/4 bsd-user: Clean up includes
In reply to Peter MaydellThis commit was created with scripts/clean-includes:
./scripts/clean-includes '--git' 'bsd-user' 'bsd-user'
All .c should include qemu/osdep.h first. The script performs three related cleanups:
* Ensure .c files include qemu/osdep.h first.
* Including it in a .h is redundant, since the .c already includes it. Drop such inclusions.
* Likewise, including headers qemu/osdep.h includes is redundant. Drop these, too.
--- bsd-user/bsd-mem.h | 3 --- bsd-user/bsd-proc.c | 1 - bsd-user/freebsd/os-proc.h | 2 -- bsd-user/qemu-bsd.h | 1 - 4 files changed, 7 deletions(-)
bsd-user/bsd-mem.h +0 -3
@@ -49,11 +49,8 @@#ifndef BSD_USER_BSD_MEM_H #define BSD_USER_BSD_MEM_H -#include <sys/types.h> #include <sys/ipc.h> -#include <sys/mman.h> #include <sys/shm.h> -#include <fcntl.h> #include "qemu-bsd.h" #include "exec/mmap-lock.h"
bsd-user/bsd-proc.c +0 -1
@@ -19,7 +19,6 @@#include "qemu/osdep.h" #include <sys/param.h> -#include <sys/types.h> #include <sys/cpuset.h> #include <sys/resource.h> #include <sys/wait.h>
bsd-user/freebsd/os-proc.h +0 -2
@@ -23,10 +23,8 @@#include <sys/param.h> #include <sys/procctl.h> #include <sys/signal.h> -#include <sys/types.h> #include <sys/procdesc.h> #include <sys/wait.h> -#include <unistd.h> #include "target_arch_cpu.h"
bsd-user/qemu-bsd.h +0 -1
@@ -20,7 +20,6 @@#ifndef QEMU_BSD_H #define QEMU_BSD_H -#include <sys/types.h> #include <sys/resource.h> #include <sys/ipc.h> #include <sys/msg.h>
Signature · 1 line
2.47.3
Re: [PATCH 2/4] bsd-user: Clean up includes
Quoted 12 lines · Peter Maydell
This commit was created with
scripts/clean-includes:
./scripts/clean-includes'--git' 'bsd-user' 'bsd-user'All .c should include
qemu/osdep.hfirst. The script performs three related cleanups:* Ensure .c files include
qemu/osdep.hfirst.
* Including it in a .h is redundant, since the .c already includes it. Drop such inclusions.
* Likewise, including headersqemu/osdep.hincludes is redundant. Drop these, too.
Quoted 7 lines
Signed-off-by Peter Maydell <[email protected]>--- bsd-user/bsd-mem.h | 3 --- bsd-user/bsd-proc.c | 1 - bsd-user/freebsd/os-proc.h | 2 -- bsd-user/qemu-bsd.h | 1 - 4 files changed, 7 deletions(-)
Re: [PATCH 2/4] bsd-user: Clean up includes
In reply to Peter MaydellQuoted 12 lines · Peter Maydell
This commit was created with
scripts/clean-includes:
./scripts/clean-includes'--git' 'bsd-user' 'bsd-user'All .c should include
qemu/osdep.hfirst. The script performs three related cleanups:* Ensure .c files include
qemu/osdep.hfirst.
* Including it in a .h is redundant, since the .c already includes it. Drop such inclusions.
* Likewise, including headersqemu/osdep.hincludes is redundant. Drop these, too.
Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>--- bsd-user/bsd-mem.h | 3 --- bsd-user/bsd-proc.c | 1 - bsd-user/freebsd/os-proc.h | 2 -- bsd-user/qemu-bsd.h | 1 - 4 files changed, 7 deletions(-)
These were the documented includes needed for these APIs. But this cleanup is fine.
We weren't 100% consistent anyway before.
Quoted 59 lines
bsd-user/bsd-mem.h +0
-3@@ -49,11 +49,8 @@#ifndef BSD_USER_BSD_MEM_H #define BSD_USER_BSD_MEM_H -#include <sys/types.h> #include <sys/ipc.h> -#include <sys/mman.h> #include <sys/shm.h> -#include <fcntl.h> #include "qemu-bsd.h" #include "exec/mmap-lock.h" bsd-user/bsd-proc.c +0
-1@@ -19,7 +19,6 @@#include "qemu/osdep.h" #include <sys/param.h> -#include <sys/types.h> #include <sys/cpuset.h> #include <sys/resource.h> #include <sys/wait.h> bsd-user/freebsd/os-proc.h +0
-2@@ -23,10 +23,8 @@#include <sys/param.h> #include <sys/procctl.h> #include <sys/signal.h> -#include <sys/types.h> #include <sys/procdesc.h> #include <sys/wait.h> -#include <unistd.h> #include "target_arch_cpu.h" bsd-user/qemu-bsd.h +0
-2@@ -20,7 +20,6 @@#ifndef QEMU_BSD_H #define QEMU_BSD_H -#include <sys/types.h> #include <sys/resource.h> #include <sys/ipc.h> #include <sys/msg.h> --2.47.3
PATCH 3/4 misc: Clean up includes
In reply to Peter MaydellThis commit deals with various .c files that included system headers that are already pulled in by osdep.h, where the .c file includes osdep.h already itself.
This commit was created with scripts/clean-includes:
./scripts/clean-includes '--git' 'misc' 'hw/core' 'semihosting' 'target/arm' 'target/i386/kvm/kvm.c' 'target/loongarch' 'target/riscv' 'tools' 'util'
All .c should include qemu/osdep.h first. The script performs three related cleanups:
* Ensure .c files include qemu/osdep.h first.
* Including it in a .h is redundant, since the .c already includes it. Drop such inclusions.
* Likewise, including headers qemu/osdep.h includes is redundant. Drop these, too.
--- hw/core/machine-qmp-cmds.c | 1 - semihosting/arm-compat-semi-stub.c | 1 - target/arm/cpu32-stubs.c | 1 - target/i386/kvm/kvm.c | 1 - target/loongarch/csr.c | 1 - target/riscv/csr.c | 1 - tools/i386/qemu-vmsr-helper.c | 1 - util/cpuinfo-aarch64.c | 1 - 8 files changed, 8 deletions(-)
hw/core/machine-qmp-cmds.c +0 -1
@@ -30,7 +30,6 @@#include "system/runstate.h" #include "system/system.h" #include "hw/s390x/storage-keys.h" -#include <sys/stat.h> /* * QMP query for enabled and present accelerators
semihosting/arm-compat-semi-stub.c +0 -1
@@ -6,7 +6,6 @@#include "qemu/osdep.h" #include "semihosting/semihost.h" -#include <glib.h> bool semihosting_arm_compatible (void ) {
target/arm/cpu32-stubs.c +0 -1
@@ -3,7 +3,6 @@#include "qemu/osdep.h" #include "target/arm/cpu.h" #include "target/arm/internals.h" -#include <glib.h> void arm_cpu_sme_finalize (ARMCPU *cpu,Error **errp) {
target/i386/kvm/kvm.c +0 -1
@@ -21,7 +21,6 @@#include <sys/utsname.h> #include <sys/syscall.h> #include <sys/resource.h> -#include <sys/time.h> #include <linux/kvm.h> #include <linux/kvm_para.h>
target/loongarch/csr.c +0 -1
@@ -2,7 +2,6 @@/* * Copyright (c) 2025 Loongson Technology Corporation Limited */ -#include <stddef.h> #include "qemu/osdep.h" #include "cpu.h" #include "csr.h"
target/riscv/csr.c +0 -1
@@ -31,7 +31,6 @@#include "qapi/error.h" #include "tcg/insn-start-words.h" #include "internals.h" -#include <stdbool.h> /* CSR function table public API */ void riscv_get_csr_ops (int csrno,riscv_csr_operations *ops)
tools/i386/qemu-vmsr-helper.c +0 -1
@@ -20,7 +20,6 @@#include "qemu/osdep.h" #include <getopt.h> -#include <stdbool.h> #include <sys/ioctl.h> #ifdef CONFIG_LIBCAP_NG #include <cap-ng.h>
util/cpuinfo-aarch64.c +0 -1
@@ -26,7 +26,6 @@#if defined(__OpenBSD__) && !defined(CONFIG_ELF_AUX_INFO )# include <machine/armreg.h> # include <machine/cpu.h> -# include <sys/types.h> # include <sys/sysctl.h> #endif
Signature · 1 line
2.47.3
Re: [PATCH 3/4] misc: Clean up includes
Quoted 10 lines · Peter Maydell
This commit deals with various .c files that included system headers that are already pulled in by
osdep.h, where the .c file includesosdep.halready itself.This commit was created with
scripts/clean-includes:
./scripts/clean-includes'--git' 'misc' 'hw/core' 'semihosting' 'target/arm' 'target/i386/kvm/kvm.c' 'target/loongarch' 'target/riscv' 'tools' 'util'All .c should include
qemu/osdep.hfirst. The script performs three related cleanups:
Quoted 7 lines
* Ensure .c files include
qemu/osdep.hfirst.
* Including it in a .h is redundant, since the .c already includes it. Drop such inclusions.
* Likewise, including headersqemu/osdep.hincludes is redundant. Drop these, too.Signed-off-by Peter Maydell <[email protected]>
Re: [PATCH 3/4] misc: Clean up includes
In reply to Peter MaydellQuoted 17 lines · Peter Maydell
This commit deals with various .c files that included system headers that are already pulled in by
osdep.h, where the .c file includesosdep.halready itself.This commit was created with
scripts/clean-includes:
./scripts/clean-includes'--git' 'misc' 'hw/core' 'semihosting' 'target/arm' 'target/i386/kvm/kvm.c' 'target/loongarch' 'target/riscv' 'tools' 'util'All .c should include
qemu/osdep.hfirst. The script performs three related cleanups:* Ensure .c files include
qemu/osdep.hfirst.
* Including it in a .h is redundant, since the .c already includes it. Drop such inclusions.
* Likewise, including headersqemu/osdep.hincludes is redundant. Drop these, too.Signed-off-by Peter Maydell <[email protected]>
Quoted 10 lines
--- hw/core/machine-qmp-cmds.c | 1 - semihosting/arm-compat-semi-stub.c | 1 - target/arm/cpu32-stubs.c | 1 - target/i386/kvm/kvm.c | 1 - target/loongarch/csr.c | 1 - target/riscv/csr.c | 1 - tools/i386/qemu-vmsr-helper.c | 1 - util/cpuinfo-aarch64.c | 1 - 8 files changed, 8 deletions(-)
PATCH 4/4 all: Clean up includes
In reply to Peter MaydellThis commit was created with scripts/clean-includes:
./scripts/clean-includes '--git' 'all' '--all'
and manually edited to remove one change to hw/virtio/cbor-helpers.c. All these changes are header files that include osdep.h or some system header that osdep.h pulls in; they don't need to do this.
All .c should include qemu/osdep.h first. The script performs three related cleanups:
* Ensure .c files include qemu/osdep.h first.
* Including it in a .h is redundant, since the .c already includes it. Drop such inclusions.
* Likewise, including headers qemu/osdep.h includes is redundant. Drop these, too.
--- hw/scsi/lasi_ncr710.h | 1 - hw/scsi/ncr53c710.h | 1 - include/hw/core/loader.h | 1 - include/hw/i386/tdvf.h | 1 - include/hw/ppc/spapr_fadump.h | 1 - include/hw/riscv/iommu.h | 1 - include/system/accel-irq.h | 1 - linux-user/alpha/target_proc.h | 1 - qga/commands-windows-ssh.h | 1 - qga/vss-win32/vss-debug.h | 1 - target/i386/kvm/vmsr_energy.h | 2 -- 11 files changed, 12 deletions(-)
hw/scsi/lasi_ncr710.h +0 -1
@@ -15,7 +15,6 @@#define HW_LASI_NCR710_H #include "hw/core/sysbus.h" -#include "qemu/osdep.h" #include "exec/memattrs.h" #include "hw/scsi/scsi.h" #include "hw/scsi/ncr53c710.h"
hw/scsi/ncr53c710.h +0 -1
@@ -15,7 +15,6 @@#ifndef HW_NCR53C710_H #define HW_NCR53C710_H -#include "qemu/osdep.h" #include "hw/core/sysbus.h" #include "hw/scsi/scsi.h" #include "qemu/fifo8.h"
include/hw/core/loader.h +0 -1
@@ -1,7 +1,6 @@#ifndef LOADER_H #define LOADER_H #include "hw/nvram/fw_cfg.h" -#include "qemu/typedefs.h" /* loader.c */ /**
include/hw/i386/tdvf.h +0 -1
@@ -9,7 +9,6 @@#ifndef HW_I386_TDVF_H #define HW_I386_TDVF_H -#include "qemu/osdep.h" #define TDVF_SECTION_TYPE_BFV 0#define TDVF_SECTION_TYPE_CFV 1
include/hw/ppc/spapr_fadump.h +0 -1
@@ -6,7 +6,6 @@#ifndef PPC_SPAPR_FADUMP_H #define PPC_SPAPR_FADUMP_H -#include "qemu/osdep.h" #include "cpu.h" /* Fadump commands */
include/hw/riscv/iommu.h +0 -1
@@ -19,7 +19,6 @@#ifndef HW_RISCV_IOMMU_H #define HW_RISCV_IOMMU_H -#include "qemu/osdep.h" #include "qom/object.h" #define TYPE_RISCV_IOMMU "riscv-iommu"
include/system/accel-irq.h +0 -1
@@ -12,7 +12,6 @@#ifndef SYSTEM_ACCEL_IRQ_H #define SYSTEM_ACCEL_IRQ_H #include "hw/pci/msi.h" -#include "qemu/osdep.h" #include "system/kvm.h" #include "system/mshv.h"
linux-user/alpha/target_proc.h +0 -1
@@ -6,7 +6,6 @@#ifndef ALPHA_TARGET_PROC_H #define ALPHA_TARGET_PROC_H -#include "qemu/osdep.h" #include "target/alpha/cpu.h" static uint8_t alpha_phys_addr_space_bits (CPUAlphaState *env)
qga/commands-windows-ssh.h +0 -1
@@ -11,7 +11,6 @@*/ #include <glib/gstrfuncs.h> -#include <stdbool.h> typedef struct WindowsUserInfo { char *sshDirectory; char *authorizedKeyFile;
qga/vss-win32/vss-debug.h +0 -1
@@ -10,7 +10,6 @@* See the COPYING file in the top-level directory. */ -#include "qemu/osdep.h" #include <vss-handles.h> #ifndef VSS_DEBUG_H
target/i386/kvm/vmsr_energy.h +0 -2
@@ -14,8 +14,6 @@#ifndef VMSR_ENERGY_H #define VMSR_ENERGY_H -#include <stdint.h> -#include "qemu/osdep.h" #include "io/channel-socket.h" #include "hw/i386/topology.h"
Signature · 1 line
2.47.3
Re: [PATCH 4/4] all: Clean up includes
Quoted 17 lines · Peter Maydell
This commit was created with
scripts/clean-includes:
./scripts/clean-includes'--git' 'all' '--all'and manually edited to remove one change to
hw/virtio/cbor-helpers.c. All these changes are header files that includeosdep.hor some system header thatosdep.hpulls in; they don't need to do this.All .c should include
qemu/osdep.hfirst. The script performs three related cleanups:* Ensure .c files include
qemu/osdep.hfirst.
* Including it in a .h is redundant, since the .c already includes it. Drop such inclusions.
* Likewise, including headersqemu/osdep.hincludes is redundant. Drop these, too.Signed-off-by Peter Maydell <[email protected]>
Quoted 13 lines
--- hw/scsi/lasi_ncr710.h | 1 - hw/scsi/ncr53c710.h | 1 - include/hw/core/loader.h | 1 - include/hw/i386/tdvf.h | 1 - include/hw/ppc/spapr_fadump.h | 1 - include/hw/riscv/iommu.h | 1 - include/system/accel-irq.h | 1 - linux-user/alpha/target_proc.h | 1 - qga/commands-windows-ssh.h | 1 - qga/vss-win32/vss-debug.h | 1 - target/i386/kvm/vmsr_energy.h | 2 -- 11 files changed, 12 deletions(-)