[Spice-devel] [PATCH] Avoid recursive inclusion of headers

Jonathon Jongsma jjongsma at redhat.com
Tue Sep 13 15:59:32 UTC 2016


On Mon, 2016-09-12 at 12:53 +0100, Frediano Ziglio wrote:
> red-common.h included utils.h which included red-common.h
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/main-channel-client.c | 1 +
>  server/red-channel-client.c  | 1 +
>  server/red-common.h          | 1 -
>  server/red-worker.h          | 1 +
>  server/sound.c               | 1 +
>  server/spicevmc.c            | 1 +
>  6 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/server/main-channel-client.c b/server/main-channel-
> client.c
> index 236a2e7..5c3ab93 100644
> --- a/server/main-channel-client.c
> +++ b/server/main-channel-client.c
> @@ -27,6 +27,7 @@
>  #include "main-channel.h"
>  #include "red-channel-client.h"
>  #include "reds.h"
> +#include "utils.h"
>  
>  #define NET_TEST_WARMUP_BYTES 0
>  #define NET_TEST_BYTES (1024 * 250)
> diff --git a/server/red-channel-client.c b/server/red-channel-
> client.c
> index 0eed02b..315160e 100644
> --- a/server/red-channel-client.c
> +++ b/server/red-channel-client.c
> @@ -36,6 +36,7 @@
>  #include "red-channel-client.h"
>  #include "red-channel-client-private.h"
>  #include "red-channel.h"
> +#include "utils.h"
>  
>  #define PING_TEST_TIMEOUT_MS (MSEC_PER_SEC * 15)
>  #define PING_TEST_IDLE_NET_TIMEOUT_MS (MSEC_PER_SEC / 10)
> diff --git a/server/red-common.h b/server/red-common.h
> index 7ab7e15..9e75f51 100644
> --- a/server/red-common.h
> +++ b/server/red-common.h
> @@ -36,7 +36,6 @@
>  #include <common/verify.h>
>  
>  #include "spice.h"
> -#include "utils.h"
>  
>  #define SPICE_UPCAST(type, ptr) \
>      (verify_expr(SPICE_OFFSETOF(type, base) ==
> 0,SPICE_CONTAINEROF(ptr, type, base)))
> diff --git a/server/red-worker.h b/server/red-worker.h
> index a0a327a..28c1c6f 100644
> --- a/server/red-worker.h
> +++ b/server/red-worker.h
> @@ -19,6 +19,7 @@
>  #define _H_REDWORKER
>  
>  #include "red-common.h"
> +#include "utils.h"
>  #include "red-qxl.h"
>  #include "red-parse-qxl.h"
>  #include "red-channel-client.h"
> diff --git a/server/sound.c b/server/sound.c
> index c08bb35..176169f 100644
> --- a/server/sound.c
> +++ b/server/sound.c
> @@ -31,6 +31,7 @@
>  
>  #include "spice.h"
>  #include "red-common.h"
> +#include "utils.h"
>  #include "main-channel.h"
>  #include "reds.h"
>  #include "red-qxl.h"
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index 3533f3f..819d42c 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -30,6 +30,7 @@
>  
>  #include <common/generated_server_marshallers.h>
>  
> +#include "utils.h"
>  #include "char-device.h"
>  #include "red-channel.h"
>  #include "red-channel-client.h"



Wouldn't it be easier to do something like this instead?



diff --git a/server/utils.h b/server/utils.h
index 00631f8..51d7630 100644
--- a/server/utils.h
+++ b/server/utils.h
@@ -18,7 +18,7 @@
 #ifndef UTILS_H_
 # define UTILS_H_
 
-#include "red-common.h"
+#include <stdint.h>
 
 #define SPICE_GNUC_VISIBLE __attribute__ ((visibility ("default")))
 

----

*not sure if stdint.h is really the only one necessary, but it seems to
compile fine in a very brief test...


More information about the Spice-devel mailing list