Skip to contentSkip to conversation

#include cleanliness

PATCH In review Avi Kivity 2 participants 5 messages May 19, 2011 – May 31, 2011

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 #include cleanliness

My mother always told me to explicitly #include any headers need to compile a file, instead of relying on other #includes to bring them in. This patch fixes up targphys.h and cpu-common.h in this regard.

---
 cpu-common.h |    4 ++++
 targphys.h   |    2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)
cpu-common.h +4 -0
index 151c32c..2009adc 100644
@@ -18,6 +18,10 @@
 #include "bswap.h"
 #include "qemu-queue.h"
 
+#include "qemu-common.h"
+
+#include <stdbool.h>
+
 #if !defined(CONFIG_USER_ONLY)
 
 enum device_endian {
targphys.h +2 -0
index 95648d6..501add2 100644
@@ -3,6 +3,8 @@
 #ifndef TARGPHYS_H
 #define TARGPHYS_H
 
+#include <stdint.h>
+
 #ifdef TARGET_PHYS_ADDR_BITS
 /* target_phys_addr_t is the type of a physical address (its size can
    be different from 'target_ulong').  */
Signature · 1 line
1.7.5.1
author
#1 lore raw
Quoted 3 lines · Avi Kivity

My mother always told me to explicitly #include any headers need to compile a file, instead of relying on other #includes to bring them in. This patch fixes up targphys.h and cpu-common.h in this regard.

Can some qemu maintainer review this patch? Stefan?

Signature · 1 line
error compiling committee.c: too many arguments to function
#2 lore raw
In reply to Avi Kivity
Quoted 15 lines · Avi Kivity

My mother always told me to explicitly #include any headers need to compile a file, instead of relying on other #includes to bring them in. This patch fixes up targphys.h and cpu-common.h in this regard.

---
  cpu-common.h |    4 ++++
  targphys.h   |    2 ++
  2 files changed, 6 insertions(+), 0 deletions(-)
cpu-common.h +0 -0
index 151c32c..2009adc 100644

cpu-common.h line 23

Quoted 6 lines
cpu-common.h +3 -0
@@ -18,6 +18,10 @@
  #include "bswap.h"
  #include "qemu-queue.h"
 
+#include "qemu-common.h"
+
+#include<stdbool.h>

qemu-common.h should include stdbool.

The idea behind qemu-common.h is to avoid direct includes to help with portability.

Regards,

Anthony Liguori

Quoted 17 lines
cpu-common.h +1 -0
+
  #if !defined(CONFIG_USER_ONLY)
 
  enum device_endian {
targphys.h +2 -0
index 95648d6..501add2 100644
@@ -3,6 +3,8 @@
  #ifndef TARGPHYS_H
  #define TARGPHYS_H
 
+#include<stdint.h>
+
  #ifdef TARGET_PHYS_ADDR_BITS
  /* target_phys_addr_t is the type of a physical address (its size can
     be different from 'target_ulong').  */
author
#3 lore raw
Quoted 19 lines · Anthony Liguori
Quoted 18 lines · Avi Kivity

My mother always told me to explicitly #include any headers need to compile a file, instead of relying on other #includes to bring them in. This patch fixes up targphys.h and cpu-common.h in this regard.

---
  cpu-common.h |    4 ++++
  targphys.h   |    2 ++
  2 files changed, 6 insertions(+), 0 deletions(-)
cpu-common.h +0 -0
index 151c32c..2009adc 100644
@@ -18,6 +18,10 @@
  #include "bswap.h"
  #include "qemu-queue.h"
 
Quoted 7 lines

cpu-common.h

Quoted 3 lines
cpu-common.h +3 -0
+#include "qemu-common.h"
+
+#include<stdbool.h>

qemu-common.h should include stdbool.

The idea behind qemu-common.h is to avoid direct includes to help with portability.

Okay. But note qemu-common.h #includes cpu.h #includes qemu-common.h...

I think osdep.h matches the "help with portability" label better, no?

Signature · 1 line
error compiling committee.c: too many arguments to function
#4 lore raw
Quoted 28 lines · Avi Kivity
Quoted 27 lines · Anthony Liguori
Quoted 17 lines · Avi Kivity

My mother always told me to explicitly #include any headers need to compile
a file, instead of relying on other #includes to bring them in. This patch
fixes up targphys.h and cpu-common.h in this regard.

---
cpu-common.h | 4 ++++
targphys.h | 2 ++

2 files changed, 6 insertions(+), 0 deletions(-)
cpu-common.h +0 -0
index 151c32c..2009adc 100644

cpu-common.h line 23

Quoted 6 lines
cpu-common.h +3 -0
@@ -18,6 +18,10 @@
 #include "bswap.h"
 #include "qemu-queue.h"
 
+#include "qemu-common.h"
+
+#include<stdbool.h>

qemu-common.h should include stdbool.

Quoted 4 lines
Quoted 2 lines

The idea behind qemu-common.h is to avoid direct includes to help with portability.

Okay. But note qemu-common.h #includes cpu.h #includes qemu-common.h...

Fortunately, guards will prevent infinite recursion here :-)

Quoted 1 line

I think osdep.h matches the "help with portability" label better, no?

I don't disagree, but that's not the purpose of osdep.h today. qemu-common.h is a header file that's more or less supposed to be included by everything.

It should prevent explicit #include's for system headers.

Regards,

Anthony Liguori