clean-up: removed duplicate #includes
PATCH 1/1 clean-up: removed duplicate #includes
Some files contain multiple #includes of the same header file. Removed most of those unnecessary duplicate entries.
--- accel.c | 1 - cputlb.c | 1 - disas/libvixl/vixl/globals.h | 1 - gdbstub.c | 1 - hw/i386/acpi-build.c | 1 - hw/microblaze/boot.c | 1 - hw/mips/mips_malta.c | 1 - hw/nvram/fw_cfg.c | 1 - hw/pci-bridge/pci_expander_bridge.c | 1 - hw/ppc/ppc405_boards.c | 1 - hw/ppc/spapr.c | 1 - hw/timer/grlib_gptimer.c | 1 - hw/tpm/tpm_tis.c | 1 - hw/unicore32/puv3.c | 1 - hw/usb/dev-mtp.c | 1 - include/hw/i386/pc.h | 1 - monitor.c | 2 -- qemu-io-cmds.c | 1 - qmp.c | 1 - target-i386/machine.c | 3 --- target-mips/machine.c | 1 - target-ppc/machine.c | 1 - target-ppc/mem_helper.c | 1 - target-sparc/machine.c | 3 --- target-xtensa/translate.c | 1 - tests/crypto-tls-x509-helpers.h | 3 --- tests/vhost-user-test.c | 2 -- util/oslib-posix.c | 1 - vl.c | 1 - 29 files changed, 37 deletions(-)
accel.c +0 -1
@@ -25,7 +25,6 @@#include "qemu/osdep.h" #include "sysemu/accel.h" -#include "hw/boards.h" #include "qemu-common.h" #include "sysemu/arch_init.h" #include "sysemu/sysemu.h"
cputlb.c +0 -1
@@ -19,7 +19,6 @@#include "qemu/osdep.h" #include "cpu.h" -#include "exec/exec-all.h" #include "exec/memory.h" #include "exec/address-spaces.h" #include "exec/cpu_ldst.h"
disas/libvixl/vixl/globals.h +0 -1
@@ -46,7 +46,6 @@#include <assert.h> #include <stdarg.h> #include <stdio.h> -#include <stdint.h> #include <stdlib.h> #include <stddef.h> #include "vixl/platform.h"
gdbstub.c +0 -1
@@ -31,7 +31,6 @@#define MAX_PACKET_LENGTH 4096 -#include "cpu.h" #include "qemu/sockets.h" #include "sysemu/kvm.h" #include "exec/semihost.h"
hw/i386/acpi-build.c +0 -1
@@ -30,7 +30,6 @@#include "qom/cpu.h" #include "hw/i386/pc.h" #include "target-i386/cpu.h" -#include "hw/timer/hpet.h" #include "hw/acpi/acpi-defs.h" #include "hw/acpi/acpi.h" #include "hw/acpi/cpu.h"
hw/microblaze/boot.c +0 -1
@@ -30,7 +30,6 @@#include "qemu/option.h" #include "qemu/config-file.h" #include "qemu/error-report.h" -#include "qemu-common.h" #include "sysemu/device_tree.h" #include "sysemu/sysemu.h" #include "hw/loader.h"
hw/mips/mips_malta.c +0 -1
@@ -47,7 +47,6 @@#include "elf.h" #include "hw/timer/mc146818rtc.h" #include "hw/timer/i8254.h" -#include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "exec/address-spaces.h" #include "hw/sysbus.h" /* SysBusDevice */
hw/nvram/fw_cfg.c +0 -1
@@ -29,7 +29,6 @@#include "hw/isa/isa.h" #include "hw/nvram/fw_cfg.h" #include "hw/sysbus.h" -#include "hw/boards.h" #include "trace.h" #include "qemu/error-report.h" #include "qemu/config-file.h"
hw/pci-bridge/pci_expander_bridge.c +0 -1
@@ -13,7 +13,6 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/pci/pci.h" -#include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" #include "hw/pci/pci_bus.h" #include "hw/pci/pci_bridge.h"
hw/ppc/ppc405_boards.c +0 -1
@@ -37,7 +37,6 @@#include "qemu/log.h" #include "qemu/error-report.h" #include "hw/loader.h" -#include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "exec/address-spaces.h"
hw/ppc/spapr.c +0 -1
@@ -37,7 +37,6 @@#include "sysemu/block-backend.h" #include "sysemu/cpus.h" #include "sysemu/kvm.h" -#include "sysemu/device_tree.h" #include "kvm_ppc.h" #include "migration/migration.h" #include "mmu-hash64.h"
hw/timer/grlib_gptimer.c +0 -1
@@ -26,7 +26,6 @@#include "hw/sysbus.h" #include "qemu/timer.h" #include "hw/ptimer.h" -#include "qemu/timer.h" #include "qemu/main-loop.h" #include "trace.h"
hw/tpm/tpm_tis.c +0 -1
@@ -34,7 +34,6 @@#include "qapi/error.h" #include "qemu-common.h" #include "qemu/main-loop.h" -#include "sysemu/tpm_backend.h" #define DEBUG_TIS 0
hw/unicore32/puv3.c +0 -1
@@ -13,7 +13,6 @@#include "qapi/error.h" #include "qemu-common.h" #include "cpu.h" -#include "qemu-common.h" #include "ui/console.h" #include "elf.h" #include "exec/address-spaces.h"
hw/usb/dev-mtp.c +0 -1
@@ -17,7 +17,6 @@#include <sys/statvfs.h> #ifdef CONFIG_INOTIFY1 #include <sys/inotify.h> -#include "qapi/error.h" #include "qemu/main-loop.h" #endif
include/hw/i386/pc.h +0 -1
@@ -13,7 +13,6 @@#include "qemu/bitmap.h" #include "sysemu/sysemu.h" #include "hw/pci/pci.h" -#include "hw/boards.h" #include "hw/compat.h" #include "hw/mem/pc-dimm.h" #include "hw/mem/nvdimm.h"
monitor.c +0 -2
@@ -59,7 +59,6 @@#include "qapi/qmp/json-streamer.h" #include "qapi/qmp/json-parser.h" #include "qom/object_interfaces.h" -#include "cpu.h" #include "trace.h" #include "trace/control.h" #include "monitor/hmp-target.h"
@@ -76,7 +75,6 @@#include "qapi/qmp-event.h" #include "qapi-event.h" #include "qmp-introspect.h" -#include "sysemu/block-backend.h" #include "sysemu/qtest.h" #include "qemu/cutils.h" #include "qapi/qmp/dispatch.h"
qemu-io-cmds.c +0 -1
@@ -18,7 +18,6 @@#include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/timer.h" -#include "sysemu/block-backend.h" #include "qemu/cutils.h" #define CMD_NOFILE_OK 0x01
qmp.c +0 -1
@@ -36,7 +36,6 @@#include "qom/object_interfaces.h" #include "hw/mem/pc-dimm.h" #include "hw/acpi/acpi_dev_interface.h" -#include "qemu/uuid.h" NameInfo *qmp_query_name (Error **errp) {
target-i386/machine.c +0 -3
@@ -7,10 +7,7 @@#include "hw/i386/pc.h" #include "hw/isa/isa.h" #include "migration/cpu.h" -#include "exec/exec-all.h" -#include "cpu.h" -#include "exec/exec-all.h" #include "sysemu/kvm.h" #include "qemu/error-report.h"
target-mips/machine.c +0 -1
@@ -2,7 +2,6 @@#include "qemu-common.h" #include "cpu.h" #include "hw/hw.h" -#include "cpu.h" #include "migration/cpu.h" static int cpu_post_load (void *opaque,int version_id)
target-ppc/machine.c +0 -1
@@ -8,7 +8,6 @@#include "helper_regs.h" #include "mmu-hash64.h" #include "migration/cpu.h" -#include "exec/exec-all.h" static int cpu_load_old (QEMUFile *f,void *opaque,int version_id) {
target-ppc/mem_helper.c +0 -1
@@ -23,7 +23,6 @@#include "exec/helper-proto.h" #include "helper_regs.h" -#include "exec/exec-all.h" #include "exec/cpu_ldst.h" //#define DEBUG_OP
target-sparc/machine.c +0 -3
@@ -6,10 +6,7 @@#include "hw/boards.h" #include "qemu/timer.h" -#include "cpu.h" -#include "exec/exec-all.h" #include "migration/cpu.h" -#include "exec/exec-all.h" #ifdef TARGET_SPARC64 static const VMStateDescription vmstate_cpu_timer = {
target-xtensa/translate.c +0 -1
@@ -36,7 +36,6 @@#include "tcg-op.h" #include "qemu/log.h" #include "sysemu/sysemu.h" -#include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "exec/semihost.h"
tests/crypto-tls-x509-helpers.h +0 -3
@@ -21,9 +21,6 @@#include <gnutls/gnutls.h> #include <gnutls/x509.h> -#include <gnutls/gnutls.h> -#include <gnutls/x509.h> -#if !(definedWIN32 ) && \ defined(CONFIG_TASN1 ) && \ (LIBGNUTLS_VERSION_NUMBER >=0x020600 )
tests/vhost-user-test.c +0 -2
@@ -20,8 +20,6 @@#include "libqos/pci-pc.h" #include "libqos/virtio-pci.h" -#include "libqos/pci-pc.h" -#include "libqos/virtio-pci.h" #include "libqos/malloc-pc.h" #include "hw/virtio/virtio-net.h"
util/oslib-posix.c +0 -1
@@ -28,7 +28,6 @@#include "qemu/osdep.h" #include <termios.h> -#include <termios.h> #include <glib/gprintf.h>
vl.c +0 -1
@@ -110,7 +110,6 @@ int main(int argc, char **argv)#include "trace.h" #include "trace/control.h" #include "qemu/queue.h" -#include "sysemu/cpus.h" #include "sysemu/arch_init.h" #include "ui/qemu-spice.h"
Signature · 1 line
2.7.4
Quoted 2 lines · Anand J
Some files contain multiple #includes of the same header file. Removed most of those unnecessary duplicate entries.
How did you find these? Is it a repeatable formula for rerunning a year from now to find new culprits? If so, listing it in the commit message would be worthwhile. Is it something we should add to scripts/clean-includes?
disas/libvixl/vixl/globals.h line 51
Quoted 13 lines
Signed-off-by Anand J <[email protected]>---
+++
b/disas/libvixl/vixl/globals.hdisas/libvixl/vixl/globals.h +0
-1@@ -46,7 +46,6 @@#include <assert.h> #include <stdarg.h> #include <stdio.h> -#include <stdint.h> #include <stdlib.h> #include <stddef.h> #include "vixl/platform.h"
scripts/clean-includes intentionally ignores disas/libvixl because that source is copied from elsewhere with minimal changes; are you sure this hunk is appropriate?
hw/pci-bridge/pci_expander_bridge.c line 17
Quoted 8 lines
+++
b/hw/pci-bridge/pci_expander_bridge.chw/pci-bridge/pci_expander_bridge.c +0
-1@@ -13,7 +13,6 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/pci/pci.h" -#include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" #include "hw/pci/pci_bus.h"
Changes like this are obviously correct...
hw/ppc/ppc405_boards.c line 41
Quoted 12 lines
hw/pci-bridge/pci_expander_bridge.c +0
-0#include "hw/pci/pci_bridge.h" hw/ppc/ppc405_boards.c +0
-1@@ -37,7 +37,6 @@#include "qemu/log.h" #include "qemu/error-report.h" #include "hw/loader.h" -#include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "exec/address-spaces.h"
...while changes like this require looking at context. But the nice part of this patch is that if it compiles, it is correct...
hw/ppc/ppc405_boards.c line 21
Quoted 8 lines
hw/ppc/ppc405_boards.c +1
-1+++ b/hw/usb/dev-mtp.c@@ -17,7 +17,6 @@#include <sys/statvfs.h> #ifdef CONFIG_INOTIFY1 #include <sys/inotify.h> -#include "qapi/error.h" #include "qemu/main-loop.h" #endif
...well, ones like this are a little trickier (if CONFIG_INOTIFY1 is not defined, a completed compilation is no indication of success - but reading context shows it is correct, and the duplicate include was just outside of the diff context).
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 11 lines · Eric Blake
hw/pci-bridge/pci_expander_bridge.c line 17
Quoted 8 lines · Anand J
+++
b/hw/pci-bridge/pci_expander_bridge.chw/pci-bridge/pci_expander_bridge.c +0
-1@@ -13,7 +13,6 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/pci/pci.h" -#include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" #include "hw/pci/pci_bus.h" Changes like this are obviously correct...
...assuming that pci_host.h doesn't implicitly depend on pci_bus.h having been included first. Deleting the second of the duplicate lines rather than the first might be safer.
thanks
-- PMM
I have replied for the questions inline. Also I'll make changes to the patch as per the review and send the updated one.
Thanks,
Anand
Quoted 9 lines · Eric Blake
Quoted 2 lines · Anand J
Some files contain multiple #includes of the same header file. Removed most of those unnecessary duplicate entries.
How did you find these? Is it a repeatable formula for rerunning a year from now to find new culprits? If so, listing it in the commit message would be worthwhile. Is it something we should add to
scripts/clean-includes?
I executed the following bash script to get multiple occurrences of #includes and manually checked each and every file from the output.
grep -r --exclude-dir=bin/ "#include" | sort | uniq -c | awk '{if ($1 > 1) print $2}'
But there are lot of noise in the output of this command. Most of the multiple #includes were not genuine issue. @Eric Do you want me to add this in the comment?
Quoted 5 lines
Quoted 4 lines
Signed-off-by Anand J <[email protected]>---
Quoted 14 lines
disas/libvixl/vixl/globals.h line 51
Quoted 9 lines
+++
b/disas/libvixl/vixl/globals.hdisas/libvixl/vixl/globals.h +0
-1@@ -46,7 +46,6 @@#include <assert.h> #include <stdarg.h> #include <stdio.h> -#include <stdint.h> #include <stdlib.h> #include <stddef.h> #include "vixl/platform.h"
scripts/clean-includesintentionally ignores disas/libvixl because that source is copied from elsewhere with minimal changes; are you sure this hunk is appropriate?
stdint.h is already included as the first #include in this file. But since this is a thrid-party file as per Peter, I'll remove this change.
Quoted 46 lines
hw/pci-bridge/pci_expander_bridge.c line 17
Quoted 8 lines
+++
b/hw/pci-bridge/pci_expander_bridge.chw/pci-bridge/pci_expander_bridge.c +0
-1@@ -13,7 +13,6 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/pci/pci.h" -#include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" #include "hw/pci/pci_bus.h" Changes like this are obviously correct...
hw/ppc/ppc405_boards.c line 41
Quoted 12 lines
hw/pci-bridge/pci_expander_bridge.c +0
-0#include "hw/pci/pci_bridge.h" hw/ppc/ppc405_boards.c +0
-1@@ -37,7 +37,6 @@#include "qemu/log.h" #include "qemu/error-report.h" #include "hw/loader.h" -#include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "exec/address-spaces.h" ...while changes like this require looking at context. But the nice part of this patch is that if it compiles, it is correct...
hw/ppc/ppc405_boards.c line 21
Quoted 8 lines
hw/ppc/ppc405_boards.c +1
-1+++ b/hw/usb/dev-mtp.c@@ -17,7 +17,6 @@#include <sys/statvfs.h> #ifdef CONFIG_INOTIFY1 #include <sys/inotify.h> -#include "qapi/error.h" #include "qemu/main-loop.h" #endif ...well, ones like this are a little trickier (if
CONFIG_INOTIFY1is not defined, a completed compilation is no indication of success - but reading context shows it is correct, and the duplicate include was just outside of the diff context).--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Quoted 17 lines · Anand J
I have replied for the questions inline. Also I'll make changes to the patch as per the review and send the updated one.
Thanks,
AnandQuoted 9 lines · Eric Blake
Quoted 2 lines · Anand J
Some files contain multiple #includes of the same header file. Removed most of those unnecessary duplicate entries.
How did you find these? Is it a repeatable formula for rerunning a year from now to find new culprits? If so, listing it in the commit message would be worthwhile. Is it something we should add to
scripts/clean-includes?
Quoted 5 lines
I executed the following bash script to get multiple occurrences of #includes and manually checked each and every file from the output.
grep -r --exclude-dir=bin/ "#include" | sort | uniq -c | awk '{if ($1 > 1) print $2}'
Seems simple enough that we ought to make it part of the scripts/clean-includes, rather than remembering to manually run it.
Quoted 4 lines
But there are lot of noise in the output of this command. Most of the multiple #includes were not genuine issue. @Eric Do you want me to add this in the comment?
Yes - whatever we end up with (whether a manual script or a run of scripts/clean-includes), documenting the process used makes it easier to verify that you didn't miss anything, and for someone else to repeat the process in another year when some mistakes have crept back in during the meantime.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 21 lines · Eric Blake
Quoted 20 lines · Anand J
I have replied for the questions inline. Also I'll make changes to the patch as per the review and send the updated one.
Thanks,
AnandQuoted 9 lines · Eric Blake
Quoted 2 lines · Anand J
Some files contain multiple #includes of the same header file. Removed most of those unnecessary duplicate entries.
How did you find these? Is it a repeatable formula for rerunning a year from now to find new culprits? If so, listing it in the commit message would be worthwhile. Is it something we should add to
scripts/clean-includes?I executed the following bash script to get multiple occurrences of #includes and manually checked each and every file from the output.
Quoted 7 lines
Quoted 1 line
grep -r --exclude-dir=bin/ "#include" | sort | uniq -c | awk '{if ($1 >
1)
Quoted 1 line
print $2}'
Seems simple enough that we ought to make it part of the
scripts/clean-includes, rather than remembering to manually run it.
scripts/clean-includes does an in place modification of the duplicate entries in the files.
There is no guarantee that my script with return all genuine duplicate entries. Some can be false positive as well.
Are you asking me to add this script in as a comment in scripts/clean-includes files? Like the one
for checking if all the files start with #include "osdep.h" ?
# for i in $(git ls-tree --name-only HEAD) ; do test -f $i && \ # grep -E '^# *include' $i | head -1 | grep 'osdep.h' ; test $? != 0 && \ # echo $i ; done
Quoted 12 lines
Quoted 3 lines
But there are lot of noise in the output of this command. Most of the multiple #includes were not genuine issue. @Eric Do you want me to add
this
Quoted 1 line
in the comment?
Yes - whatever we end up with (whether a manual script or a run of
scripts/clean-includes), documenting the process used makes it easier to verify that you didn't miss anything, and for someone else to repeat the process in another year when some mistakes have crept back in during the meantime.
agree. Adding to the comments for future reference.
Quoted 6 lines
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Quoted 4 lines · Anand J
Quoted 4 lines
Quoted 1 line
grep -r --exclude-dir=bin/ "#include" | sort | uniq -c | awk '{if ($1 >
1)
Quoted 1 line
print $2}'
Quoted 8 lines
Quoted 3 lines
Seems simple enough that we ought to make it part of the
scripts/clean-includes, rather than remembering to manually run it.
scripts/clean-includesdoes an in place modification of the duplicate entries in the files.
There is no guarantee that my script with return all genuine duplicate entries. Some can be false positive as well.
If you don't trust an in-place modification, then maybe it is simple enough to just make scripts/clean-includes fail with non-zero status and flag that the files need manual attention, then rerunning the script. But still, having the script be able to flag the problems, whether or not it can fix them, is better than making it a comment where no one remembers to manually run the comment.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 6 lines · Anand J
Some files contain multiple #includes of the same header file. Removed most of those unnecessary duplicate entries.
Signed-off-by Anand J <[email protected]>disas/libvixl/vixl/globals.h | 1 -
This is a third party file which we copy into our tree; we prefer to avoid making changes to our local copy unless they're critically required.
thanks
-- PMM