qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/8] more include cleaning
@ 2016-02-18 18:05 Peter Maydell
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 1/8] cpu: Clean up includes Peter Maydell
                   ` (8 more replies)
  0 siblings, 9 replies; 21+ messages in thread
From: Peter Maydell @ 2016-02-18 18:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

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(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 1/8] cpu: Clean up includes
  2016-02-18 18:05 [Qemu-devel] [PATCH 0/8] more include cleaning Peter Maydell
@ 2016-02-18 18:05 ` Peter Maydell
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 2/8] osdep.h: Define macros for the benefit of C++ before C++11 Peter Maydell
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 21+ messages in thread
From: Peter Maydell @ 2016-02-18 18:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 qom/cpu.c         | 1 +
 target-i386/cpu.c | 5 +----
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/qom/cpu.c b/qom/cpu.c
index aeb32f1..c45d0bb 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -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"
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 0af43a3..c78f824 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -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"
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 2/8] osdep.h: Define macros for the benefit of C++ before C++11
  2016-02-18 18:05 [Qemu-devel] [PATCH 0/8] more include cleaning Peter Maydell
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 1/8] cpu: Clean up includes Peter Maydell
@ 2016-02-18 18:05 ` Peter Maydell
  2016-02-18 18:51   ` Eric Blake
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 3/8] disas/arm-a64.cc: Include osdep.h first Peter Maydell
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 21+ messages in thread
From: Peter Maydell @ 2016-02-18 18:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

For 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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/osdep.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index cc055c9..c1b413d 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -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
  */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 3/8] disas/arm-a64.cc: Include osdep.h first
  2016-02-18 18:05 [Qemu-devel] [PATCH 0/8] more include cleaning Peter Maydell
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 1/8] cpu: Clean up includes Peter Maydell
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 2/8] osdep.h: Define macros for the benefit of C++ before C++11 Peter Maydell
@ 2016-02-18 18:05 ` Peter Maydell
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files Peter Maydell
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 21+ messages in thread
From: Peter Maydell @ 2016-02-18 18:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

Rearrange include directives so that we include osdep.h first.
This has to be done manually because clean-includes doesn't
handle C++.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 disas/arm-a64.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/disas/arm-a64.cc b/disas/arm-a64.cc
index d4d46d5..9280950 100644
--- a/disas/arm-a64.cc
+++ b/disas/arm-a64.cc
@@ -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;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files
  2016-02-18 18:05 [Qemu-devel] [PATCH 0/8] more include cleaning Peter Maydell
                   ` (2 preceding siblings ...)
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 3/8] disas/arm-a64.cc: Include osdep.h first Peter Maydell
@ 2016-02-18 18:05 ` Peter Maydell
  2016-02-18 18:36   ` Peter Maydell
  2016-02-18 19:04   ` Eric Blake
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 5/8] scripts/clean-includes: Add --all option Peter Maydell
                   ` (4 subsequent siblings)
  8 siblings, 2 replies; 21+ messages in thread
From: Peter Maydell @ 2016-02-18 18:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

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.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/.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 scripts/clean-includes | 50 ++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 42 insertions(+), 8 deletions(-)

diff --git a/scripts/clean-includes b/scripts/clean-includes
index 1af1f82..737a5ce 100755
--- a/scripts/clean-includes
+++ b/scripts/clean-includes
@@ -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*(["<][^>"]*[">])/ ||
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 5/8] scripts/clean-includes: Add --all option
  2016-02-18 18:05 [Qemu-devel] [PATCH 0/8] more include cleaning Peter Maydell
                   ` (3 preceding siblings ...)
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files Peter Maydell
@ 2016-02-18 18:05 ` Peter Maydell
  2016-02-18 19:09   ` Eric Blake
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 6/8] osdep.h: Include config-target.h if NEED_CPU_H is defined Peter Maydell
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 21+ messages in thread
From: Peter Maydell @ 2016-02-18 18:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

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 <peter.maydell@linaro.org>
---
 scripts/clean-includes | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/scripts/clean-includes b/scripts/clean-includes
index 737a5ce..6acf120 100755
--- a/scripts/clean-includes
+++ b/scripts/clean-includes
@@ -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.
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 6/8] osdep.h: Include config-target.h if NEED_CPU_H is defined
  2016-02-18 18:05 [Qemu-devel] [PATCH 0/8] more include cleaning Peter Maydell
                   ` (4 preceding siblings ...)
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 5/8] scripts/clean-includes: Add --all option Peter Maydell
@ 2016-02-18 18:05 ` Peter Maydell
  2016-02-18 19:09   ` Eric Blake
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 7/8] all: Clean up includes Peter Maydell
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 21+ messages in thread
From: Peter Maydell @ 2016-02-18 18:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

NEED_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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/osdep.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index c1b413d..80c62be 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -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
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 7/8] all: Clean up includes
  2016-02-18 18:05 [Qemu-devel] [PATCH 0/8] more include cleaning Peter Maydell
                   ` (5 preceding siblings ...)
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 6/8] osdep.h: Include config-target.h if NEED_CPU_H is defined Peter Maydell
@ 2016-02-18 18:05 ` Peter Maydell
  2016-02-18 19:16   ` Eric Blake
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 8/8] include: " Peter Maydell
  2016-02-18 20:04 ` [Qemu-devel] [PATCH 0/8] more include cleaning Eric Blake
  8 siblings, 1 reply; 21+ messages in thread
From: Peter Maydell @ 2016-02-18 18:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 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(-)

diff --git a/audio/audio.h b/audio/audio.h
index e7ea397..b41a970 100644
--- a/audio/audio.h
+++ b/audio/audio.h
@@ -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);
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 735cb40..1b5f998 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -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"
diff --git a/contrib/ivshmem-client/ivshmem-client.h b/contrib/ivshmem-client/ivshmem-client.h
index 3a4f809..54cde17 100644
--- a/contrib/ivshmem-client/ivshmem-client.h
+++ b/contrib/ivshmem-client/ivshmem-client.h
@@ -19,7 +19,6 @@
  * purposes.
  */
 
-#include <limits.h>
 #include <sys/select.h>
 
 #include "qemu/queue.h"
diff --git a/contrib/ivshmem-server/ivshmem-server.h b/contrib/ivshmem-server/ivshmem-server.h
index c9359a0..e9de8a3 100644
--- a/contrib/ivshmem-server/ivshmem-server.h
+++ b/contrib/ivshmem-server/ivshmem-server.h
@@ -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"
diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h
index 956fda0..b8c2602 100644
--- a/fsdev/file-op-9p.h
+++ b/fsdev/file-op-9p.h
@@ -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>
 
diff --git a/hw/9pfs/9p-synth.h b/hw/9pfs/9p-synth.h
index eaf5a0c..8296251 100644
--- a/hw/9pfs/9p-synth.h
+++ b/hw/9pfs/9p-synth.h
@@ -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,
diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h
index edcd51b..1a19418 100644
--- a/hw/9pfs/9p.h
+++ b/hw/9pfs/9p.h
@@ -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>
diff --git a/hw/audio/gusemu.h b/hw/audio/gusemu.h
index 331bb6f..b7f0751 100644
--- a/hw/audio/gusemu.h
+++ b/hw/audio/gusemu.h
@@ -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;
diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
index 40ba6a4..bdb43a5 100644
--- a/hw/display/vga_int.h
+++ b/hw/display/vga_int.h
@@ -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
diff --git a/hw/net/fsl_etsec/registers.h b/hw/net/fsl_etsec/registers.h
index 7ad7686..6fb9684 100644
--- a/hw/net/fsl_etsec/registers.h
+++ b/hw/net/fsl_etsec/registers.h
@@ -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 */
diff --git a/hw/usb/desc.h b/hw/usb/desc.h
index 8e8db03..4d81c68 100644
--- a/hw/usb/desc.h
+++ b/hw/usb/desc.h
@@ -1,7 +1,6 @@
 #ifndef QEMU_HW_USB_DESC_H
 #define QEMU_HW_USB_DESC_H
 
-#include <inttypes.h>
 #include <wchar.h>
 
 /* binary representation */
diff --git a/io/channel-util.c b/io/channel-util.c
index f96907c..0fb4bd0 100644
--- a/io/channel-util.c
+++ b/io/channel-util.c
@@ -18,6 +18,7 @@
  *
  */
 
+#include "qemu/osdep.h"
 #include "io/channel-util.h"
 #include "io/channel-file.h"
 #include "io/channel-socket.h"
diff --git a/linux-user/arm/nwfpe/fpa11.h b/linux-user/arm/nwfpe/fpa11.h
index bb9ac65..7e114ee 100644
--- a/linux-user/arm/nwfpe/fpa11.h
+++ b/linux-user/arm/nwfpe/fpa11.h
@@ -21,9 +21,6 @@
 #ifndef __FPA11_H__
 #define __FPA11_H__
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
 
 #include <cpu.h>
 
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index bd90cc3..ba5b433 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -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"
diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h
index db6ab65..d09b4ee 100644
--- a/nbd/nbd-internal.h
+++ b/nbd/nbd-internal.h
@@ -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>
diff --git a/net/tap-linux.h b/net/tap-linux.h
index 01dc6f8..1dc3a9f 100644
--- a/net/tap-linux.h
+++ b/net/tap-linux.h
@@ -16,7 +16,6 @@
 #ifndef QEMU_TAP_LINUX_H
 #define QEMU_TAP_LINUX_H
 
-#include <stdint.h>
 #ifdef __linux__
 
 #include <linux/ioctl.h>
diff --git a/net/util.h b/net/util.h
index 10c7da9..60b73d3 100644
--- a/net/util.h
+++ b/net/util.h
@@ -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);
 
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 933ca4a..3a280ee 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -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>
 
diff --git a/qga/vss-win32.h b/qga/vss-win32.h
index 298927d..4d1d150 100644
--- a/qga/vss-win32.h
+++ b/qga/vss-win32.h
@@ -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);
diff --git a/qga/vss-win32/requester.h b/qga/vss-win32/requester.h
index c3093cf..ad2bf3d 100644
--- a/qga/vss-win32/requester.h
+++ b/qga/vss-win32/requester.h
@@ -14,7 +14,6 @@
 #define VSS_WIN32_REQUESTER_H
 
 #include <basetyps.h>           /* STDAPI */
-#include "qemu/compiler.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/qga/vss-win32/vss-common.h b/qga/vss-win32/vss-common.h
index ce14e14..91dae0c 100644
--- a/qga/vss-win32/vss-common.h
+++ b/qga/vss-win32/vss-common.h
@@ -14,7 +14,6 @@
 #define VSS_WIN32_H
 
 #define __MIDL_user_allocate_free_DEFINED__
-#include "config-host.h"
 #include <windows.h>
 #include <shlwapi.h>
 
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index 77e0d29..5438ebd 100644
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -12,7 +12,6 @@
  *
  */
 
-#include <stdio.h>
 
 enum ReplayEvents {
     /* for instruction event */
diff --git a/slirp/slirp.h b/slirp/slirp.h
index 239fe29..07c13b4 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -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. */
diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h
index bcd8076..420f2a5 100644
--- a/target-alpha/cpu.h
+++ b/target-alpha/cpu.h
@@ -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
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 1623821..3cbda73 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -19,7 +19,6 @@
 #ifndef CPU_ARM_H
 #define CPU_ARM_H
 
-#include "config.h"
 
 #include "kvm-consts.h"
 
diff --git a/target-arm/kvm-consts.h b/target-arm/kvm-consts.h
index 943bf89..a2c9518 100644
--- a/target-arm/kvm-consts.h
+++ b/target-arm/kvm-consts.h
@@ -15,7 +15,6 @@
 #define ARM_KVM_CONSTS_H
 
 #ifdef CONFIG_KVM
-#include "qemu/compiler.h"
 #include <linux/kvm.h>
 #include <linux/psci.h>
 
diff --git a/target-cris/cpu.h b/target-cris/cpu.h
index 3220460..415cf91 100644
--- a/target-cris/cpu.h
+++ b/target-cris/cpu.h
@@ -20,7 +20,6 @@
 #ifndef CPU_CRIS_H
 #define CPU_CRIS_H
 
-#include "config.h"
 #include "qemu-common.h"
 
 #define TARGET_LONG_BITS 32
diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
index 5f9d960..cb75017 100644
--- a/target-i386/cpu-qom.h
+++ b/target-i386/cpu-qom.h
@@ -22,7 +22,6 @@
 
 #include "qom/cpu.h"
 #include "cpu.h"
-#include "qapi/error.h"
 #include "qemu/notify.h"
 
 #ifdef TARGET_X86_64
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 94cb4db..7febc3f 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -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"
 
diff --git a/target-i386/mpx_helper.c b/target-i386/mpx_helper.c
index 1bf717a..052a69c 100644
--- a/target-i386/mpx_helper.c
+++ b/target-i386/mpx_helper.c
@@ -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"
diff --git a/target-lm32/cpu.h b/target-lm32/cpu.h
index 2b7620c..f220fc0 100644
--- a/target-lm32/cpu.h
+++ b/target-lm32/cpu.h
@@ -24,7 +24,6 @@
 
 #define CPUArchState struct CPULM32State
 
-#include "config.h"
 #include "qemu-common.h"
 #include "exec/cpu-defs.h"
 struct CPULM32State;
diff --git a/target-m68k/cpu.h b/target-m68k/cpu.h
index 224c169..48b4c87 100644
--- a/target-m68k/cpu.h
+++ b/target-m68k/cpu.h
@@ -24,7 +24,6 @@
 
 #define CPUArchState struct CPUM68KState
 
-#include "config.h"
 #include "qemu-common.h"
 #include "exec/cpu-defs.h"
 
diff --git a/target-microblaze/cpu.h b/target-microblaze/cpu.h
index 6b212ab..2f7335e 100644
--- a/target-microblaze/cpu.h
+++ b/target-microblaze/cpu.h
@@ -19,7 +19,6 @@
 #ifndef CPU_MICROBLAZE_H
 #define CPU_MICROBLAZE_H
 
-#include "config.h"
 #include "qemu-common.h"
 
 #define TARGET_LONG_BITS 32
diff --git a/target-mips/cpu.h b/target-mips/cpu.h
index 17817c3..9ddc43f 100644
--- a/target-mips/cpu.h
+++ b/target-mips/cpu.h
@@ -7,7 +7,6 @@
 
 #define CPUArchState struct CPUMIPSState
 
-#include "config.h"
 #include "qemu-common.h"
 #include "mips-defs.h"
 #include "exec/cpu-defs.h"
diff --git a/target-moxie/cpu.h b/target-moxie/cpu.h
index a612744..4ee2077 100644
--- a/target-moxie/cpu.h
+++ b/target-moxie/cpu.h
@@ -19,7 +19,6 @@
 #ifndef _CPU_MOXIE_H
 #define _CPU_MOXIE_H
 
-#include "config.h"
 #include "qemu-common.h"
 
 #define TARGET_LONG_BITS 32
diff --git a/target-openrisc/cpu.h b/target-openrisc/cpu.h
index eb71607..4b63f25 100644
--- a/target-openrisc/cpu.h
+++ b/target-openrisc/cpu.h
@@ -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"
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index 892f4dc..2b10597 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -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
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 06ca60b..6ae5699 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -22,7 +22,6 @@
 #ifndef CPU_S390X_H
 #define CPU_S390X_H
 
-#include "config.h"
 #include "qemu-common.h"
 
 #define TARGET_LONG_BITS 64
diff --git a/target-sh4/cpu.h b/target-sh4/cpu.h
index 5b022c5..3b23e96 100644
--- a/target-sh4/cpu.h
+++ b/target-sh4/cpu.h
@@ -19,7 +19,6 @@
 #ifndef _CPU_SH4_H
 #define _CPU_SH4_H
 
-#include "config.h"
 #include "qemu-common.h"
 
 #define TARGET_LONG_BITS 32
diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h
index 58ff474..dc46122 100644
--- a/target-sparc/cpu.h
+++ b/target-sparc/cpu.h
@@ -1,7 +1,6 @@
 #ifndef CPU_SPARC_H
 #define CPU_SPARC_H
 
-#include "config.h"
 #include "qemu-common.h"
 #include "qemu/bswap.h"
 
diff --git a/target-tilegx/cpu.h b/target-tilegx/cpu.h
index 03df107..022cad1 100644
--- a/target-tilegx/cpu.h
+++ b/target-tilegx/cpu.h
@@ -19,7 +19,6 @@
 #ifndef CPU_TILEGX_H
 #define CPU_TILEGX_H
 
-#include "config.h"
 #include "qemu-common.h"
 
 #define TARGET_LONG_BITS 64
diff --git a/target-tricore/cpu.h b/target-tricore/cpu.h
index 20a12f3..be6f121 100644
--- a/target-tricore/cpu.h
+++ b/target-tricore/cpu.h
@@ -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"
diff --git a/target-unicore32/cpu.h b/target-unicore32/cpu.h
index 01c370c..9c1fbf9 100644
--- a/target-unicore32/cpu.h
+++ b/target-unicore32/cpu.h
@@ -19,7 +19,6 @@
 
 #define CPUArchState                struct CPUUniCore32State
 
-#include "config.h"
 #include "qemu-common.h"
 #include "exec/cpu-defs.h"
 #include "fpu/softfloat.h"
diff --git a/target-xtensa/cpu.h b/target-xtensa/cpu.h
index 15ce010..d0bd9da 100644
--- a/target-xtensa/cpu.h
+++ b/target-xtensa/cpu.h
@@ -33,7 +33,6 @@
 
 #define CPUArchState struct CPUXtensaState
 
-#include "config.h"
 #include "qemu-common.h"
 #include "exec/cpu-defs.h"
 #include "fpu/softfloat.h"
diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h
index 77e5952..3942f9c 100644
--- a/tcg/tci/tcg-target.h
+++ b/tcg/tci/tcg-target.h
@@ -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
diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h
index 69dc4d7..71dd7a6 100644
--- a/tests/libqos/ahci.h
+++ b/tests/libqos/ahci.h
@@ -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"
diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
index 61b1548..e8371b2 100644
--- a/tests/libqos/fw_cfg.h
+++ b/tests/libqos/fw_cfg.h
@@ -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;
 
diff --git a/tests/libqos/i2c.h b/tests/libqos/i2c.h
index c21f1dc..6e648f9 100644
--- a/tests/libqos/i2c.h
+++ b/tests/libqos/i2c.h
@@ -9,7 +9,6 @@
 #ifndef LIBQOS_I2C_H
 #define LIBQOS_I2C_H
 
-#include <stdint.h>
 
 typedef struct I2CAdapter I2CAdapter;
 struct I2CAdapter {
diff --git a/tests/libqos/malloc.h b/tests/libqos/malloc.h
index 0c6c9b7..ae9dac8 100644
--- a/tests/libqos/malloc.h
+++ b/tests/libqos/malloc.h
@@ -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 {
diff --git a/tests/libqos/pci.h b/tests/libqos/pci.h
index dfaee9e..c06add8 100644
--- a/tests/libqos/pci.h
+++ b/tests/libqos/pci.h
@@ -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))
diff --git a/tests/libqtest.h b/tests/libqtest.h
index ebdd5bb..37f37ad 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -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;
 
diff --git a/trace/control-internal.h b/trace/control-internal.h
index 07cb1c1..dcf67f5 100644
--- a/trace/control-internal.h
+++ b/trace/control-internal.h
@@ -10,7 +10,6 @@
 #ifndef TRACE__CONTROL_INTERNAL_H
 #define TRACE__CONTROL_INTERNAL_H
 
-#include <string.h>
 
 
 extern TraceEvent trace_events[];
diff --git a/trace/ftrace.h b/trace/ftrace.h
index 863e052..92372e3 100644
--- a/trace/ftrace.h
+++ b/trace/ftrace.h
@@ -1,7 +1,6 @@
 #ifndef TRACE_FTRACE_H
 #define TRACE_FTRACE_H
 
-#include <stdbool.h>
 
 
 #define MAX_TRACE_STRLEN 512
diff --git a/trace/simple.h b/trace/simple.h
index 8d1a32e..1e7de45 100644
--- a/trace/simple.h
+++ b/trace/simple.h
@@ -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"
 
diff --git a/ui/vnc-palette.h b/ui/vnc-palette.h
index d02f023..1bd4318 100644
--- a/ui/vnc-palette.h
+++ b/ui/vnc-palette.h
@@ -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
diff --git a/ui/vnc.h b/ui/vnc.h
index a95cc15..81a3261 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -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"
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 8/8] include: Clean up includes
  2016-02-18 18:05 [Qemu-devel] [PATCH 0/8] more include cleaning Peter Maydell
                   ` (6 preceding siblings ...)
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 7/8] all: Clean up includes Peter Maydell
@ 2016-02-18 18:05 ` Peter Maydell
  2016-02-18 19:54   ` Eric Blake
  2016-02-18 20:04 ` [Qemu-devel] [PATCH 0/8] more include cleaning Eric Blake
  8 siblings, 1 reply; 21+ messages in thread
From: Peter Maydell @ 2016-02-18 18:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches

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.

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 <peter.maydell@linaro.org>
---
 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(-)

diff --git a/include/block/accounting.h b/include/block/accounting.h
index 0f46cb4..2db2a00 100644
--- a/include/block/accounting.h
+++ b/include/block/accounting.h
@@ -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"
diff --git a/include/block/nbd.h b/include/block/nbd.h
index b197adc..b86a976 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -19,7 +19,6 @@
 #ifndef NBD_H
 #define NBD_H
 
-#include <sys/types.h>
 
 #include "qemu-common.h"
 #include "qemu/option.h"
diff --git a/include/block/snapshot.h b/include/block/snapshot.h
index c6910da6..e5c0553 100644
--- a/include/block/snapshot.h
+++ b/include/block/snapshot.h
@@ -26,7 +26,6 @@
 #define SNAPSHOT_H
 
 #include "qemu-common.h"
-#include "qapi/error.h"
 #include "qemu/option.h"
 
 
diff --git a/include/block/write-threshold.h b/include/block/write-threshold.h
index f1b899c..8a79505 100644
--- a/include/block/write-threshold.h
+++ b/include/block/write-threshold.h
@@ -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"
diff --git a/include/config.h b/include/config.h
index e20f786..992d761 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1,2 +1 @@
-#include "config-host.h"
 #include "config-target.h"
diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h
index f90ac79..c04c3ac 100644
--- a/include/crypto/cipher.h
+++ b/include/crypto/cipher.h
@@ -22,7 +22,6 @@
 #define QCRYPTO_CIPHER_H__
 
 #include "qemu-common.h"
-#include "qapi/error.h"
 
 typedef struct QCryptoCipher QCryptoCipher;
 
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index 5e8d9a1..aebccd1 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -22,7 +22,6 @@
 #define QCRYPTO_HASH_H__
 
 #include "qemu-common.h"
-#include "qapi/error.h"
 
 /* See also "QCryptoHashAlgorithm" defined in qapi/crypto.json */
 
diff --git a/include/crypto/init.h b/include/crypto/init.h
index 5fc510c..4836a37 100644
--- a/include/crypto/init.h
+++ b/include/crypto/init.h
@@ -22,7 +22,6 @@
 #define QCRYPTO_INIT_H__
 
 #include "qemu-common.h"
-#include "qapi/error.h"
 
 int qcrypto_init(Error **errp);
 
diff --git a/include/crypto/secret.h b/include/crypto/secret.h
index 913519a..60f2a50 100644
--- a/include/crypto/secret.h
+++ b/include/crypto/secret.h
@@ -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"
diff --git a/include/crypto/tlscreds.h b/include/crypto/tlscreds.h
index 21761b7..4bf1d2e 100644
--- a/include/crypto/tlscreds.h
+++ b/include/crypto/tlscreds.h
@@ -22,7 +22,6 @@
 #define QCRYPTO_TLSCRED_H__
 
 #include "qemu-common.h"
-#include "qapi/error.h"
 #include "qom/object.h"
 
 #ifdef CONFIG_GNUTLS
diff --git a/include/elf.h b/include/elf.h
index 1098d21..28d448bb 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -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;
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 83b1781..08e5093 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -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.
diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
index 5093be2..854e7e3 100644
--- a/include/exec/cpu-defs.h
+++ b/include/exec/cpu-defs.h
@@ -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
diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h
index b009ccb..ec79043 100644
--- a/include/exec/helper-head.h
+++ b/include/exec/helper-head.h
@@ -18,7 +18,6 @@
 #ifndef DEF_HELPER_H
 #define DEF_HELPER_H 1
 
-#include "qemu/osdep.h"
 
 #define HELPER(name) glue(helper_, name)
 
diff --git a/include/exec/memory.h b/include/exec/memory.h
index c92734a..d5f2b2c 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -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"
 
diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h
index 3b67462..ad1d602 100644
--- a/include/exec/user/thunk.h
+++ b/include/exec/user/thunk.h
@@ -19,7 +19,6 @@
 #ifndef THUNK_H
 #define THUNK_H
 
-#include <inttypes.h>
 #include "cpu.h"
 
 /* types enums definitions */
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 575a739..84145b1 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -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
diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h
index 2de3021..7462e20 100644
--- a/include/hw/acpi/acpi.h
+++ b/include/hw/acpi/acpi.h
@@ -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"
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index aa29d30..d3e0c8f 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -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. */
diff --git a/include/hw/acpi/bios-linker-loader.h b/include/hw/acpi/bios-linker-loader.h
index 498c0af..721b7b9 100644
--- a/include/hw/acpi/bios-linker-loader.h
+++ b/include/hw/acpi/bios-linker-loader.h
@@ -2,8 +2,6 @@
 #define BIOS_LINKER_LOADER_H
 
 #include <glib.h>
-#include <stdbool.h>
-#include <inttypes.h>
 
 GArray *bios_linker_loader_init(void);
 
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index f3526d4..31b7820 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -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"
diff --git a/include/hw/block/block.h b/include/hw/block/block.h
index 8d7c4b4..984660e 100644
--- a/include/hw/block/block.h
+++ b/include/hw/block/block.h
@@ -12,7 +12,6 @@
 #define HW_BLOCK_COMMON_H
 
 #include "qemu-common.h"
-#include "qapi/error.h"
 
 /* Configuration */
 
diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h
index 148cc1b..fc95572 100644
--- a/include/hw/i386/topology.h
+++ b/include/hw/i386/topology.h
@@ -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"
 
diff --git a/include/hw/isa/apm.h b/include/hw/isa/apm.h
index 3edea5f..4839ff1 100644
--- a/include/hw/isa/apm.h
+++ b/include/hw/isa/apm.h
@@ -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"
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index 664eaf6..5d19975 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -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"
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index dedf277..0be07c8 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -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"
diff --git a/include/hw/pci/shpc.h b/include/hw/pci/shpc.h
index 2c871b9..b208554 100644
--- a/include/hw/pci/shpc.h
+++ b/include/hw/pci/shpc.h
@@ -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"
 
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index abcdee8..c3ff99f 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -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 {
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index c59cc81..d6b012f 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -11,7 +11,6 @@
 #ifndef VHOST_BACKEND_H_
 #define VHOST_BACKEND_H_
 
-#include <stdbool.h>
 
 typedef enum VhostBackendType {
     VHOST_BACKEND_TYPE_NONE = 0,
diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
index df33481..bf3fe97 100644
--- a/include/hw/xen/xen.h
+++ b/include/hw/xen/xen.h
@@ -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"
diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index 7a3cce0..bd65e67 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -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
diff --git a/include/io/channel.h b/include/io/channel.h
index 3e17fe7..0a1f1ce 100644
--- a/include/io/channel.h
+++ b/include/io/channel.h
@@ -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"
diff --git a/include/io/task.h b/include/io/task.h
index 2418714..2e69d8a 100644
--- a/include/io/task.h
+++ b/include/io/task.h
@@ -22,7 +22,6 @@
 #define QIO_TASK_H__
 
 #include "qemu-common.h"
-#include "qapi/error.h"
 #include "qom/object.h"
 
 typedef struct QIOTask QIOTask;
diff --git a/include/libdecnumber/dconfig.h b/include/libdecnumber/dconfig.h
index 2f0455a..0f7dcce 100644
--- a/include/libdecnumber/dconfig.h
+++ b/include/libdecnumber/dconfig.h
@@ -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
diff --git a/include/libdecnumber/decContext.h b/include/libdecnumber/decContext.h
index c3e46f4..01365e2 100644
--- a/include/libdecnumber/decContext.h
+++ b/include/libdecnumber/decContext.h
@@ -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	      */
diff --git a/include/libdecnumber/decNumberLocal.h b/include/libdecnumber/decNumberLocal.h
index 71ed77b..94fb512 100644
--- a/include/libdecnumber/decNumberLocal.h
+++ b/include/libdecnumber/decNumberLocal.h
@@ -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     */
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 74684ad..65d47a9 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -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"
diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
index b5d08d2..3f6b4ed 100644
--- a/include/migration/qemu-file.h
+++ b/include/migration/qemu-file.h
@@ -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
diff --git a/include/net/checksum.h b/include/net/checksum.h
index 2d7a363..7de1acb 100644
--- a/include/net/checksum.h
+++ b/include/net/checksum.h
@@ -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);
diff --git a/include/net/eth.h b/include/net/eth.h
index 84384fe..18d0be3 100644
--- a/include/net/eth.h
+++ b/include/net/eth.h
@@ -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"
 
diff --git a/include/qapi/error.h b/include/qapi/error.h
index e64fe54..02e9dd2 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -115,9 +115,6 @@
 #ifndef ERROR_H
 #define ERROR_H
 
-#include <stdarg.h>
-#include <stdbool.h>
-#include "qemu/compiler.h"
 #include "qapi-types.h"
 
 /*
diff --git a/include/qapi/qmp-event.h b/include/qapi/qmp-event.h
index 8a8ffb5..40fe3cb 100644
--- a/include/qapi/qmp-event.h
+++ b/include/qapi/qmp-event.h
@@ -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);
diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h
index e389697..4955209 100644
--- a/include/qapi/qmp/dispatch.h
+++ b/include/qapi/qmp/dispatch.h
@@ -16,7 +16,6 @@
 
 #include "qapi/qmp/qobject.h"
 #include "qapi/qmp/qdict.h"
-#include "qapi/error.h"
 
 typedef void (QmpCommandFunc)(QDict *, QObject **, Error **);
 
diff --git a/include/qapi/qmp/json-lexer.h b/include/qapi/qmp/json-lexer.h
index cb456d5..afee782 100644
--- a/include/qapi/qmp/json-lexer.h
+++ b/include/qapi/qmp/json-lexer.h
@@ -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,
diff --git a/include/qapi/qmp/json-parser.h b/include/qapi/qmp/json-parser.h
index fea89f8..9987f8c 100644
--- a/include/qapi/qmp/json-parser.h
+++ b/include/qapi/qmp/json-parser.h
@@ -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);
diff --git a/include/qapi/qmp/json-streamer.h b/include/qapi/qmp/json-streamer.h
index 09b3d3e..00d8a23 100644
--- a/include/qapi/qmp/json-streamer.h
+++ b/include/qapi/qmp/json-streamer.h
@@ -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 {
diff --git a/include/qapi/qmp/qbool.h b/include/qapi/qmp/qbool.h
index 836d078..a41111c 100644
--- a/include/qapi/qmp/qbool.h
+++ b/include/qapi/qmp/qbool.h
@@ -14,7 +14,6 @@
 #ifndef QBOOL_H
 #define QBOOL_H
 
-#include <stdbool.h>
 #include "qapi/qmp/qobject.h"
 
 typedef struct QBool {
diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
index 6c2a0e5..71b8eb0 100644
--- a/include/qapi/qmp/qdict.h
+++ b/include/qapi/qmp/qdict.h
@@ -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
 
diff --git a/include/qapi/qmp/qfloat.h b/include/qapi/qmp/qfloat.h
index a8af2a8..b5d1583 100644
--- a/include/qapi/qmp/qfloat.h
+++ b/include/qapi/qmp/qfloat.h
@@ -14,7 +14,6 @@
 #ifndef QFLOAT_H
 #define QFLOAT_H
 
-#include <stdint.h>
 #include "qapi/qmp/qobject.h"
 
 typedef struct QFloat {
diff --git a/include/qapi/qmp/qint.h b/include/qapi/qmp/qint.h
index 049e528..3aaff76 100644
--- a/include/qapi/qmp/qint.h
+++ b/include/qapi/qmp/qint.h
@@ -13,7 +13,6 @@
 #ifndef QINT_H
 #define QINT_H
 
-#include <stdint.h>
 #include "qapi/qmp/qobject.h"
 
 typedef struct QInt {
diff --git a/include/qapi/qmp/qjson.h b/include/qapi/qmp/qjson.h
index ee4d31a..02b1f2c 100644
--- a/include/qapi/qmp/qjson.h
+++ b/include/qapi/qmp/qjson.h
@@ -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"
 
diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
index 74459ae..b8ddbca 100644
--- a/include/qapi/qmp/qobject.h
+++ b/include/qapi/qmp/qobject.h
@@ -32,8 +32,6 @@
 #ifndef QOBJECT_H
 #define QOBJECT_H
 
-#include <stddef.h>
-#include <assert.h>
 #include "qapi-types.h"
 
 struct QObject {
diff --git a/include/qapi/qmp/qstring.h b/include/qapi/qmp/qstring.h
index df7df55..10076b7 100644
--- a/include/qapi/qmp/qstring.h
+++ b/include/qapi/qmp/qstring.h
@@ -13,7 +13,6 @@
 #ifndef QSTRING_H
 #define QSTRING_H
 
-#include <stdint.h>
 #include "qapi/qmp/qobject.h"
 
 typedef struct QString {
diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h
index ea252f8..5b6238ad 100644
--- a/include/qapi/visitor-impl.h
+++ b/include/qapi/visitor-impl.h
@@ -12,7 +12,6 @@
 #ifndef QAPI_VISITOR_IMPL_H
 #define QAPI_VISITOR_IMPL_H
 
-#include "qapi/error.h"
 #include "qapi/visitor.h"
 
 struct Visitor
diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h
index 5e581dc..5aa0f58 100644
--- a/include/qapi/visitor.h
+++ b/include/qapi/visitor.h
@@ -16,8 +16,6 @@
 
 #include "qemu/typedefs.h"
 #include "qapi/qmp/qobject.h"
-#include "qapi/error.h"
-#include <stdlib.h>
 
 typedef struct GenericList
 {
diff --git a/include/qemu-common.h b/include/qemu-common.h
index f557be7..a85e9bf 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -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"
 
diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index 05b447c..8f1d8d9 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -15,7 +15,6 @@
 #ifndef __QEMU_ATOMIC_H
 #define __QEMU_ATOMIC_H 1
 
-#include "qemu/compiler.h"
 
 
 /* Compiler barrier */
diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h
index 86dd9cd..0e33fa5 100644
--- a/include/qemu/bitmap.h
+++ b/include/qemu/bitmap.h
@@ -13,10 +13,7 @@
 #define BITMAP_H
 
 #include <glib.h>
-#include <string.h>
-#include <stdlib.h>
 
-#include "qemu/osdep.h"
 #include "qemu/bitops.h"
 
 /*
diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
index 8164225..755fdd1 100644
--- a/include/qemu/bitops.h
+++ b/include/qemu/bitops.h
@@ -12,8 +12,6 @@
 #ifndef BITOPS_H
 #define BITOPS_H
 
-#include <stdint.h>
-#include <assert.h>
 
 #include "host-utils.h"
 #include "atomic.h"
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index 07d88de..95071ba 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -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>
diff --git a/include/qemu/compatfd.h b/include/qemu/compatfd.h
index fc37915..aa12ee9 100644
--- a/include/qemu/compatfd.h
+++ b/include/qemu/compatfd.h
@@ -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 */
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index c5fbe28..8f1cc7b 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -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.
diff --git a/include/qemu/config-file.h b/include/qemu/config-file.h
index d4ba20e..3b8ecb0 100644
--- a/include/qemu/config-file.h
+++ b/include/qemu/config-file.h
@@ -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);
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
index 20c027a..99b9398 100644
--- a/include/qemu/coroutine.h
+++ b/include/qemu/coroutine.h
@@ -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"
diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
index 7ab2355..7a2a363 100644
--- a/include/qemu/error-report.h
+++ b/include/qemu/error-report.h
@@ -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 */
diff --git a/include/qemu/fprintf-fn.h b/include/qemu/fprintf-fn.h
index 9ddc90f..b6bad35 100644
--- a/include/qemu/fprintf-fn.h
+++ b/include/qemu/fprintf-fn.h
@@ -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);
diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h
index bb94a00..e29188c 100644
--- a/include/qemu/hbitmap.h
+++ b/include/qemu/hbitmap.h
@@ -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"
 
diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h
index 3ef97d5..1cdae0d 100644
--- a/include/qemu/host-utils.h
+++ b/include/qemu/host-utils.h
@@ -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,
diff --git a/include/qemu/int128.h b/include/qemu/int128.h
index fb782aa..c598881 100644
--- a/include/qemu/int128.h
+++ b/include/qemu/int128.h
@@ -1,9 +1,6 @@
 #ifndef INT128_H
 #define INT128_H
 
-#include <assert.h>
-#include <stdint.h>
-#include <stdbool.h>
 
 typedef struct Int128 Int128;
 
diff --git a/include/qemu/log.h b/include/qemu/log.h
index 30817f7..1afac63 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -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;
diff --git a/include/qemu/memfd.h b/include/qemu/memfd.h
index 53858ed..745a8c5 100644
--- a/include/qemu/memfd.h
+++ b/include/qemu/memfd.h
@@ -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
diff --git a/include/qemu/module.h b/include/qemu/module.h
index 72d9498..85fafa2 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -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)
diff --git a/include/qemu/option.h b/include/qemu/option.h
index 71f5f27..8809ce1 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -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"
 
diff --git a/include/qemu/range.h b/include/qemu/range.h
index cfa021f..9fc547b 100644
--- a/include/qemu/range.h
+++ b/include/qemu/range.h
@@ -1,7 +1,6 @@
 #ifndef QEMU_RANGE_H
 #define QEMU_RANGE_H
 
-#include <inttypes.h>
 #include <qemu/typedefs.h>
 #include "qemu/queue.h"
 
diff --git a/include/qemu/rcu.h b/include/qemu/rcu.h
index 7c7cca7..56d3a68 100644
--- a/include/qemu/rcu.h
+++ b/include/qemu/rcu.h
@@ -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"
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
index cde2f5e..0be68de 100644
--- a/include/qemu/sockets.h
+++ b/include/qemu/sockets.h
@@ -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 */
diff --git a/include/qemu/thread.h b/include/qemu/thread.h
index 5114ec8..bdae6df 100644
--- a/include/qemu/thread.h
+++ b/include/qemu/thread.h
@@ -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;
diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h
index d0c98ed..13dae95 100644
--- a/include/qemu/throttle.h
+++ b/include/qemu/throttle.h
@@ -25,7 +25,6 @@
 #ifndef THROTTLE_H
 #define THROTTLE_H
 
-#include <stdint.h>
 #include "qemu-common.h"
 #include "qemu/timer.h"
 
diff --git a/include/qemu/timed-average.h b/include/qemu/timed-average.h
index 364bf88..08245e7 100644
--- a/include/qemu/timed-average.h
+++ b/include/qemu/timed-average.h
@@ -25,7 +25,6 @@
 #ifndef TIMED_AVERAGE_H
 #define TIMED_AVERAGE_H
 
-#include <stdint.h>
 
 #include "qemu/timer.h"
 
diff --git a/include/qemu/xattr.h b/include/qemu/xattr.h
index f910d96..83cf98c 100644
--- a/include/qemu/xattr.h
+++ b/include/qemu/xattr.h
@@ -18,7 +18,6 @@
  * in /usr/include/sys, and don't have ENOATTR.
  */
 
-#include "config-host.h"
 
 #ifdef CONFIG_LIBATTR
 #  include <attr/xattr.h>
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index ff54600..1df7cb4 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -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"
diff --git a/include/qom/object.h b/include/qom/object.h
index 33abce9..eda16df 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -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;
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index ec30331..66c5cf2 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -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
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
index b06a060..16432f3 100644
--- a/include/sysemu/blockdev.h
+++ b/include/sysemu/blockdev.h
@@ -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);
diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
index efa8b99..b0fbb9b 100644
--- a/include/sysemu/dma.h
+++ b/include/sysemu/dma.h
@@ -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"
diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h
index 1ce4394..a19801d 100644
--- a/include/sysemu/hostmem.h
+++ b/include/sysemu/hostmem.h
@@ -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"
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 7741f91..6695fa7 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -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"
diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h
index a6392bc..bb184c9 100644
--- a/include/sysemu/numa.h
+++ b/include/sysemu/numa.h
@@ -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"
diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h
index f131521..5b9c4d6 100644
--- a/include/sysemu/os-posix.h
+++ b/include/sysemu/os-posix.h
@@ -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);
diff --git a/include/sysemu/qtest.h b/include/sysemu/qtest.h
index 05473b7..70aa40a 100644
--- a/include/sysemu/qtest.h
+++ b/include/sysemu/qtest.h
@@ -15,7 +15,6 @@
 #define QTEST_H
 
 #include "qemu-common.h"
-#include "qapi/error.h"
 
 extern bool qtest_allowed;
 
diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h
index abb4688..e4108e8 100644
--- a/include/sysemu/replay.h
+++ b/include/sysemu/replay.h
@@ -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 */
diff --git a/include/sysemu/rng.h b/include/sysemu/rng.h
index 0a27c9b..858be8c 100644
--- a/include/sysemu/rng.h
+++ b/include/sysemu/rng.h
@@ -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) \
diff --git a/include/sysemu/seccomp.h b/include/sysemu/seccomp.h
index 1189fa2..cfc0600 100644
--- a/include/sysemu/seccomp.h
+++ b/include/sysemu/seccomp.h
@@ -16,7 +16,6 @@
 #define QEMU_SECCOMP_H
 
 #include <seccomp.h>
-#include "qemu/osdep.h"
 
 int seccomp_start(void);
 #endif
diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h
index 0a366be..e3ec800 100644
--- a/include/sysemu/tpm_backend.h
+++ b/include/sysemu/tpm_backend.h
@@ -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"
diff --git a/include/sysemu/xen-mapcache.h b/include/sysemu/xen-mapcache.h
index c598040..c849489 100644
--- a/include/sysemu/xen-mapcache.h
+++ b/include/sysemu/xen-mapcache.h
@@ -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,
diff --git a/include/ui/console.h b/include/ui/console.h
index c8f9f7e..6631b96 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -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>
diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index f9ce357..2dabe49 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -18,7 +18,6 @@
 #ifndef QEMU_SPICE_H
 #define QEMU_SPICE_H
 
-#include "config-host.h"
 
 #ifdef CONFIG_SPICE
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files Peter Maydell
@ 2016-02-18 18:36   ` Peter Maydell
  2016-02-18 19:04   ` Eric Blake
  1 sibling, 0 replies; 21+ messages in thread
From: Peter Maydell @ 2016-02-18 18:36 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Patch Tracking

On 18 February 2016 at 18:05, Peter Maydell <peter.maydell@linaro.org> wrote:
> 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.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/.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> Reviewed-by: Eric Blake <eblake@redhat.com>

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 2/8] osdep.h: Define macros for the benefit of C++ before C++11
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 2/8] osdep.h: Define macros for the benefit of C++ before C++11 Peter Maydell
@ 2016-02-18 18:51   ` Eric Blake
  0 siblings, 0 replies; 21+ messages in thread
From: Eric Blake @ 2016-02-18 18:51 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches

[-- Attachment #1: Type: text/plain, Size: 1503 bytes --]

On 02/18/2016 11:05 AM, Peter Maydell wrote:
> For 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.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  include/qemu/osdep.h | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)

Reviewed-by: Eric Blake <eblake@redhat.com>

> +/* 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.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files Peter Maydell
  2016-02-18 18:36   ` Peter Maydell
@ 2016-02-18 19:04   ` Eric Blake
  2016-02-18 20:07     ` Peter Maydell
  2016-02-19 18:03     ` Peter Maydell
  1 sibling, 2 replies; 21+ messages in thread
From: Eric Blake @ 2016-02-18 19:04 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches

[-- Attachment #1: Type: text/plain, Size: 3421 bytes --]

On 02/18/2016 11:05 AM, Peter Maydell wrote:
> 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.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/.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>  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 :)

> 
> diff --git a/scripts/clean-includes b/scripts/clean-includes
> index 1af1f82..737a5ce 100755
> --- a/scripts/clean-includes
> +++ b/scripts/clean-includes
> @@ -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'?

>  #
>  # Copyright (c) 2015 Linaro Limited

Want to add 2016?

>  #
> @@ -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?

> +  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.

> +
> +  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?

> +    # (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),...

> +  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.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 5/8] scripts/clean-includes: Add --all option
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 5/8] scripts/clean-includes: Add --all option Peter Maydell
@ 2016-02-18 19:09   ` Eric Blake
  0 siblings, 0 replies; 21+ messages in thread
From: Eric Blake @ 2016-02-18 19:09 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches

[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]

On 02/18/2016 11:05 AM, Peter Maydell wrote:
> 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 <peter.maydell@linaro.org>
> ---
>  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).

> +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...

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 6/8] osdep.h: Include config-target.h if NEED_CPU_H is defined
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 6/8] osdep.h: Include config-target.h if NEED_CPU_H is defined Peter Maydell
@ 2016-02-18 19:09   ` Eric Blake
  0 siblings, 0 replies; 21+ messages in thread
From: Eric Blake @ 2016-02-18 19:09 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches

[-- Attachment #1: Type: text/plain, Size: 907 bytes --]

On 02/18/2016 11:05 AM, Peter Maydell wrote:
> NEED_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.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  include/qemu/osdep.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> index c1b413d..80c62be 100644
> --- a/include/qemu/osdep.h
> +++ b/include/qemu/osdep.h
> @@ -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"

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 7/8] all: Clean up includes
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 7/8] all: Clean up includes Peter Maydell
@ 2016-02-18 19:16   ` Eric Blake
  2016-02-18 20:10     ` Peter Maydell
  0 siblings, 1 reply; 21+ messages in thread
From: Eric Blake @ 2016-02-18 19:16 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches

[-- Attachment #1: Type: text/plain, Size: 2027 bytes --]

On 02/18/2016 11:05 AM, Peter Maydell wrote:
> 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.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---

>  56 files changed, 2 insertions(+), 100 deletions(-)
> 

> +++ b/io/channel-util.c
> @@ -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.

> +++ b/slirp/slirp.h
> @@ -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

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,
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 8/8] include: Clean up includes
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 8/8] include: " Peter Maydell
@ 2016-02-18 19:54   ` Eric Blake
  2016-02-18 20:12     ` Peter Maydell
  0 siblings, 1 reply; 21+ messages in thread
From: Eric Blake @ 2016-02-18 19:54 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches

[-- Attachment #1: Type: text/plain, Size: 1052 bytes --]

On 02/18/2016 11:05 AM, Peter Maydell wrote:
> 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.
> 
> 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 <peter.maydell@linaro.org>
> ---

>  97 files changed, 156 deletions(-)

> 
> +++ b/include/migration/qemu-file.h
> @@ -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.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 0/8] more include cleaning
  2016-02-18 18:05 [Qemu-devel] [PATCH 0/8] more include cleaning Peter Maydell
                   ` (7 preceding siblings ...)
  2016-02-18 18:05 ` [Qemu-devel] [PATCH 8/8] include: " Peter Maydell
@ 2016-02-18 20:04 ` Eric Blake
  8 siblings, 0 replies; 21+ messages in thread
From: Eric Blake @ 2016-02-18 20:04 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches

[-- Attachment #1: Type: text/plain, Size: 1613 bytes --]

On 02/18/2016 11:05 AM, Peter Maydell wrote:
> 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):

Tested-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files
  2016-02-18 19:04   ` Eric Blake
@ 2016-02-18 20:07     ` Peter Maydell
  2016-02-19 18:03     ` Peter Maydell
  1 sibling, 0 replies; 21+ messages in thread
From: Peter Maydell @ 2016-02-18 20:07 UTC (permalink / raw)
  To: Eric Blake; +Cc: QEMU Developers, Patch Tracking

On 18 February 2016 at 19:04, Eric Blake <eblake@redhat.com> wrote:
> On 02/18/2016 11:05 AM, Peter Maydell wrote:
>> 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.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/.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> ---
>>  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 :)
>
>>
>> diff --git a/scripts/clean-includes b/scripts/clean-includes
>> index 1af1f82..737a5ce 100755
>> --- a/scripts/clean-includes
>> +++ b/scripts/clean-includes
>> @@ -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.

>>  #
>>  # Copyright (c) 2015 Linaro Limited
>
> Want 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.

>>  #
>> @@ -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?

Feels a touch over-verbose to me.

>> +  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.

>> +
>> +  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?

OK.

>> +    # (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.

> I can understand the use of perl here (detecting duplicates lines is
> doable, but a lot harder, in sed),...
>
>> +  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.

> 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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 7/8] all: Clean up includes
  2016-02-18 19:16   ` Eric Blake
@ 2016-02-18 20:10     ` Peter Maydell
  0 siblings, 0 replies; 21+ messages in thread
From: Peter Maydell @ 2016-02-18 20:10 UTC (permalink / raw)
  To: Eric Blake; +Cc: QEMU Developers, Patch Tracking

On 18 February 2016 at 19:16, Eric Blake <eblake@redhat.com> wrote:
> On 02/18/2016 11:05 AM, Peter Maydell wrote:
>> 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.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>
>>  56 files changed, 2 insertions(+), 100 deletions(-)
>>
>
>> +++ b/io/channel-util.c
>> @@ -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.

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.

> 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.

OK. Will put it on my list to fix up later.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 8/8] include: Clean up includes
  2016-02-18 19:54   ` Eric Blake
@ 2016-02-18 20:12     ` Peter Maydell
  0 siblings, 0 replies; 21+ messages in thread
From: Peter Maydell @ 2016-02-18 20:12 UTC (permalink / raw)
  To: Eric Blake; +Cc: QEMU Developers, Patch Tracking

On 18 February 2016 at 19:54, Eric Blake <eblake@redhat.com> wrote:
> On 02/18/2016 11:05 AM, Peter Maydell wrote:
>> 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.
>>
>> 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 <peter.maydell@linaro.org>
>> ---
>
>>  97 files changed, 156 deletions(-)
>
>>
>> +++ b/include/migration/qemu-file.h
>> @@ -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.

Oh, you mean we end up with two blank lines in a row? Yeah,
I don't care about that either :-)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files
  2016-02-18 19:04   ` Eric Blake
  2016-02-18 20:07     ` Peter Maydell
@ 2016-02-19 18:03     ` Peter Maydell
  1 sibling, 0 replies; 21+ messages in thread
From: Peter Maydell @ 2016-02-19 18:03 UTC (permalink / raw)
  To: Eric Blake; +Cc: QEMU Developers, Patch Tracking

On 18 February 2016 at 19:04, Eric Blake <eblake@redhat.com> wrote:
> On 02/18/2016 11:05 AM, Peter Maydell wrote:
>> 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.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/.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
>> ---
>>  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 :)
>
>>
>> diff --git a/scripts/clean-includes b/scripts/clean-includes
>> index 1af1f82..737a5ce 100755
>> --- a/scripts/clean-includes
>> +++ b/scripts/clean-includes
>> @@ -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'?
>
>>  #
>>  # Copyright (c) 2015 Linaro Limited
>
> Want to add 2016?
>
>>  #
>> @@ -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?
>
>> +  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

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2016-02-19 18:03 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-18 18:05 [Qemu-devel] [PATCH 0/8] more include cleaning Peter Maydell
2016-02-18 18:05 ` [Qemu-devel] [PATCH 1/8] cpu: Clean up includes Peter Maydell
2016-02-18 18:05 ` [Qemu-devel] [PATCH 2/8] osdep.h: Define macros for the benefit of C++ before C++11 Peter Maydell
2016-02-18 18:51   ` Eric Blake
2016-02-18 18:05 ` [Qemu-devel] [PATCH 3/8] disas/arm-a64.cc: Include osdep.h first Peter Maydell
2016-02-18 18:05 ` [Qemu-devel] [PATCH 4/8] scripts/clean-includes: Enhance to handle header files Peter Maydell
2016-02-18 18:36   ` Peter Maydell
2016-02-18 19:04   ` Eric Blake
2016-02-18 20:07     ` Peter Maydell
2016-02-19 18:03     ` Peter Maydell
2016-02-18 18:05 ` [Qemu-devel] [PATCH 5/8] scripts/clean-includes: Add --all option Peter Maydell
2016-02-18 19:09   ` Eric Blake
2016-02-18 18:05 ` [Qemu-devel] [PATCH 6/8] osdep.h: Include config-target.h if NEED_CPU_H is defined Peter Maydell
2016-02-18 19:09   ` Eric Blake
2016-02-18 18:05 ` [Qemu-devel] [PATCH 7/8] all: Clean up includes Peter Maydell
2016-02-18 19:16   ` Eric Blake
2016-02-18 20:10     ` Peter Maydell
2016-02-18 18:05 ` [Qemu-devel] [PATCH 8/8] include: " Peter Maydell
2016-02-18 19:54   ` Eric Blake
2016-02-18 20:12     ` Peter Maydell
2016-02-18 20:04 ` [Qemu-devel] [PATCH 0/8] more include cleaning Eric Blake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).