more include cleaning
Subsystems (4)
cover more include cleaning
This patchset makes more progress with with cleaning our include use and is hopefully the last of the big ones (there are some other minor fixups that can be done after).
Patch 1 is already in Andreas' QOM tree but I include it for convenience since without it things will fail to compile later in the series.
Patch 2 fixes a problem with including osdep.h first in arm-a64.cc if the compiler doesn't support C++11 Patch 3 is the previously sent arm-a64.cc change Patches 4 and 5 add support to the clean-includes script for working on .h files, and for saying "run on everything in the source tree"
Patch 6 fixes something I had forgotten about -- osdep.h needs to include config-target.h if the object file being built is a per-target one!
Patch 7 is the results of cleaning everything except include/. Patch 8 cleans include/.
In particular, since patch 8 removes the osdep.h include from qemu-common.h it is where you will see compile failures if anything isn't including osdep.h (this builds fine against current master but might break in-flight patches and other out of tree code if it does not include osdep.h everywhere it should).
I could split patches 7 and 8 up into smaller chunks if that seems helpful to people, but I figured they weren't too terrible as-is.
thanks
-- PMM
Peter Maydell (8):
cpu: Clean up includes
osdep.h: Define macros for the benefit of C++ before C++11 disas/arm-a64.cc: Include osdep.h first scripts/clean-includes: Enhance to handle header files scripts/clean-includes: Add --all option osdep.h: Include config-target.h if NEED_CPU_H is defined
all: Clean up includes
include: Clean up includes
audio/audio.h | 1 - bsd-user/qemu.h | 3 -- contrib/ivshmem-client/ivshmem-client.h | 1 - contrib/ivshmem-server/ivshmem-server.h | 3 -- disas/arm-a64.cc | 5 ++- fsdev/file-op-9p.h | 3 -- hw/9pfs/9p-synth.h | 3 -- hw/9pfs/9p.h | 2 - hw/audio/gusemu.h | 1 - hw/display/vga_int.h | 1 - hw/net/fsl_etsec/registers.h | 1 - hw/usb/desc.h | 1 - include/block/accounting.h | 2 - include/block/nbd.h | 1 - include/block/snapshot.h | 1 - include/block/write-threshold.h | 1 - include/config.h | 1 - include/crypto/cipher.h | 1 - include/crypto/hash.h | 1 - include/crypto/init.h | 1 - include/crypto/secret.h | 1 - include/crypto/tlscreds.h | 1 - include/elf.h | 1 - include/exec/cpu-all.h | 1 - include/exec/cpu-defs.h | 3 -- include/exec/helper-head.h | 1 - include/exec/memory.h | 3 -- include/exec/user/thunk.h | 1 - include/fpu/softfloat.h | 3 -- include/hw/acpi/acpi.h | 1 - include/hw/acpi/aml-build.h | 2 - include/hw/acpi/bios-linker-loader.h | 2 - include/hw/acpi/pcihp.h | 1 - include/hw/block/block.h | 1 - include/hw/i386/topology.h | 2 - include/hw/isa/apm.h | 1 - include/hw/nvram/fw_cfg.h | 2 - include/hw/pci/pci.h | 1 - include/hw/pci/shpc.h | 1 - include/hw/qdev-core.h | 1 - include/hw/virtio/vhost-backend.h | 1 - include/hw/xen/xen.h | 1 - include/hw/xen/xen_common.h | 3 -- include/io/channel.h | 1 - include/io/task.h | 1 - include/libdecnumber/dconfig.h | 1 - include/libdecnumber/decContext.h | 3 -- include/libdecnumber/decNumberLocal.h | 2 - include/migration/migration.h | 1 - include/migration/qemu-file.h | 1 - include/net/checksum.h | 1 - include/net/eth.h | 2 - include/qapi/error.h | 3 -- include/qapi/qmp-event.h | 1 - include/qapi/qmp/dispatch.h | 1 - include/qapi/qmp/json-lexer.h | 1 - include/qapi/qmp/json-parser.h | 1 - include/qapi/qmp/json-streamer.h | 2 - include/qapi/qmp/qbool.h | 1 - include/qapi/qmp/qdict.h | 2 - include/qapi/qmp/qfloat.h | 1 - include/qapi/qmp/qint.h | 1 - include/qapi/qmp/qjson.h | 2 - include/qapi/qmp/qobject.h | 2 - include/qapi/qmp/qstring.h | 1 - include/qapi/visitor-impl.h | 1 - include/qapi/visitor.h | 2 - include/qemu-common.h | 1 - include/qemu/atomic.h | 1 - include/qemu/bitmap.h | 3 -- include/qemu/bitops.h | 2 - include/qemu/bswap.h | 5 --- include/qemu/compatfd.h | 1 - include/qemu/compiler.h | 1 - include/qemu/config-file.h | 2 - include/qemu/coroutine.h | 1 - include/qemu/error-report.h | 3 -- include/qemu/fprintf-fn.h | 2 - include/qemu/hbitmap.h | 3 -- include/qemu/host-utils.h | 3 -- include/qemu/int128.h | 3 -- include/qemu/log.h | 4 -- include/qemu/memfd.h | 2 - include/qemu/module.h | 1 - include/qemu/option.h | 2 - include/qemu/osdep.h | 17 +++++++++ include/qemu/range.h | 1 - include/qemu/rcu.h | 7 ---- include/qemu/sockets.h | 2 - include/qemu/thread.h | 2 - include/qemu/throttle.h | 1 - include/qemu/timed-average.h | 1 - include/qemu/xattr.h | 1 - include/qom/cpu.h | 1 - include/qom/object.h | 3 -- include/sysemu/block-backend.h | 1 - include/sysemu/blockdev.h | 1 - include/sysemu/dma.h | 1 - include/sysemu/hostmem.h | 1 - include/sysemu/kvm.h | 2 - include/sysemu/numa.h | 1 - include/sysemu/os-posix.h | 1 - include/sysemu/qtest.h | 1 - include/sysemu/replay.h | 3 -- include/sysemu/rng.h | 1 - include/sysemu/seccomp.h | 1 - include/sysemu/tpm_backend.h | 1 - include/sysemu/xen-mapcache.h | 1 - include/ui/console.h | 1 - include/ui/qemu-spice.h | 1 - io/channel-util.c | 1 + linux-user/arm/nwfpe/fpa11.h | 3 -- linux-user/qemu.h | 3 -- nbd/nbd-internal.h | 4 -- net/tap-linux.h | 1 - net/util.h | 1 - qemu-nbd.c | 2 - qga/vss-win32.h | 1 - qga/vss-win32/requester.h | 1 - qga/vss-win32/vss-common.h | 1 - qom/cpu.c | 1 + replay/replay-internal.h | 1 - scripts/clean-includes | 66 ++++++++++++++++++++++++++++----- slirp/slirp.h | 18 --------- target-alpha/cpu.h | 1 - target-arm/cpu.h | 1 - target-arm/kvm-consts.h | 1 - target-cris/cpu.h | 1 - target-i386/cpu-qom.h | 1 - target-i386/cpu.c | 5 +-- target-i386/cpu.h | 1 - target-i386/mpx_helper.c | 1 + target-lm32/cpu.h | 1 - target-m68k/cpu.h | 1 - target-microblaze/cpu.h | 1 - target-mips/cpu.h | 1 - target-moxie/cpu.h | 1 - target-openrisc/cpu.h | 1 - target-ppc/cpu.h | 1 - target-s390x/cpu.h | 1 - target-sh4/cpu.h | 1 - target-sparc/cpu.h | 1 - target-tilegx/cpu.h | 1 - target-tricore/cpu.h | 1 - target-unicore32/cpu.h | 1 - target-xtensa/cpu.h | 1 - tcg/tci/tcg-target.h | 1 - tests/libqos/ahci.h | 3 -- tests/libqos/fw_cfg.h | 2 - tests/libqos/i2c.h | 1 - tests/libqos/malloc.h | 2 - tests/libqos/pci.h | 1 - tests/libqtest.h | 6 --- trace/control-internal.h | 1 - trace/ftrace.h | 1 - trace/simple.h | 3 -- ui/vnc-palette.h | 2 - ui/vnc.h | 1 - 158 files changed, 81 insertions(+), 271 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/8 cpu: Clean up includes
Clean up includes so that osdep.h is included first and headers which it implies are not included manually.
This commit was created with scripts/clean-includes.
--- qom/cpu.c | 1 + target-i386/cpu.c | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-)
qom/cpu.c +1 -0
@@ -18,6 +18,7 @@* <http://www.gnu.org/licenses/gpl-2.0.html> */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "qom/cpu.h" #include "sysemu/kvm.h"
target-i386/cpu.c +1 -4
@@ -16,10 +16,7 @@* 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/>. */ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <inttypes.h> +#include "qemu/osdep.h" #include "cpu.h" #include "sysemu/kvm.h"
Signature · 1 line
1.9.1
PATCH 2/8 osdep.h: Define macros for the benefit of C++ before C++11
In reply to Peter MaydellFor C++ before C++11, <stdint.h> requires definition of the macros __STDC_CONSTANT_MACROS, __STDC_LIMIT_MACROS and __STDC_FORMAT_MACROS in order to enable definition of various macros by the header file. Define these in osdep.h, so that we get the right header file definitions whether osdep.h is being used by plain C, C++11 or older C++.
In particular libvixl's header files depend on this and won't compile if osdep.h is included before them otherwise.
--- include/qemu/osdep.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
include/qemu/osdep.h +14 -0
@@ -28,6 +28,20 @@#include "config-host.h" #include "qemu/compiler.h" +/* Older versions of C++ don't get definitions of various macros from +* stdlib.h unless we define these macros before first inclusion of +* that system header. +*/ +#ifndef __STDC_CONSTANT_MACROS +#define __STDC_CONSTANT_MACROS +#endif +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS +#endif +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif +/* The following block of code temporarily renames the daemon() function so the * compiler does not see the warning associated with it in stdlib.h on OSX */
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PATCH 2/8] osdep.h: Define macros for the benefit of C++ before C++11
Quoted 7 lines · Peter Maydell
For C++ before C++11, <
stdint.h> requires definition of the macros__STDC_CONSTANT_MACROS,__STDC_LIMIT_MACROSand__STDC_FORMAT_MACROSin order to enable definition of various macros by the header file. Define these inosdep.h, so that we get the right header file definitions whetherosdep.his being used by plain C, C++11 or older C++.
Quoted 7 lines
In particular libvixl's header files depend on this and won't compile if
osdep.his included before them otherwise.Signed-off-by Peter Maydell <[email protected]>--- include/qemu/osdep.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
include/qemu/osdep.h line 37
Quoted 7 lines
include/qemu/osdep.h +7
-0+/* Older versions of C++ don't get definitions of various macros from +* stdlib.h unless we define these macros before first inclusion of +* that system header. +*/ +#ifndef __STDC_CONSTANT_MACROS +#define __STDC_CONSTANT_MACROS +#endif
Style nit: In libvirt, we've grown used to writing:
#ifndef ...
# define ... #endif
that is, use spacing to make it more visually obvious what level of conditional nesting is in effect during preprocessor lines. But short of a tree-wide change to enforce that style (which I'm not advocating), it's more of a food for thought comment, and has no bearing on taking this series as is.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 3/8 disas/arm-a64.cc: Include osdep.h first
In reply to Peter MaydellRearrange include directives so that we include osdep.h first. This has to be done manually because clean-includes doesn't handle C++.
--- disas/arm-a64.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
disas/arm-a64.cc +3 -2
@@ -17,12 +17,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "vixl/a64/disasm-a64.h" - extern "C" { +#include "qemu/osdep.h" #include "disas/bfd.h" } +#include "vixl/a64/disasm-a64.h" + using namespace vixl; static Decoder *vixl_decoder = NULL;
Signature · 1 line
1.9.1
PATCH 4/8 scripts/clean-includes: Enhance to handle header files
In reply to Peter MaydellEnhance clean-includes to handle header files as well as .c source files. For headers we merely remove all the redundant #include lines, including any includes of qemu/osdep.h itself.
There is a simple mollyguard on the include file processing to skip a few key headers like osdep.h itself, to avoid producing bad patches if the script is run on every file in include/.
--- scripts/clean-includes | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-)
scripts/clean-includes +42 -8
@@ -1,7 +1,8 @@ #!/bin/sh -e # # Clean up QEMU #include lines by ensuring that qemu/osdep.h -# is the first include listed. +# is the first include listed, and no headers provided by +# osdep.h itself are redundantly included. # # Copyright (c) 2015 Linaro Limited #
@@ -22,6 +23,11 @@ # This script requires Coccinelle to be installed. +# .c files will have the osdep.h included added, and redundant +# includes removed. +# .h files will have redundant includes (including includes of osdep.h) +# removed. +# Other files (including C++ and ObjectiveC) can't be handled by this script. # The following one-liner may be handy for finding files to run this on. # However some caution is required regarding files that might be part
@@ -73,13 +79,41 @@ EOT for f in "$@"; do - # First, use coccinelle to add qemu/osdep.h before the first existing include - # (this will add two lines if the file uses both "..." and <...> #includes, - # but we will remove the extras in the next step) - spatch --in-place --no-show-diff --cocci-file "$COCCIFILE" "$f" - - # Now remove any duplicate osdep.h includes - perl -n -i -e 'print if !/#include "qemu\/osdep.h"/ || !$n++;' "$f" + case "$f" in + *.c) + MODE=c + ;; + *include/qemu/osdep.h|include/qemu/compiler.h|include/config.h|include/standard-headers/) + # Removing include lines from osdep.h itself would be counterproductive. + echo "SKIPPING $f (special case header)" + continue + ;; + *include/standard-headers/*) + echo "SKIPPING $f (autogenerated header)" + continue + ;; + *.h) + MODE=h + ;; + *) + echo "WARNING: ignoring $f (cannot handle non-C files)" + continue + ;; + esac + + if [ "$MODE" = "c" ]; then + # First, use coccinelle to add qemu/osdep.h before the first existing include + # (this will add two lines if the file uses both "..." and <...> #includes, + # but we will remove the extras in the next step) + spatch --in-place --no-show-diff --cocci-file "$COCCIFILE" "$f" + + # Now remove any duplicate osdep.h includes + perl -n -i -e 'print if !/#include "qemu\/osdep.h"/ || !$n++;' "$f" + else + # Remove includes of osdep.h itself + perl -n -i -e 'print if !/\s*#\s*include\s*(["<][^>"]*[">])/ || + ! (grep { $_ eq $1 } qw ("qemu/osdep.h"))' "$f" + fi # Remove includes that osdep.h already provides perl -n -i -e 'print if !/\s*#\s*include\s*(["<][^>"]*[">])/ ||
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files
Quoted 10 lines · Peter Maydell
Enhance clean-includes to handle header files as well as .c source files. For headers we merely remove all the redundant #include lines, including any includes of
qemu/osdep.hitself.There is a simple mollyguard on the include file processing to skip a few key headers like
osdep.hitself, to avoid producing bad patches if the script is run on every file ininclude/.Signed-off-by Peter Maydell <[email protected]>Reviewed-by Eric Blake <[email protected]>
Hmm, I'm not sure why this ended up with an R-b tag from Eric because I'm pretty sure this is the first time I've sent it to the list. Sorry about that, and please ignore that r-b tag...
thanks
-- PMM
Re: [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files
In reply to Peter MaydellQuoted 8 lines · Peter Maydell
Enhance clean-includes to handle header files as well as .c source files. For headers we merely remove all the redundant #include lines, including any includes of
qemu/osdep.hitself.There is a simple mollyguard on the include file processing to skip a few key headers like
osdep.hitself, to avoid producing bad patches if the script is run on every file ininclude/.
Quoted 5 lines
Signed-off-by Peter Maydell <[email protected]>Reviewed-by Eric Blake <[email protected]>--- scripts/clean-includes | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-)
I already saw your followup explaining about the spurious R-b, so let's make it real this time :)
scripts/clean-includes line 5
Quoted 12 lines
scripts/clean-includes +2
-1@@ -1,7 +1,8 @@ #!/bin/sh -e # # Clean up QEMU #include lines by ensuring that qemu/osdep.h -# is the first include listed. +# is the first include listed, and no headers provided by +# osdep.h itself are redundantly included.
Do you want to mention 'is the first include listed in .c files', now that this cleanup also scrubs .h files? Or, since you go into details below and this is just the summary, maybe 'is the first include encountered'?
scripts/clean-includes line 7
Quoted 2 lines
scripts/clean-includes +0
-0# # Copyright (c) 2015 Linaro Limited
Want to add 2016?
scripts/clean-includes line 29
Quoted 9 lines
scripts/clean-includes +4
-0#@@ -22,6 +23,11 @@ # This script requires Coccinelle to be installed. +# .c files will have the osdep.h included added, and redundant +# includes removed. +# .h files will have redundant includes (including includes of osdep.h) +# removed.
Maybe a note here that "this is because any other .h file will not be included by a .c file until after osdep.h" ? Or is that too verbose?
scripts/clean-includes EOT · line 86
Quoted 5 lines
scripts/clean-includes +5
-0+ case "$f" in + *.c) + MODE=c + ;; + *include/qemu/osdep.h|include/qemu/compiler.h|include/config.h|include/standard-headers/)
Spaces around | may make this more legible, and doesn't affect correctness.
scripts/clean-includes EOT · line 105
Quoted 3 lines
scripts/clean-includes +3
-0+ + if [ "$MODE" = "c" ]; then + # First, use coccinelle to add qemu/osdep.h before the first existing include
Should the tool name be capitalized as Coccinelle?
scripts/clean-includes EOT · line 111
Quoted 6 lines
scripts/clean-includes +6
-0+ # (this will add two lines if the file uses both "..." and <...> #includes, + # but we will remove the extras in the next step) + spatch --in-place --no-show-diff --cocci-file "$COCCIFILE" "$f" + + # Now remove any duplicate osdep.h includes + perl -n -i -e 'print if !/#include "qemu\/osdep.h"/ || !$n++;' "$f"
Why two spaces before -e?
I can understand the use of perl here (detecting duplicates lines is doable, but a lot harder, in sed),...
scripts/clean-includes EOT · line 115
Quoted 4 lines
scripts/clean-includes +4
-0+ else + # Remove includes of osdep.h itself + perl -n -i -e 'print if !/\s*#\s*include\s*(["<][^>"]*[">])/ || + ! (grep { $_ eq $1 } qw ("qemu/osdep.h"))' "$f"
...but this could be shortened, if you wanted:
sed -i '/#[[:space:]]*include[[:space:]]*["<]qemu/osdep.h[">]/d' "$f"
My findings are minor; functionally, your patch is sane, so the accidental R-b can now be treated as real, if you don't want to respin.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files
Quoted 19 lines · Eric Blake
Quoted 8 lines · Peter Maydell
Enhance clean-includes to handle header files as well as .c source files. For headers we merely remove all the redundant #include lines, including any includes of
qemu/osdep.hitself.There is a simple mollyguard on the include file processing to skip a few key headers like
osdep.hitself, to avoid producing bad patches if the script is run on every file ininclude/.Quoted 5 lines
Signed-off-by Peter Maydell <[email protected]>Reviewed-by Eric Blake <[email protected]>--- scripts/clean-includes | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-)I already saw your followup explaining about the spurious R-b, so let's make it real this time :)
Quoted 1 line
Quoted 16 lines
scripts/clean-includes line 5
Quoted 11 lines
scripts/clean-includes +2
-1@@ -1,7 +1,8 @@ #!/bin/sh -e # # Clean up QEMU #include lines by ensuring that qemu/osdep.h -# is the first include listed. +# is the first include listed, and no headers provided by +# osdep.h itself are redundantly included.Do you want to mention 'is the first include listed in .c files', now that this cleanup also scrubs .h files? Or, since you go into details below and this is just the summary, maybe 'is the first include encountered'?
OK.
Quoted 4 lines
scripts/clean-includes line 7
Quoted 2 lines
scripts/clean-includes +0
-0# # Copyright (c) 2015 Linaro LimitedWant to add 2016?
Most of the Copyright lines in QEMU source files are probably out of date; I'm not convinced that touching the Copyright line for the first patch to each source file each year really gains us anything.
Quoted 5 lines
Quoted 5 lines
scripts/clean-includes +0
-0#@@ -22,6 +23,11 @@ # This script requires Coccinelle to be installed.
Quoted 7 lines
scripts/clean-includes line 29
Quoted 4 lines
scripts/clean-includes +4
-0+# .c files will have the osdep.h included added, and redundant +# includes removed. +# .h files will have redundant includes (including includes of osdep.h) +# removed.Maybe a note here that "this is because any other .h file will not be included by a .c file until after
osdep.h" ? Or is that too verbose?
Feels a touch over-verbose to me.
Quoted 7 lines
scripts/clean-includes EOT · line 86
Quoted 5 lines
scripts/clean-includes +5
-0+ case "$f" in + *.c) + MODE=c + ;; + *include/qemu/osdep.h|include/qemu/compiler.h|include/config.h|include/standard-headers/)Spaces around | may make this more legible, and doesn't affect correctness.
OK.
Quoted 5 lines
scripts/clean-includes EOT · line 105
Quoted 3 lines
scripts/clean-includes +3
-0+ + if [ "$MODE" = "c" ]; then + # First, use coccinelle to add qemu/osdep.h before the first existing includeShould the tool name be capitalized as Coccinelle?
OK.
Quoted 8 lines
scripts/clean-includes EOT · line 111
Quoted 6 lines
scripts/clean-includes +6
-0+ # (this will add two lines if the file uses both "..." and <...> #includes, + # but we will remove the extras in the next step) + spatch --in-place --no-show-diff --cocci-file "$COCCIFILE" "$f" + + # Now remove any duplicate osdep.h includes + perl -n -i -e 'print if !/#include "qemu\/osdep.h"/ || !$n++;' "$f"Why two spaces before -e?
Accidental.
Quoted 11 lines
I can understand the use of perl here (detecting duplicates lines is doable, but a lot harder, in sed),...
scripts/clean-includes EOT · line 115
Quoted 4 lines
scripts/clean-includes +4
-0+ else + # Remove includes of osdep.h itself + perl -n -i -e 'print if !/\s*#\s*include\s*(["<][^>"]*[">])/ || + ! (grep { $_ eq $1 } qw ("qemu/osdep.h"))' "$f"...but this could be shortened, if you wanted:
sed -i '/#[[:space:]]*include[[:space:]]*["<]qemu/osdep.h[">]/d' "$f"
The next perl line (only partially visible in the diff context) is doing basically the same job for a larger set of header files, so I preferred to retain the same code to do the same thing, even if in this case there's only one header in the list.
Quoted 2 lines
My findings are minor; functionally, your patch is sane, so the accidental R-b can now be treated as real, if you don't want to respin.
Thanks. I'll fix the minor space/comment issues above, but won't resend unless I need to redo the series for some other reason.
-- PMM
Re: [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files
In reply to Eric BlakeQuoted 54 lines · Eric Blake
Quoted 8 lines · Peter Maydell
Enhance clean-includes to handle header files as well as .c source files. For headers we merely remove all the redundant #include lines, including any includes of
qemu/osdep.hitself.There is a simple mollyguard on the include file processing to skip a few key headers like
osdep.hitself, to avoid producing bad patches if the script is run on every file ininclude/.Quoted 5 lines
Signed-off-by Peter Maydell <[email protected]>Reviewed-by Eric Blake <[email protected]>--- scripts/clean-includes | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-)I already saw your followup explaining about the spurious R-b, so let's make it real this time :)
scripts/clean-includes line 5
Quoted 12 lines
scripts/clean-includes +2
-1@@ -1,7 +1,8 @@ #!/bin/sh -e # # Clean up QEMU #include lines by ensuring that qemu/osdep.h -# is the first include listed. +# is the first include listed, and no headers provided by +# osdep.h itself are redundantly included.Do you want to mention 'is the first include listed in .c files', now that this cleanup also scrubs .h files? Or, since you go into details below and this is just the summary, maybe 'is the first include encountered'?
scripts/clean-includes line 7
Quoted 2 lines
scripts/clean-includes +0
-0# # Copyright (c) 2015 Linaro LimitedWant to add 2016?
scripts/clean-includes line 29
Quoted 9 lines
scripts/clean-includes +4
-0#@@ -22,6 +23,11 @@ # This script requires Coccinelle to be installed. +# .c files will have the osdep.h included added, and redundant +# includes removed. +# .h files will have redundant includes (including includes of osdep.h) +# removed.Maybe a note here that "this is because any other .h file will not be included by a .c file until after
osdep.h" ? Or is that too verbose?
Quoted 7 lines
scripts/clean-includes EOT · line 86
Quoted 5 lines
scripts/clean-includes +5
-0+ case "$f" in + *.c) + MODE=c + ;; + *include/qemu/osdep.h|include/qemu/compiler.h|include/config.h|include/standard-headers/)Spaces around | may make this more legible, and doesn't affect correctness.
Your comment here reveals a bug, incidentally -- I meant (with the '*' at the front) to make this work whether $f was "include/foo.h" or "./include/foo.h" or "/path/to/qemu/include/foo.h". I guess I want
*include/qemu/osdep.h | \
*include/qemu/compiler.h | \
*include/config.h | \
*include/standard-headers/ )(including some line breaks to help readability a little).
thanks
-- PMM
PATCH 5/8 scripts/clean-includes: Add --all option
In reply to Peter MaydellAdd a --all option which will run the script on every C source and header file in the repository (except for those in a few directories which contain standalone guest code).
--- scripts/clean-includes | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
scripts/clean-includes +15 -1
@@ -15,11 +15,17 @@ # Usage: # clean-includes [--git subjectprefix] file ... +# or +# clean-includes [--git subjectprefix] --all # # If the --git subjectprefix option is given, then after making # the changes to the files this script will create a git commit # with the subject line "subjectprefix: Clean up includes" # and a boilerplate commit message. +# +# Using --all will cause clean-includes to run on the whole source +# tree (excluding certain directories which are known not to need +# handling). # This script requires Coccinelle to be installed.
@@ -40,6 +46,9 @@ GIT=no +# Regular expression defining files to ignore when using --all +XDIRREGEX='^(tests/tcg|tests/multiboot|pc-bios|disas/libvixl)' + if [ $# -ne 0 ] && [ "$1" = "--git" ]; then if [ $# -eq 1 ]; then echo "--git option requires an argument"
@@ -52,11 +61,16 @@ if [ $# -ne 0 ] && [ "$1" = "--git" ]; then fi if [ $# -eq 0 ]; then - echo "Usage: clean-includes [--git subjectprefix] foo.c ..." + echo "Usage: clean-includes [--git subjectprefix] [--all | foo.c ...]" echo "(modifies the files in place)" exit 1 fi +if [ "$1" = "--all" ]; then + # We assume there are no files in the tree with spaces in their name + set -- $(git ls-files '*.[ch]' | egrep -v "$XDIRREGEX") +fi + # Annoyingly coccinelle won't read a scriptfile unless its # name ends '.cocci', so write it out to a tempfile with the # right kind of name.
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PATCH 5/8] scripts/clean-includes: Add --all option
Quoted 11 lines · Peter Maydell
Add a --all option which will run the script on every C source and header file in the repository (except for those in a few directories which contain standalone guest code).
Signed-off-by Peter Maydell <[email protected]>--- scripts/clean-includes | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)+# Regular expression defining files to ignore when using --all
s/Regular/Extended regular/, to make it obvious which flavor we are using? (But yes to ERE; it's a pain to write \(..\|..\) in BRE).
scripts/clean-includes if [ $# -ne 0 ] && [ "$1" = "--git" ]; then · line 71
Quoted 8 lines
scripts/clean-includes +5
-0+XDIRREGEX='^(tests/tcg|tests/multiboot|pc-bios|disas/libvixl)' + if [ $# -ne 0 ] && [ "$1" = "--git" ]; then +if [ "$1" = "--all" ]; then + # We assume there are no files in the tree with spaces in their name + set -- $(git ls-files '*.[ch]' | egrep -v "$XDIRREGEX")
'grep -E' is slightly more portable than 'egrep'.
We could perhaps patch checkpatch.pl to enforce that no new files with stupid names are checked in...
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 6/8 osdep.h: Include config-target.h if NEED_CPU_H is defined
In reply to Peter MaydellNEED_CPU_H is the define we use to distinguish per-target object compilation from common object compilation. For the former, we must also include config-target.h so that the .c files see the necessary CONFIG_ constants.
--- include/qemu/osdep.h | 3 +++ 1 file changed, 3 insertions(+)
include/qemu/osdep.h +3 -0
@@ -26,6 +26,9 @@#define QEMU_OSDEP_H #include "config-host.h" +#ifdef NEED_CPU_H +#include "config-target.h" +#endif #include "qemu/compiler.h" /* Older versions of C++ don't get definitions of various macros from
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PATCH 6/8] osdep.h: Include config-target.h if NEED_CPU_H is defined
Quoted 15 lines · Peter Maydell
NEED_CPU_His the define we use to distinguish per-target object compilation from common object compilation. For the former, we must also includeconfig-target.hso that the .c files see the necessaryCONFIG_constants.Signed-off-by Peter Maydell <[email protected]>--- include/qemu/osdep.h | 3 +++ 1 file changed, 3 insertions(+)include/qemu/osdep.h +0
-0
include/qemu/osdep.h line 32
Quoted 7 lines
include/qemu/osdep.h +3
-0@@ -26,6 +26,9 @@#define QEMU_OSDEP_H #include "config-host.h" +#ifdef NEED_CPU_H +#include "config-target.h" +#endif #include "qemu/compiler.h"
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 7/8 all: Clean up includes
In reply to Peter MaydellClean up includes so that osdep.h is included first and headers which it implies are not included manually.
This commit was created with scripts/clean-includes.
--- audio/audio.h | 1 - bsd-user/qemu.h | 3 --- contrib/ivshmem-client/ivshmem-client.h | 1 - contrib/ivshmem-server/ivshmem-server.h | 3 --- fsdev/file-op-9p.h | 3 --- hw/9pfs/9p-synth.h | 3 --- hw/9pfs/9p.h | 2 -- hw/audio/gusemu.h | 1 - hw/display/vga_int.h | 1 - hw/net/fsl_etsec/registers.h | 1 - hw/usb/desc.h | 1 - io/channel-util.c | 1 + linux-user/arm/nwfpe/fpa11.h | 3 --- linux-user/qemu.h | 3 --- nbd/nbd-internal.h | 4 ---- net/tap-linux.h | 1 - net/util.h | 1 - qemu-nbd.c | 2 -- qga/vss-win32.h | 1 - qga/vss-win32/requester.h | 1 - qga/vss-win32/vss-common.h | 1 - replay/replay-internal.h | 1 - slirp/slirp.h | 18 ------------------ target-alpha/cpu.h | 1 - target-arm/cpu.h | 1 - target-arm/kvm-consts.h | 1 - target-cris/cpu.h | 1 - target-i386/cpu-qom.h | 1 - target-i386/cpu.h | 1 - target-i386/mpx_helper.c | 1 + target-lm32/cpu.h | 1 - target-m68k/cpu.h | 1 - target-microblaze/cpu.h | 1 - target-mips/cpu.h | 1 - target-moxie/cpu.h | 1 - target-openrisc/cpu.h | 1 - target-ppc/cpu.h | 1 - target-s390x/cpu.h | 1 - target-sh4/cpu.h | 1 - target-sparc/cpu.h | 1 - target-tilegx/cpu.h | 1 - target-tricore/cpu.h | 1 - target-unicore32/cpu.h | 1 - target-xtensa/cpu.h | 1 - tcg/tci/tcg-target.h | 1 - tests/libqos/ahci.h | 3 --- tests/libqos/fw_cfg.h | 2 -- tests/libqos/i2c.h | 1 - tests/libqos/malloc.h | 2 -- tests/libqos/pci.h | 1 - tests/libqtest.h | 6 ------ trace/control-internal.h | 1 - trace/ftrace.h | 1 - trace/simple.h | 3 --- ui/vnc-palette.h | 2 -- ui/vnc.h | 1 - 56 files changed, 2 insertions(+), 100 deletions(-)
audio/audio.h +0 -1
@@ -24,7 +24,6 @@#ifndef QEMU_AUDIO_H #define QEMU_AUDIO_H -#include "config-host.h" #include "qemu/queue.h" typedef void (*audio_callback_fn ) (void *opaque,int avail);
bsd-user/qemu.h +0 -3
@@ -17,15 +17,12 @@#ifndef QEMU_H #define QEMU_H -#include <signal.h> -#include <string.h> #include "cpu.h" #include "exec/cpu_ldst.h" #undef DEBUG_REMAP#ifdef DEBUG_REMAP -#include <stdlib.h> #endif /* DEBUG_REMAP */ #include "exec/user/abitypes.h"
contrib/ivshmem-client/ivshmem-client.h +0 -1
@@ -19,7 +19,6 @@* purposes. */ -#include <limits.h> #include <sys/select.h> #include "qemu/queue.h"
contrib/ivshmem-server/ivshmem-server.h +0 -3
@@ -26,10 +26,7 @@* associated to the ivshmem shared memory. */ -#include <limits.h> #include <sys/select.h> -#include <stdint.h> -#include <stdbool.h> #include "qemu/event_notifier.h" #include "qemu/queue.h"
fsdev/file-op-9p.h +0 -3
@@ -12,11 +12,8 @@*/ #ifndef _FILEOP_H#define _FILEOP_H -#include <sys/types.h> #include <dirent.h> -#include <sys/time.h> #include <utime.h> -#include <sys/stat.h> #include <sys/uio.h> #include <sys/vfs.h>
hw/9pfs/9p-synth.h +0 -3
@@ -13,9 +13,6 @@#ifndef HW_9PFS_SYNTH_H #define HW_9PFS_SYNTH_H 1 -#include <unistd.h> -#include <sys/types.h> -#include <limits.h> typedef struct V9fsSynthNode V9fsSynthNode ; typedef ssize_t (*v9fs_synth_read)(void *buf, int len, off_t offset,
hw/9pfs/9p.h +0 -2
@@ -1,9 +1,7 @@#ifndef _QEMU_9P_H#define _QEMU_9P_H -#include <sys/types.h> #include <dirent.h> -#include <sys/time.h> #include <utime.h> #include <sys/resource.h> #include <glib.h>
hw/audio/gusemu.h +0 -1
@@ -34,7 +34,6 @@typedef signed char GUSchar ;typedef signed short GUSsample ;#else -#include <stdint.h> typedef int8_t GUSchar ;typedef uint8_t GUSbyte ;typedef uint16_t GUSword ;
hw/display/vga_int.h +0 -1
@@ -25,7 +25,6 @@#define HW_VGA_INT_H 1#include <hw/hw.h> -#include "qapi/error.h" #include "exec/memory.h" #define ST01_V_RETRACE 0x08
hw/net/fsl_etsec/registers.h +0 -1
@@ -24,7 +24,6 @@#ifndef _ETSEC_REGISTERS_H_#define _ETSEC_REGISTERS_H_ -#include <stdint.h> enum eTSEC_Register_Access_Type { ACC_RW = 1, /* Read/Write */
hw/usb/desc.h +0 -1
@@ -1,7 +1,6 @@#ifndef QEMU_HW_USB_DESC_H #define QEMU_HW_USB_DESC_H -#include <inttypes.h> #include <wchar.h> /* binary representation */
io/channel-util.c +1 -0
@@ -18,6 +18,7 @@* */ +#include "qemu/osdep.h" #include "io/channel-util.h" #include "io/channel-file.h" #include "io/channel-socket.h"
linux-user/arm/nwfpe/fpa11.h +0 -3
@@ -21,9 +21,6 @@#ifndef __FPA11_H__#define __FPA11_H__ -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> #include <cpu.h>
linux-user/qemu.h +0 -3
@@ -1,15 +1,12 @@#ifndef QEMU_H #define QEMU_H -#include <signal.h> -#include <string.h> #include "cpu.h" #include "exec/cpu_ldst.h" #undef DEBUG_REMAP#ifdef DEBUG_REMAP -#include <stdlib.h> #endif /* DEBUG_REMAP */ #include "exec/user/abitypes.h"
nbd/nbd-internal.h +0 -4
@@ -16,16 +16,12 @@#include "qemu/coroutine.h" #include "qemu/iov.h" -#include <errno.h> -#include <string.h> #ifndef _WIN32#include <sys/ioctl.h> #endif #if defined(__sun__) || defined(__HAIKU__)#include <sys/ioccom.h> #endif -#include <ctype.h> -#include <inttypes.h> #ifdef __linux__#include <linux/fs.h>
net/tap-linux.h +0 -1
@@ -16,7 +16,6 @@#ifndef QEMU_TAP_LINUX_H #define QEMU_TAP_LINUX_H -#include <stdint.h> #ifdef __linux__#include <linux/ioctl.h>
net/util.h +0 -1
@@ -25,7 +25,6 @@#ifndef QEMU_NET_UTIL_H #define QEMU_NET_UTIL_H -#include <stdint.h> int net_parse_macaddr (uint8_t *macaddr,const char *p);
qemu-nbd.c +0 -2
@@ -31,8 +31,6 @@#include "io/channel-socket.h" #include <getopt.h> -#include <sys/types.h> -#include <signal.h> #include <libgen.h> #include <pthread.h>
qga/vss-win32.h +0 -1
@@ -13,7 +13,6 @@#ifndef VSS_WIN32_H #define VSS_WIN32_H -#include "qapi/error.h" bool vss_init (bool init_requester);void vss_deinit (bool deinit_requester);
qga/vss-win32/requester.h +0 -1
@@ -14,7 +14,6 @@#define VSS_WIN32_REQUESTER_H #include <basetyps.h> /* STDAPI */ -#include "qemu/compiler.h" #ifdef __cplusplusextern "C" {
qga/vss-win32/vss-common.h +0 -1
@@ -14,7 +14,6 @@#define VSS_WIN32_H #define __MIDL_user_allocate_free_DEFINED__ -#include "config-host.h" #include <windows.h> #include <shlwapi.h>
replay/replay-internal.h +0 -1
@@ -12,7 +12,6 @@* */ -#include <stdio.h> enum ReplayEvents {/* for instruction event */
slirp/slirp.h +0 -18
@@ -1,11 +1,9 @@#ifndef __COMMON_H__#define __COMMON_H__ -#include "config-host.h" #include "slirp_config.h" #ifdef _WIN32 -# include <inttypes.h> typedef char *caddr_t ;
@@ -23,43 +21,31 @@ typedef char *caddr_t;# endif #endif -#include <sys/types.h> #ifdef HAVE_SYS_BITYPES_H # include <sys/bitypes.h> #endif -#include <sys/time.h> #ifdef HAVE_UNISTD_H -# include <unistd.h> #endif #ifdef HAVE_STDLIB_H -# include <stdlib.h> #endif -#include <stdio.h> -#include <errno.h> #ifndef HAVE_MEMMOVE #define memmove (x, y, z) bcopy(y, x, z)#endif #if TIME_WITH_SYS_TIME -# include <sys/time.h> -# include <time.h> #else # ifdef HAVE_SYS_TIME_H -# include <sys/time.h> # else -# include <time.h> # endif #endif #ifdef HAVE_STRING_H -# include <string.h> #else -# include <strings.h> #endif #ifndef _WIN32
@@ -82,11 +68,9 @@ void *malloc(size_t arg);void free (void *ptr);#endif -#include <fcntl.h> #ifndef NO_UNIX_SOCKETS #include <sys/un.h> #endif -#include <signal.h> #ifdef HAVE_SYS_SIGNAL_H # include <sys/signal.h> #endif
@@ -115,12 +99,10 @@ void free(void *ptr);#endif #ifdef __STDC__ -#include <stdarg.h> #else #include <varargs.h> #endif -#include <sys/stat.h> /* Avoid conflicting with the libc insque() and remque(), which have different prototypes. */
target-alpha/cpu.h +0 -1
@@ -20,7 +20,6 @@#if !defined (__CPU_ALPHA_H__)#define __CPU_ALPHA_H__ -#include "config.h" #include "qemu-common.h" #define TARGET_LONG_BITS 64
target-arm/cpu.h +0 -1
@@ -19,7 +19,6 @@#ifndef CPU_ARM_H #define CPU_ARM_H -#include "config.h" #include "kvm-consts.h"
target-arm/kvm-consts.h +0 -1
@@ -15,7 +15,6 @@#define ARM_KVM_CONSTS_H #ifdef CONFIG_KVM -#include "qemu/compiler.h" #include <linux/kvm.h> #include <linux/psci.h>
target-cris/cpu.h +0 -1
@@ -20,7 +20,6 @@#ifndef CPU_CRIS_H #define CPU_CRIS_H -#include "config.h" #include "qemu-common.h" #define TARGET_LONG_BITS 32
target-i386/cpu-qom.h +0 -1
@@ -22,7 +22,6 @@#include "qom/cpu.h" #include "cpu.h" -#include "qapi/error.h" #include "qemu/notify.h" #ifdef TARGET_X86_64
target-i386/cpu.h +0 -1
@@ -19,7 +19,6 @@#ifndef CPU_I386_H #define CPU_I386_H -#include "config.h" #include "qemu-common.h" #include "standard-headers/asm-x86/hyperv.h"
target-i386/mpx_helper.c +1 -0
@@ -17,6 +17,7 @@* License along with this library; if not, see <http://www.gnu.org/licenses/>. */ +#include "qemu/osdep.h" #include "cpu.h" #include "exec/helper-proto.h" #include "exec/cpu_ldst.h"
target-lm32/cpu.h +0 -1
@@ -24,7 +24,6 @@#define CPUArchState struct CPULM32State -#include "config.h" #include "qemu-common.h" #include "exec/cpu-defs.h" struct CPULM32State ;
target-m68k/cpu.h +0 -1
@@ -24,7 +24,6 @@#define CPUArchState struct CPUM68KState -#include "config.h" #include "qemu-common.h" #include "exec/cpu-defs.h"
target-microblaze/cpu.h +0 -1
@@ -19,7 +19,6 @@#ifndef CPU_MICROBLAZE_H #define CPU_MICROBLAZE_H -#include "config.h" #include "qemu-common.h" #define TARGET_LONG_BITS 32
target-mips/cpu.h +0 -1
@@ -7,7 +7,6 @@#define CPUArchState struct CPUMIPSState -#include "config.h" #include "qemu-common.h" #include "mips-defs.h" #include "exec/cpu-defs.h"
target-moxie/cpu.h +0 -1
@@ -19,7 +19,6 @@#ifndef _CPU_MOXIE_H#define _CPU_MOXIE_H -#include "config.h" #include "qemu-common.h" #define TARGET_LONG_BITS 32
target-openrisc/cpu.h +0 -1
@@ -27,7 +27,6 @@/* cpu_openrisc_map_address_* in CPUOpenRISCTLBContext need this decl. */ struct OpenRISCCPU ; -#include "config.h" #include "qemu-common.h" #include "exec/cpu-defs.h" #include "fpu/softfloat.h"
target-ppc/cpu.h +0 -1
@@ -19,7 +19,6 @@#if !defined (__CPU_PPC_H__)#define __CPU_PPC_H__ -#include "config.h" #include "qemu-common.h" //#define PPC_EMULATE_32BITS_HYPV
target-s390x/cpu.h +0 -1
@@ -22,7 +22,6 @@#ifndef CPU_S390X_H #define CPU_S390X_H -#include "config.h" #include "qemu-common.h" #define TARGET_LONG_BITS 64
target-sh4/cpu.h +0 -1
@@ -19,7 +19,6 @@#ifndef _CPU_SH4_H#define _CPU_SH4_H -#include "config.h" #include "qemu-common.h" #define TARGET_LONG_BITS 32
target-sparc/cpu.h +0 -1
@@ -1,7 +1,6 @@#ifndef CPU_SPARC_H #define CPU_SPARC_H -#include "config.h" #include "qemu-common.h" #include "qemu/bswap.h"
target-tilegx/cpu.h +0 -1
@@ -19,7 +19,6 @@#ifndef CPU_TILEGX_H #define CPU_TILEGX_H -#include "config.h" #include "qemu-common.h" #define TARGET_LONG_BITS 64
target-tricore/cpu.h +0 -1
@@ -20,7 +20,6 @@#define __TRICORE_CPU_H__#include "tricore-defs.h" -#include "config.h" #include "qemu-common.h" #include "exec/cpu-defs.h" #include "fpu/softfloat.h"
target-unicore32/cpu.h +0 -1
@@ -19,7 +19,6 @@#define CPUArchState struct CPUUniCore32State -#include "config.h" #include "qemu-common.h" #include "exec/cpu-defs.h" #include "fpu/softfloat.h"
target-xtensa/cpu.h +0 -1
@@ -33,7 +33,6 @@#define CPUArchState struct CPUXtensaState -#include "config.h" #include "qemu-common.h" #include "exec/cpu-defs.h" #include "fpu/softfloat.h"
tcg/tci/tcg-target.h +0 -1
@@ -40,7 +40,6 @@#if !defined(TCG_TARGET_H )#define TCG_TARGET_H -#include "config-host.h" #define TCG_TARGET_INTERPRETER 1#define TCG_TARGET_INSN_UNIT_SIZE 1
tests/libqos/ahci.h +0 -3
@@ -25,9 +25,6 @@* THE SOFTWARE. */ -#include <stdint.h> -#include <stdlib.h> -#include <stdbool.h> #include "libqos/libqos.h" #include "libqos/pci.h" #include "libqos/malloc-pc.h"
tests/libqos/fw_cfg.h +0 -2
@@ -13,8 +13,6 @@#ifndef LIBQOS_FW_CFG_H #define LIBQOS_FW_CFG_H -#include <stdint.h> -#include <sys/types.h> typedef struct QFWCFG QFWCFG ;
tests/libqos/i2c.h +0 -1
@@ -9,7 +9,6 @@#ifndef LIBQOS_I2C_H #define LIBQOS_I2C_H -#include <stdint.h> typedef struct I2CAdapter I2CAdapter ; struct I2CAdapter {
tests/libqos/malloc.h +0 -2
@@ -13,8 +13,6 @@ #ifndef LIBQOS_MALLOC_H #define LIBQOS_MALLOC_H -#include <stdint.h> -#include <sys/types.h> #include "qemu/queue.h" typedef enum {
tests/libqos/pci.h +0 -1
@@ -13,7 +13,6 @@#ifndef LIBQOS_PCI_H #define LIBQOS_PCI_H -#include <stdint.h> #include "libqtest.h" #define QPCI_DEVFN (dev, fn) (((dev) << 3) | (fn))
tests/libqtest.h +0 -6
@@ -17,13 +17,7 @@#ifndef LIBQTEST_H #define LIBQTEST_H -#include <stddef.h> -#include <stdint.h> -#include <stdbool.h> -#include <stdarg.h> -#include <sys/types.h> #include "qapi/qmp/qdict.h" -#include "glib-compat.h" typedef struct QTestState QTestState ;
trace/control-internal.h +0 -1
@@ -10,7 +10,6 @@#ifndef TRACE__CONTROL_INTERNAL_H #define TRACE__CONTROL_INTERNAL_H -#include <string.h> extern TraceEvent trace_events[];
trace/ftrace.h +0 -1
@@ -1,7 +1,6 @@#ifndef TRACE_FTRACE_H #define TRACE_FTRACE_H -#include <stdbool.h> #define MAX_TRACE_STRLEN 512
trace/simple.h +0 -3
@@ -11,9 +11,6 @@#ifndef TRACE_SIMPLE_H #define TRACE_SIMPLE_H -#include <stdint.h> -#include <stdbool.h> -#include <stdio.h> #include "trace/generated-events.h"
ui/vnc-palette.h +0 -2
@@ -31,8 +31,6 @@#include "qapi/qmp/qlist.h" #include "qemu/queue.h" -#include <stdint.h> -#include <stdbool.h> #define VNC_PALETTE_HASH_SIZE 256#define VNC_PALETTE_MAX_SIZE 256
ui/vnc.h +0 -1
@@ -38,7 +38,6 @@#include "io/channel-socket.h" #include "io/channel-tls.h" #include <zlib.h> -#include <stdbool.h> #include "keymaps.h" #include "vnc-palette.h"
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PATCH 7/8] all: Clean up includes
Quoted 13 lines · Peter Maydell
Clean up includes so that
osdep.his included first and headers which it implies are not included manually.This commit was created with
scripts/clean-includes.Signed-off-by Peter Maydell <[email protected]>---
56 files changed, 2 insertions(+), 100 deletions(-)+++
b/io/channel-util.c
io/channel-util.c line 24
Quoted 7 lines
io/channel-util.c +1
-0@@ -18,6 +18,7 @@* */ +#include "qemu/osdep.h" #include "io/channel-util.h" #include "io/channel-file.h" #include "io/channel-socket.h"
Ah, so the 2 insertions are due to recent file additions, after your last round of cleanups.
Any way to automate this into checkpatch.pl for new file creation? Then again, not all developers have Coccinelle installed. But even checking whether the string 'include.*qemu/osdep.h' is present in a new file may help, even if it doesn't detect it being included out-of-order.
Quoted 21 lines
+++
b/slirp/slirp.hslirp/slirp.h +0
-3@@ -1,11 +1,9 @@#ifndef __COMMON_H__#define __COMMON_H__ -#include "config-host.h" #include "slirp_config.h" #ifdef _WIN32 -# include <inttypes.h> typedef char *caddr_t ;@@ -23,43 +21,31 @@ typedef char *caddr_t;# endif #endif -#include <sys/types.h> #ifdef HAVE_SYS_BITYPES_H # include <sys/bitypes.h> #endif
slirp/slirp.h typedef char *caddr_t; · line 33
Quoted 10 lines
slirp/slirp.h +0
-3-#include <sys/time.h> #ifdef HAVE_UNISTD_H -# include <unistd.h> #endif #ifdef HAVE_STDLIB_H -# include <stdlib.h> #endif
Leftover dead checks of HAVE_UNISTD_H and so forth; this file could use further manual cleanups. For that matter, do we even need HAVE_UNISTD_H in slirp/slirp_config.h any more? There's probably quite a bit of pruning of cruft we could do. But as this patch was completely automated, I'm fine if that cleanup is done as followups.
Therefore,
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 7/8] all: Clean up includes
Quoted 25 lines · Eric Blake
Quoted 13 lines · Peter Maydell
Clean up includes so that
osdep.his included first and headers which it implies are not included manually.This commit was created with
scripts/clean-includes.Signed-off-by Peter Maydell <[email protected]>---
56 files changed, 2 insertions(+), 100 deletions(-)+++
b/io/channel-util.cio/channel-util.c line 24
Quoted 7 lines
io/channel-util.c +1
-0@@ -18,6 +18,7 @@* */ +#include "qemu/osdep.h" #include "io/channel-util.h" #include "io/channel-file.h" #include "io/channel-socket.h" Ah, so the 2 insertions are due to recent file additions, after your last round of cleanups.
Quoted 4 lines
Any way to automate this into checkpatch.pl for new file creation? Then again, not all developers have Coccinelle installed. But even checking whether the string '
include.*qemu/osdep.h' is present in a new file may help, even if it doesn't detect it being included out-of-order.
Looking at this is on my todo list, but TBH once this patch is in master I don't expect much backsliding, because forgetting osdep.h will result in your new file not compiling at all. It's only in this transitional stage where qemu-common.h still pulls in osdep.h that it's possible for a new file to slip in without the include.
Quoted 5 lines
Leftover dead checks of
HAVE_UNISTD_Hand so forth; this file could use further manual cleanups. For that matter, do we even needHAVE_UNISTD_Hinslirp/slirp_config.hany more? There's probably quite a bit of pruning of cruft we could do. But as this patch was completely automated, I'm fine if that cleanup is done as followups.
OK. Will put it on my list to fix up later.
thanks
-- PMM
PATCH 8/8 include: Clean up includes
In reply to Peter MaydellClean up includes so that osdep.h is included first and headers which it implies are not included manually.
This commit was created with scripts/clean-includes.
NB: If this commit breaks compilation for your out-of-tree patchseries or fork, then you need to make sure you add #include "qemu/osdep.h" to any new .c files that you have.
--- include/block/accounting.h | 2 -- include/block/nbd.h | 1 - include/block/snapshot.h | 1 - include/block/write-threshold.h | 1 - include/config.h | 1 - include/crypto/cipher.h | 1 - include/crypto/hash.h | 1 - include/crypto/init.h | 1 - include/crypto/secret.h | 1 - include/crypto/tlscreds.h | 1 - include/elf.h | 1 - include/exec/cpu-all.h | 1 - include/exec/cpu-defs.h | 3 --- include/exec/helper-head.h | 1 - include/exec/memory.h | 3 --- include/exec/user/thunk.h | 1 - include/fpu/softfloat.h | 3 --- include/hw/acpi/acpi.h | 1 - include/hw/acpi/aml-build.h | 2 -- include/hw/acpi/bios-linker-loader.h | 2 -- include/hw/acpi/pcihp.h | 1 - include/hw/block/block.h | 1 - include/hw/i386/topology.h | 2 -- include/hw/isa/apm.h | 1 - include/hw/nvram/fw_cfg.h | 2 -- include/hw/pci/pci.h | 1 - include/hw/pci/shpc.h | 1 - include/hw/qdev-core.h | 1 - include/hw/virtio/vhost-backend.h | 1 - include/hw/xen/xen.h | 1 - include/hw/xen/xen_common.h | 3 --- include/io/channel.h | 1 - include/io/task.h | 1 - include/libdecnumber/dconfig.h | 1 - include/libdecnumber/decContext.h | 3 --- include/libdecnumber/decNumberLocal.h | 2 -- include/migration/migration.h | 1 - include/migration/qemu-file.h | 1 - include/net/checksum.h | 1 - include/net/eth.h | 2 -- include/qapi/error.h | 3 --- include/qapi/qmp-event.h | 1 - include/qapi/qmp/dispatch.h | 1 - include/qapi/qmp/json-lexer.h | 1 - include/qapi/qmp/json-parser.h | 1 - include/qapi/qmp/json-streamer.h | 2 -- include/qapi/qmp/qbool.h | 1 - include/qapi/qmp/qdict.h | 2 -- include/qapi/qmp/qfloat.h | 1 - include/qapi/qmp/qint.h | 1 - include/qapi/qmp/qjson.h | 2 -- include/qapi/qmp/qobject.h | 2 -- include/qapi/qmp/qstring.h | 1 - include/qapi/visitor-impl.h | 1 - include/qapi/visitor.h | 2 -- include/qemu-common.h | 1 - include/qemu/atomic.h | 1 - include/qemu/bitmap.h | 3 --- include/qemu/bitops.h | 2 -- include/qemu/bswap.h | 5 ----- include/qemu/compatfd.h | 1 - include/qemu/compiler.h | 1 - include/qemu/config-file.h | 2 -- include/qemu/coroutine.h | 1 - include/qemu/error-report.h | 3 --- include/qemu/fprintf-fn.h | 2 -- include/qemu/hbitmap.h | 3 --- include/qemu/host-utils.h | 3 --- include/qemu/int128.h | 3 --- include/qemu/log.h | 4 ---- include/qemu/memfd.h | 2 -- include/qemu/module.h | 1 - include/qemu/option.h | 2 -- include/qemu/range.h | 1 - include/qemu/rcu.h | 7 ------- include/qemu/sockets.h | 2 -- include/qemu/thread.h | 2 -- include/qemu/throttle.h | 1 - include/qemu/timed-average.h | 1 - include/qemu/xattr.h | 1 - include/qom/cpu.h | 1 - include/qom/object.h | 3 --- include/sysemu/block-backend.h | 1 - include/sysemu/blockdev.h | 1 - include/sysemu/dma.h | 1 - include/sysemu/hostmem.h | 1 - include/sysemu/kvm.h | 2 -- include/sysemu/numa.h | 1 - include/sysemu/os-posix.h | 1 - include/sysemu/qtest.h | 1 - include/sysemu/replay.h | 3 --- include/sysemu/rng.h | 1 - include/sysemu/seccomp.h | 1 - include/sysemu/tpm_backend.h | 1 - include/sysemu/xen-mapcache.h | 1 - include/ui/console.h | 1 - include/ui/qemu-spice.h | 1 - 97 files changed, 156 deletions(-)
include/block/accounting.h +0 -2
@@ -25,8 +25,6 @@#ifndef BLOCK_ACCOUNTING_H #define BLOCK_ACCOUNTING_H -#include <stdint.h> -#include <stdbool.h> #include "qemu/typedefs.h" #include "qemu/timed-average.h"
include/block/nbd.h +0 -1
@@ -19,7 +19,6 @@#ifndef NBD_H #define NBD_H -#include <sys/types.h> #include "qemu-common.h" #include "qemu/option.h"
include/block/snapshot.h +0 -1
@@ -26,7 +26,6 @@#define SNAPSHOT_H #include "qemu-common.h" -#include "qapi/error.h" #include "qemu/option.h"
include/block/write-threshold.h +0 -1
@@ -12,7 +12,6 @@#ifndef BLOCK_WRITE_THRESHOLD_H #define BLOCK_WRITE_THRESHOLD_H -#include <stdint.h> #include "qemu/typedefs.h" #include "qemu-common.h"
include/config.h +0 -1
@@ -1,2 +1 @@ -#include "config-host.h" #include "config-target.h"
include/crypto/cipher.h +0 -1
@@ -22,7 +22,6 @@#define QCRYPTO_CIPHER_H__ #include "qemu-common.h" -#include "qapi/error.h" typedef struct QCryptoCipher QCryptoCipher ;
include/crypto/hash.h +0 -1
@@ -22,7 +22,6 @@#define QCRYPTO_HASH_H__ #include "qemu-common.h" -#include "qapi/error.h" /* See also "QCryptoHashAlgorithm" defined in qapi/crypto.json */
include/crypto/init.h +0 -1
@@ -22,7 +22,6 @@#define QCRYPTO_INIT_H__ #include "qemu-common.h" -#include "qapi/error.h" int qcrypto_init (Error **errp);
include/crypto/secret.h +0 -1
@@ -22,7 +22,6 @@#define QCRYPTO_SECRET_H__ #include "qemu-common.h" -#include "qapi/error.h" #include "qom/object.h" #define TYPE_QCRYPTO_SECRET "secret"
include/crypto/tlscreds.h +0 -1
@@ -22,7 +22,6 @@#define QCRYPTO_TLSCRED_H__ #include "qemu-common.h" -#include "qapi/error.h" #include "qom/object.h" #ifdef CONFIG_GNUTLS
include/elf.h +0 -1
@@ -1,7 +1,6 @@#ifndef _QEMU_ELF_H#define _QEMU_ELF_H -#include <inttypes.h> /* 32-bit ELF base types. */ typedef uint32_t Elf32_Addr ;
include/exec/cpu-all.h +0 -1
@@ -154,7 +154,6 @@ static inline void tswap64s(uint64_t *s)/* MMU memory access macros */ #if defined(CONFIG_USER_ONLY ) -#include <assert.h> #include "exec/user/abitypes.h" /* On some host systems the guest address space is reserved on the host.
include/exec/cpu-defs.h +0 -3
@@ -23,9 +23,6 @@#error cpu.h included from common code#endif -#include "config.h" -#include <inttypes.h> -#include "qemu/osdep.h" #include "qemu/queue.h" #include "tcg-target.h" #ifndef CONFIG_USER_ONLY
include/exec/helper-head.h +0 -1
@@ -18,7 +18,6 @@#ifndef DEF_HELPER_H #define DEF_HELPER_H 1 -#include "qemu/osdep.h" #define HELPER (name) glue(helper_, name)
include/exec/memory.h +0 -3
@@ -21,8 +21,6 @@#define DIRTY_MEMORY_MIGRATION 2#define DIRTY_MEMORY_NUM 3/* num of dirty bits */ -#include <stdint.h> -#include <stdbool.h> #include "exec/cpu-common.h" #ifndef CONFIG_USER_ONLY #include "exec/hwaddr.h"
@@ -31,7 +29,6 @@#include "qemu/queue.h" #include "qemu/int128.h" #include "qemu/notify.h" -#include "qapi/error.h" #include "qom/object.h" #include "qemu/rcu.h"
include/exec/user/thunk.h +0 -1
@@ -19,7 +19,6 @@#ifndef THUNK_H #define THUNK_H -#include <inttypes.h> #include "cpu.h" /* types enums definitions */
include/fpu/softfloat.h +0 -3
@@ -86,9 +86,6 @@ this code that are retained.#include <sunmath.h> #endif -#include <inttypes.h> -#include "config-host.h" -#include "qemu/osdep.h" /* This 'flag' type must be able to hold at least 0 and 1. It should * probably be replaced with 'bool' but the uses would need to be audited
include/hw/acpi/acpi.h +0 -1
@@ -19,7 +19,6 @@* <http://www.gnu.org/licenses/>. */ -#include "qapi/error.h" #include "qemu/typedefs.h" #include "qemu/notify.h" #include "qemu/option.h"
include/hw/acpi/aml-build.h +0 -2
@@ -1,9 +1,7 @@#ifndef HW_ACPI_GEN_UTILS_H #define HW_ACPI_GEN_UTILS_H -#include <stdint.h> #include <glib.h> -#include "qemu/compiler.h" #include "hw/acpi/acpi-defs.h" /* Reserve RAM space for tables: add another order of magnitude. */
include/hw/acpi/bios-linker-loader.h +0 -2
@@ -2,8 +2,6 @@#define BIOS_LINKER_LOADER_H #include <glib.h> -#include <stdbool.h> -#include <inttypes.h> GArray *bios_linker_loader_init (void );
include/hw/acpi/pcihp.h +0 -1
@@ -27,7 +27,6 @@#ifndef HW_ACPI_PCIHP_H #define HW_ACPI_PCIHP_H -#include <inttypes.h> #include <qemu/typedefs.h> #include "hw/acpi/acpi.h" #include "migration/vmstate.h"
include/hw/block/block.h +0 -1
@@ -12,7 +12,6 @@#define HW_BLOCK_COMMON_H #include "qemu-common.h" -#include "qapi/error.h" /* Configuration */
include/hw/i386/topology.h +0 -2
@@ -38,8 +38,6 @@* CPUID Fn8000_0008_ECX[ApicIdCoreIdSize[3:0]] is set to apicid_core_width(). */ -#include <stdint.h> -#include <string.h> #include "qemu/bitops.h"
include/hw/isa/apm.h +0 -1
@@ -1,7 +1,6 @@#ifndef APM_H #define APM_H -#include <stdint.h> #include "qemu-common.h" #include "hw/hw.h" #include "exec/memory.h"
include/hw/nvram/fw_cfg.h +0 -2
@@ -2,8 +2,6 @@#define FW_CFG_H #ifndef NO_QEMU_PROTOS -#include <stdint.h> -#include <stddef.h> #include "exec/hwaddr.h" #include "qemu/typedefs.h"
include/hw/pci/pci.h +0 -1
@@ -6,7 +6,6 @@#include "hw/qdev.h" #include "exec/memory.h" #include "sysemu/dma.h" -#include "qapi/error.h" /* PCI includes legacy ISA access. */ #include "hw/isa/isa.h"
include/hw/pci/shpc.h +0 -1
@@ -4,7 +4,6 @@#include "qemu-common.h" #include "exec/memory.h" #include "migration/vmstate.h" -#include "qapi/error.h" #include "hw/hotplug.h" #include "hw/pci/pci.h"
include/hw/qdev-core.h +0 -1
@@ -7,7 +7,6 @@#include "qemu/bitmap.h" #include "qom/object.h" #include "hw/irq.h" -#include "qapi/error.h" #include "hw/hotplug.h" enum {
include/hw/virtio/vhost-backend.h +0 -1
@@ -11,7 +11,6 @@ #ifndef VHOST_BACKEND_H_ #define VHOST_BACKEND_H_ -#include <stdbool.h> typedef enum VhostBackendType { VHOST_BACKEND_TYPE_NONE = 0,
include/hw/xen/xen.h +0 -1
@@ -6,7 +6,6 @@* must not depend on any xen headers being present in * /usr/include/xen, so it can be included unconditionally. */ -#include <inttypes.h> #include "hw/irq.h" #include "qemu-common.h"
include/hw/xen/xen_common.h +0 -3
@@ -1,10 +1,7 @@#ifndef QEMU_HW_XEN_COMMON_H #define QEMU_HW_XEN_COMMON_H 1 -#include "config-host.h" -#include <stddef.h> -#include <inttypes.h> /* * If we have new enough libxenctrl then we do not want/need these compat
include/io/channel.h +0 -1
@@ -22,7 +22,6 @@#define QIO_CHANNEL_H__ #include "qemu-common.h" -#include "qapi/error.h" #include "qom/object.h" #define TYPE_QIO_CHANNEL "qio-channel"
include/io/task.h +0 -1
@@ -22,7 +22,6 @@#define QIO_TASK_H__ #include "qemu-common.h" -#include "qapi/error.h" #include "qom/object.h" typedef struct QIOTask QIOTask ;
include/libdecnumber/dconfig.h +0 -1
@@ -27,7 +27,6 @@Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "config-host.h" #if defined(HOST_WORDS_BIGENDIAN )#define WORDS_BIGENDIAN 1
include/libdecnumber/decContext.h +0 -3
@@ -56,9 +56,6 @@#define DECCFULLNAME "Decimal Context Descriptor"/* Verbose name */ #define DECCAUTHOR "Mike Cowlishaw"/* Who to blame */ -#include <stdint.h> -#include <stdio.h> /* for printf, etc. */ -#include <signal.h> /* for traps */ /* Extended flags setting -- set this to 0 to use only IEEE flags */ #define DECEXTFLAG 1/* 1=enable extended flags */
include/libdecnumber/decNumberLocal.h +0 -2
@@ -42,8 +42,6 @@#define DECVERSION "decNumber 3.53"/* Package Version [16 max.] */ #define DECNLAUTHOR "Mike Cowlishaw"/* Who to blame */ -#include <stdlib.h> /* for abs */ -#include <string.h> /* for memset, strcpy */ #include "libdecnumber/dconfig.h" /* Conditional code flag -- set this to match hardware platform */
include/migration/migration.h +0 -1
@@ -18,7 +18,6 @@#include "qemu-common.h" #include "qemu/thread.h" #include "qemu/notify.h" -#include "qapi/error.h" #include "migration/vmstate.h" #include "qapi-types.h" #include "exec/cpu-common.h"
include/migration/qemu-file.h +0 -1
@@ -25,7 +25,6 @@#define QEMU_FILE_H 1#include "exec/cpu-common.h" -#include <stdint.h> /* This function writes a chunk of data to a file at the given position. * The pos argument can be ignored if the file is only being used for
include/net/checksum.h +0 -1
@@ -18,7 +18,6 @@#ifndef QEMU_NET_CHECKSUM_H #define QEMU_NET_CHECKSUM_H -#include <stdint.h> struct iovec ;uint32_t net_checksum_add_cont (int len,uint8_t *buf,int seq);
include/net/eth.h +0 -2
@@ -26,8 +26,6 @@#ifndef QEMU_ETH_H #define QEMU_ETH_H -#include <sys/types.h> -#include <string.h> #include "qemu/bswap.h" #include "qemu/iov.h"
include/qapi/error.h +0 -3
@@ -115,9 +115,6 @@#ifndef ERROR_H #define ERROR_H -#include <stdarg.h> -#include <stdbool.h> -#include "qemu/compiler.h" #include "qapi-types.h" /*
include/qapi/qmp-event.h +0 -1
@@ -14,7 +14,6 @@#ifndef QMP_EVENT_H #define QMP_EVENT_H -#include "qapi/error.h" #include "qapi/qmp/qdict.h" typedef void (*QMPEventFuncEmit )(unsigned event,QDict *dict,Error **errp);
include/qapi/qmp/dispatch.h +0 -1
@@ -16,7 +16,6 @@#include "qapi/qmp/qobject.h" #include "qapi/qmp/qdict.h" -#include "qapi/error.h" typedef void (QmpCommandFunc )(QDict *,QObject **,Error **);
include/qapi/qmp/json-lexer.h +0 -1
@@ -14,7 +14,6 @@ #ifndef QEMU_JSON_LEXER_H #define QEMU_JSON_LEXER_H -#include "glib-compat.h" typedef enum json_token_type { JSON_MIN = 100,
include/qapi/qmp/json-parser.h +0 -1
@@ -16,7 +16,6 @@#include "qemu-common.h" #include "qapi/qmp/qlist.h" -#include "qapi/error.h" QObject *json_parser_parse (GQueue *tokens,va_list *ap);QObject *json_parser_parse_err (GQueue *tokens,va_list *ap,Error **errp);
include/qapi/qmp/json-streamer.h +0 -2
@@ -14,8 +14,6 @@ #ifndef QEMU_JSON_STREAMER_H #define QEMU_JSON_STREAMER_H -#include <stdint.h> -#include "glib-compat.h" #include "qapi/qmp/json-lexer.h" typedef struct JSONToken {
include/qapi/qmp/qbool.h +0 -1
@@ -14,7 +14,6 @@ #ifndef QBOOL_H #define QBOOL_H -#include <stdbool.h> #include "qapi/qmp/qobject.h" typedef struct QBool {
include/qapi/qmp/qdict.h +0 -2
@@ -16,8 +16,6 @@#include "qapi/qmp/qobject.h" #include "qapi/qmp/qlist.h" #include "qemu/queue.h" -#include <stdbool.h> -#include <stdint.h> #define QDICT_BUCKET_MAX 512
include/qapi/qmp/qfloat.h +0 -1
@@ -14,7 +14,6 @@ #ifndef QFLOAT_H #define QFLOAT_H -#include <stdint.h> #include "qapi/qmp/qobject.h" typedef struct QFloat {
include/qapi/qmp/qint.h +0 -1
@@ -13,7 +13,6 @@ #ifndef QINT_H #define QINT_H -#include <stdint.h> #include "qapi/qmp/qobject.h" typedef struct QInt {
include/qapi/qmp/qjson.h +0 -2
@@ -14,8 +14,6 @@#ifndef QJSON_H #define QJSON_H -#include <stdarg.h> -#include "qemu/compiler.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp/qstring.h"
include/qapi/qmp/qobject.h +0 -2
@@ -32,8 +32,6 @@#ifndef QOBJECT_H #define QOBJECT_H -#include <stddef.h> -#include <assert.h> #include "qapi-types.h" struct QObject {
include/qapi/qmp/qstring.h +0 -1
@@ -13,7 +13,6 @@ #ifndef QSTRING_H #define QSTRING_H -#include <stdint.h> #include "qapi/qmp/qobject.h" typedef struct QString {
include/qapi/visitor-impl.h +0 -1
@@ -12,7 +12,6 @@#ifndef QAPI_VISITOR_IMPL_H #define QAPI_VISITOR_IMPL_H -#include "qapi/error.h" #include "qapi/visitor.h" struct Visitor
include/qapi/visitor.h +0 -2
@@ -16,8 +16,6 @@#include "qemu/typedefs.h" #include "qapi/qmp/qobject.h" -#include "qapi/error.h" -#include <stdlib.h> typedef struct GenericList {
include/qemu-common.h +0 -1
@@ -12,7 +12,6 @@#ifndef QEMU_COMMON_H #define QEMU_COMMON_H -#include "qemu/osdep.h" #include "qemu/typedefs.h" #include "qemu/fprintf-fn.h"
include/qemu/atomic.h +0 -1
@@ -15,7 +15,6 @@#ifndef __QEMU_ATOMIC_H#define __QEMU_ATOMIC_H 1 -#include "qemu/compiler.h" /* Compiler barrier */
include/qemu/bitmap.h +0 -3
@@ -13,10 +13,7 @@#define BITMAP_H #include <glib.h> -#include <string.h> -#include <stdlib.h> -#include "qemu/osdep.h" #include "qemu/bitops.h" /*
include/qemu/bitops.h +0 -2
@@ -12,8 +12,6 @@#ifndef BITOPS_H #define BITOPS_H -#include <stdint.h> -#include <assert.h> #include "host-utils.h" #include "atomic.h"
include/qemu/bswap.h +0 -5
@@ -1,15 +1,10 @@#ifndef BSWAP_H #define BSWAP_H -#include "config-host.h" -#include <inttypes.h> -#include <limits.h> -#include <string.h> #include "fpu/softfloat.h" #ifdef CONFIG_MACHINE_BSWAP_H # include <sys/endian.h> -# include <sys/types.h> # include <machine/bswap.h> #elif defined(__FreeBSD__)# include <sys/endian.h>
include/qemu/compatfd.h +0 -1
@@ -14,7 +14,6 @@ #ifndef QEMU_COMPATFD_H #define QEMU_COMPATFD_H -#include <signal.h> struct qemu_signalfd_siginfo { uint32_t ssi_signo; /* Signal number */
include/qemu/compiler.h +0 -1
@@ -3,7 +3,6 @@#ifndef COMPILER_H #define COMPILER_H -#include "config-host.h" /*---------------------------------------------------------------------------- | The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler.
include/qemu/config-file.h +0 -2
@@ -1,9 +1,7 @@#ifndef QEMU_CONFIG_H #define QEMU_CONFIG_H -#include <stdio.h> #include "qemu/option.h" -#include "qapi/error.h" #include "qapi/qmp/qdict.h" QemuOptsList *qemu_find_opts (const char *group);
include/qemu/coroutine.h +0 -1
@@ -15,7 +15,6 @@#ifndef QEMU_COROUTINE_H #define QEMU_COROUTINE_H -#include <stdbool.h> #include "qemu/typedefs.h" #include "qemu/queue.h" #include "qemu/timer.h"
include/qemu/error-report.h +0 -3
@@ -13,9 +13,6 @@ #ifndef QEMU_ERROR_H #define QEMU_ERROR_H -#include <stdarg.h> -#include <stdbool.h> -#include "qemu/compiler.h" typedef struct Location { /* all members are private to qemu-error.c */
include/qemu/fprintf-fn.h +0 -2
@@ -8,8 +8,6 @@#ifndef QEMU_FPRINTF_FN_H #define QEMU_FPRINTF_FN_H 1 -#include "qemu/compiler.h" -#include <stdio.h> typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)GCC_FMT_ATTR (2 ,3 );
include/qemu/hbitmap.h +0 -3
@@ -12,9 +12,6 @@#ifndef HBITMAP_H #define HBITMAP_H 1 -#include <limits.h> -#include <stdint.h> -#include <stdbool.h> #include "bitops.h" #include "host-utils.h"
include/qemu/host-utils.h +0 -3
@@ -25,10 +25,7 @@#ifndef HOST_UTILS_H #define HOST_UTILS_H 1 -#include "qemu/compiler.h" /* QEMU_GNUC_PREREQ */ #include "qemu/bswap.h" -#include <limits.h> -#include <stdbool.h> #ifdef CONFIG_INT128 static inline void mulu64(uint64_t *plow, uint64_t *phigh,
include/qemu/int128.h +0 -3
@@ -1,9 +1,6 @@#ifndef INT128_H #define INT128_H -#include <assert.h> -#include <stdint.h> -#include <stdbool.h> typedef struct Int128 Int128 ;
include/qemu/log.h +0 -4
@@ -1,10 +1,6 @@#ifndef QEMU_LOG_H #define QEMU_LOG_H -#include <stdarg.h> -#include <stdbool.h> -#include <stdio.h> -#include "qemu/compiler.h" /* Private global variables, don't use */ extern FILE *qemu_logfile;
include/qemu/memfd.h +0 -2
@@ -1,8 +1,6 @@#ifndef QEMU_MEMFD_H #define QEMU_MEMFD_H -#include "config-host.h" -#include <stdbool.h> #ifndef F_LINUX_SPECIFIC_BASE #define F_LINUX_SPECIFIC_BASE 1024
include/qemu/module.h +0 -1
@@ -14,7 +14,6 @@#ifndef QEMU_MODULE_H #define QEMU_MODULE_H -#include "qemu/osdep.h" #define DSO_STAMP_FUN glue(qemu_stamp, CONFIG_STAMP)#define DSO_STAMP_FUN_STR stringify(DSO_STAMP_FUN)
include/qemu/option.h +0 -2
@@ -26,9 +26,7 @@#ifndef QEMU_OPTIONS_H #define QEMU_OPTIONS_H -#include <stdint.h> #include "qemu/queue.h" -#include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "qemu/typedefs.h"
include/qemu/range.h +0 -1
@@ -1,7 +1,6 @@#ifndef QEMU_RANGE_H #define QEMU_RANGE_H -#include <inttypes.h> #include <qemu/typedefs.h> #include "qemu/queue.h"
include/qemu/rcu.h +0 -7
@@ -23,15 +23,8 @@* IBM's contributions to this file may be relicensed under LGPLv2 or later. */ -#include <stdlib.h> -#include <assert.h> -#include <limits.h> -#include <unistd.h> -#include <stdint.h> -#include <stdbool.h> #include <glib.h> -#include "qemu/compiler.h" #include "qemu/thread.h" #include "qemu/queue.h" #include "qemu/atomic.h"
include/qemu/sockets.h +0 -2
@@ -13,7 +13,6 @@ int inet_aton(const char *cp, struct in_addr *ia);#else -#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/tcp.h>
@@ -26,7 +25,6 @@ int inet_aton(const char *cp, struct in_addr *ia);#endif /* !_WIN32 */ -#include "qapi/error.h" #include "qapi-types.h" /* misc helpers */
include/qemu/thread.h +0 -2
@@ -1,8 +1,6 @@#ifndef __QEMU_THREAD_H#define __QEMU_THREAD_H 1 -#include <inttypes.h> -#include <stdbool.h> typedef struct QemuMutex QemuMutex ;typedef struct QemuCond QemuCond ;
include/qemu/throttle.h +0 -1
@@ -25,7 +25,6 @@#ifndef THROTTLE_H #define THROTTLE_H -#include <stdint.h> #include "qemu-common.h" #include "qemu/timer.h"
include/qemu/timed-average.h +0 -1
@@ -25,7 +25,6 @@#ifndef TIMED_AVERAGE_H #define TIMED_AVERAGE_H -#include <stdint.h> #include "qemu/timer.h"
include/qemu/xattr.h +0 -1
@@ -18,7 +18,6 @@* in /usr/include/sys, and don't have ENOATTR. */ -#include "config-host.h" #ifdef CONFIG_LIBATTR # include <attr/xattr.h>
include/qom/cpu.h +0 -1
@@ -20,7 +20,6 @@#ifndef QEMU_CPU_H #define QEMU_CPU_H -#include <signal.h> #include <setjmp.h> #include "hw/qdev-core.h" #include "disas/bfd.h"
include/qom/object.h +0 -3
@@ -15,11 +15,8 @@#define QEMU_OBJECT_H #include <glib.h> -#include <stdint.h> -#include <stdbool.h> #include "qemu/queue.h" #include "qemu/typedefs.h" -#include "qapi/error.h" struct TypeImpl ;typedef struct TypeImpl *Type ;
include/sysemu/block-backend.h +0 -1
@@ -14,7 +14,6 @@#define BLOCK_BACKEND_H #include "qemu/typedefs.h" -#include "qapi/error.h" /* * TODO Have to include block/block.h for a bunch of block layer
include/sysemu/blockdev.h +0 -1
@@ -11,7 +11,6 @@#define BLOCKDEV_H #include "block/block.h" -#include "qapi/error.h" #include "qemu/queue.h" void blockdev_mark_auto_del (BlockBackend *blk);
include/sysemu/dma.h +0 -1
@@ -10,7 +10,6 @@#ifndef DMA_H #define DMA_H -#include <stdio.h> #include "exec/memory.h" #include "exec/address-spaces.h" #include "hw/hw.h"
include/sysemu/hostmem.h +0 -1
@@ -14,7 +14,6 @@#include "sysemu/sysemu.h" /* for MAX_NODES */ #include "qom/object.h" -#include "qapi/error.h" #include "exec/memory.h" #include "qemu/option.h" #include "qemu/bitmap.h"
include/sysemu/kvm.h +0 -2
@@ -14,8 +14,6 @@#ifndef QEMU_KVM_H #define QEMU_KVM_H -#include <errno.h> -#include "config-host.h" #include "qemu/queue.h" #include "qom/cpu.h" #include "exec/memattrs.h"
include/sysemu/numa.h +0 -1
@@ -1,7 +1,6 @@#ifndef SYSEMU_NUMA_H #define SYSEMU_NUMA_H -#include <stdint.h> #include "qemu/bitmap.h" #include "qemu/option.h" #include "sysemu/sysemu.h"
include/sysemu/os-posix.h +0 -1
@@ -26,7 +26,6 @@#ifndef QEMU_OS_POSIX_H #define QEMU_OS_POSIX_H -#include <sys/time.h> void os_set_line_buffering (void );void os_set_proc_name (const char *s);
include/sysemu/qtest.h +0 -1
@@ -15,7 +15,6 @@#define QTEST_H #include "qemu-common.h" -#include "qapi/error.h" extern bool qtest_allowed;
include/sysemu/replay.h +0 -3
@@ -12,10 +12,7 @@* */ -#include <stdbool.h> -#include <stdint.h> #include "qapi-types.h" -#include "qapi/error.h" #include "qemu/typedefs.h" /* replay clock kinds */
include/sysemu/rng.h +0 -1
@@ -15,7 +15,6 @@#include "qom/object.h" #include "qemu-common.h" -#include "qapi/error.h" #define TYPE_RNG_BACKEND "rng-backend"#define RNG_BACKEND (obj) \
include/sysemu/seccomp.h +0 -1
@@ -16,7 +16,6 @@#define QEMU_SECCOMP_H #include <seccomp.h> -#include "qemu/osdep.h" int seccomp_start (void );#endif
include/sysemu/tpm_backend.h +0 -1
@@ -15,7 +15,6 @@#include "qom/object.h" #include "qemu-common.h" -#include "qapi/error.h" #include "qapi-types.h" #include "qemu/option.h" #include "sysemu/tpm.h"
include/sysemu/xen-mapcache.h +0 -1
@@ -9,7 +9,6 @@#ifndef XEN_MAPCACHE_H #define XEN_MAPCACHE_H -#include <stdlib.h> typedef hwaddr (*phys_offset_to_gaddr_t)(hwaddr start_addr, ram_addr_t size,
include/ui/console.h +0 -1
@@ -7,7 +7,6 @@#include "qemu/notify.h" #include "qemu/typedefs.h" #include "qapi-types.h" -#include "qapi/error.h" #ifdef CONFIG_OPENGL # include <epoxy/gl.h>
include/ui/qemu-spice.h +0 -1
@@ -18,7 +18,6 @@#ifndef QEMU_SPICE_H #define QEMU_SPICE_H -#include "config-host.h" #ifdef CONFIG_SPICE
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PATCH 8/8] include: Clean up includes
Quoted 17 lines · Peter Maydell
Clean up includes so that
osdep.his included first and headers which it implies are not included manually.This commit was created with
scripts/clean-includes.NB: If this commit breaks compilation for your out-of-tree patchseries or fork, then you need to make sure you add #include "
qemu/osdep.h" to any new .c files that you have.Signed-off-by Peter Maydell <[email protected]>---
97 files changed, 156 deletions(-)+++
b/include/migration/qemu-file.h
include/migration/qemu-file.h line 29
Quoted 6 lines
include/migration/qemu-file.h +0
-1@@ -25,7 +25,6 @@#define QEMU_FILE_H 1#include "exec/cpu-common.h" -#include <stdint.h> /* This function writes a chunk of data to a file at the given position.
Cleanups like this change the resulting whitespace in the file. I don't personally care, but I'm pointing it out in case someone does.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 8/8] include: Clean up includes
Quoted 21 lines · Eric Blake
Quoted 20 lines · Peter Maydell
Clean up includes so that
osdep.his included first and headers which it implies are not included manually.This commit was created with
scripts/clean-includes.NB: If this commit breaks compilation for your out-of-tree patchseries or fork, then you need to make sure you add #include "
qemu/osdep.h" to any new .c files that you have.Signed-off-by Peter Maydell <[email protected]>---
97 files changed, 156 deletions(-)+++
b/include/migration/qemu-file.hinclude/migration/qemu-file.h +0
-0@@ -25,7 +25,6 @@#define QEMU_FILE_H 1#include "exec/cpu-common.h"
Quoted 6 lines
include/migration/qemu-file.h line 29
Quoted 3 lines
include/migration/qemu-file.h +0
-1-#include <stdint.h> /* This function writes a chunk of data to a file at the given position. Cleanups like this change the resulting whitespace in the file. I don't personally care, but I'm pointing it out in case someone does.
Oh, you mean we end up with two blank lines in a row? Yeah, I don't care about that either :-)
thanks
-- PMM
Quoted 25 lines · Peter Maydell
This patchset makes more progress with with cleaning our include use and is hopefully the last of the big ones (there are some other minor fixups that can be done after).
Patch 1 is already in Andreas' QOM tree but I include it for convenience since without it things will fail to compile later in the series.
Patch 2 fixes a problem with includingosdep.hfirst in arm-a64.cc if the compiler doesn't support C++11 Patch 3 is the previously sent arm-a64.cc change Patches 4 and 5 add support to the clean-includes script for working on .h files, and for saying "run on everything in the source tree"
Patch 6 fixes something I had forgotten about --osdep.hneeds to includeconfig-target.hif the object file being built is a per-target one!
Patch 7 is the results of cleaning everything exceptinclude/. Patch 8 cleansinclude/.In particular, since patch 8 removes the
osdep.hinclude fromqemu-common.hit is where you will see compile failures if anything isn't includingosdep.h(this builds fine against current master but might break in-flight patches and other out of tree code if it does not includeosdep.heverywhere it should).
Quoted 8 lines
I could split patches 7 and 8 up into smaller chunks if that seems helpful to people, but I figured they weren't too terrible as-is.
thanks
-- PMMPeter Maydell (8):
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org