[PATCH] Miscellaneous fixes to #includes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(1) #include <libvirt/*.h> ---> #include "libvirt/*.h"

(2) src/internal.h has become a dumping ground for all sorts of includes. Removed the ones which are not actually used in this file (ie. almost all of them) and moved them down into the two files which actually needed them.

(3) Remove <ansidecl.h>, which is apparently some legacy thing.

(4) Add a comment that __func__ is from the C99 standard.

(5) xen_unified.c was defining a symbol called 'VERSION' which clashed with the one from "config.h", so change it to HV_VERSION.

(6) <limits.h> / <sys/syslimits.h> / backup plan if neither exists -- is done in src/internal.h, so remove explicit includes from other files.

Rich.

--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903
Index: python/libvir.c
===================================================================
RCS file: /data/cvs/libvirt/python/libvir.c,v
retrieving revision 1.24
diff -u -r1.24 libvir.c
--- python/libvir.c	30 Nov 2007 11:10:53 -0000	1.24
+++ python/libvir.c	4 Dec 2007 18:59:53 -0000
@@ -10,8 +10,8 @@
  */
 
 #include <Python.h>
-#include <libvirt/libvirt.h>
-#include <libvirt/virterror.h>
+#include "libvirt/libvirt.h"
+#include "libvirt/virterror.h"
 #include "libvirt_wrap.h"
 #include "libvirt-py.h"
 
Index: python/libvirt_wrap.h
===================================================================
RCS file: /data/cvs/libvirt/python/libvirt_wrap.h,v
retrieving revision 1.7
diff -u -r1.7 libvirt_wrap.h
--- python/libvirt_wrap.h	9 Mar 2007 15:42:50 -0000	1.7
+++ python/libvirt_wrap.h	4 Dec 2007 18:59:53 -0000
@@ -7,8 +7,8 @@
  */
 
 #include <Python.h>
-#include <libvirt/libvirt.h>
-#include <libvirt/virterror.h>
+#include "libvirt/libvirt.h"
+#include "libvirt/virterror.h"
 
 #ifdef __GNUC__
 #ifdef ATTRIBUTE_UNUSED
Index: qemud/qemud.c
===================================================================
RCS file: /data/cvs/libvirt/qemud/qemud.c,v
retrieving revision 1.65
diff -u -r1.65 qemud.c
--- qemud/qemud.c	3 Dec 2007 19:45:00 -0000	1.65
+++ qemud/qemud.c	4 Dec 2007 18:59:54 -0000
@@ -50,7 +50,7 @@
 #include <fnmatch.h>
 #include <grp.h>
 
-#include <libvirt/virterror.h>
+#include "libvirt/virterror.h"
 
 #include "internal.h"
 #include "../src/internal.h"
Index: qemud/remote.c
===================================================================
RCS file: /data/cvs/libvirt/qemud/remote.c,v
retrieving revision 1.11
diff -u -r1.11 remote.c
--- qemud/remote.c	26 Nov 2007 17:41:26 -0000	1.11
+++ qemud/remote.c	4 Dec 2007 18:59:55 -0000
@@ -45,7 +45,7 @@
 #include <ctype.h>
 #include <assert.h>
 
-#include <libvirt/virterror.h>
+#include "libvirt/virterror.h"
 
 #include "internal.h"
 #include "../src/internal.h"
Index: src/internal.h
===================================================================
RCS file: /data/cvs/libvirt/src/internal.h,v
retrieving revision 1.54
diff -u -r1.54 internal.h
--- src/internal.h	26 Nov 2007 11:40:28 -0000	1.54
+++ src/internal.h	4 Dec 2007 18:59:56 -0000
@@ -6,16 +6,22 @@
 #define __VIR_INTERNAL_H__
 
 #include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <libxml/threads.h>
+#include <limits.h>
+
 #ifdef HAVE_SYS_SYSLIMITS_H
 #include <sys/syslimits.h>
 #endif
 
+#include "hash.h"
+#include "libvirt/libvirt.h"
+#include "libvirt/virterror.h"
+#include "driver.h"
+#include <libintl.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* On architectures which lack these limits, define them (ie. Cygwin).
  * Note that the libvirt code should be robust enough to handle the
  * case where actual value is longer than these limits (eg. by setting
@@ -30,16 +36,6 @@
 #define IF_NAMESIZE 16
 #endif
 
-#include "hash.h"
-#include "libvirt/libvirt.h"
-#include "libvirt/virterror.h"
-#include "driver.h"
-#include <libintl.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #define _(str) dgettext(GETTEXT_PACKAGE, (str))
 #define N_(str) dgettext(GETTEXT_PACKAGE, (str))
 #define gettext_noop(str) (str)
@@ -52,15 +48,12 @@
 #define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0)
 #define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
 
+/* C99 uses __func__.  __FUNCTION__ is legacy. */
 #ifndef __GNUC__
-#define	__FUNCTION__	__func__
+#define __FUNCTION__ __func__
 #endif
 
 #ifdef __GNUC__
-#ifdef HAVE_ANSIDECL_H
-#include <ansidecl.h>
-#endif
-
 /**
  * ATTRIBUTE_UNUSED:
  *
Index: src/openvz_conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/openvz_conf.c,v
retrieving revision 1.7
diff -u -r1.7 openvz_conf.c
--- src/openvz_conf.c	20 Nov 2007 10:15:38 -0000	1.7
+++ src/openvz_conf.c	4 Dec 2007 18:59:56 -0000
@@ -45,7 +45,7 @@
 #include <libxml/xpath.h>
 #include <libxml/uri.h>
 
-#include <libvirt/virterror.h>
+#include "libvirt/virterror.h"
 
 #include "openvz_driver.h"
 #include "openvz_conf.h"
Index: src/openvz_driver.c
===================================================================
RCS file: /data/cvs/libvirt/src/openvz_driver.c,v
retrieving revision 1.9
diff -u -r1.9 openvz_driver.c
--- src/openvz_driver.c	20 Nov 2007 10:15:38 -0000	1.9
+++ src/openvz_driver.c	4 Dec 2007 18:59:57 -0000
@@ -52,7 +52,7 @@
 #include <stdio.h>
 #include <sys/wait.h>
 
-#include <libvirt/virterror.h>
+#include "libvirt/virterror.h"
 
 #include "openvz_driver.h"
 #include "event.h"
Index: src/proxy_internal.h
===================================================================
RCS file: /data/cvs/libvirt/src/proxy_internal.h,v
retrieving revision 1.10
diff -u -r1.10 proxy_internal.h
--- src/proxy_internal.h	31 Oct 2007 09:39:13 -0000	1.10
+++ src/proxy_internal.h	4 Dec 2007 18:59:57 -0000
@@ -12,7 +12,7 @@
 #ifndef __LIBVIR_PROXY_H__
 #define __LIBVIR_PROXY_H__
 
-#include <libvirt/libvirt.h>
+#include "libvirt/libvirt.h"
 
 #ifdef __cplusplus
 extern "C" {
Index: src/qemu_conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/qemu_conf.c,v
retrieving revision 1.21
diff -u -r1.21 qemu_conf.c
--- src/qemu_conf.c	3 Dec 2007 14:30:47 -0000	1.21
+++ src/qemu_conf.c	4 Dec 2007 18:59:59 -0000
@@ -42,7 +42,7 @@
 #include <libxml/xpath.h>
 #include <libxml/uri.h>
 
-#include <libvirt/virterror.h>
+#include "libvirt/virterror.h"
 
 #include "qemu_conf.h"
 #include "uuid.h"
Index: src/qemu_driver.c
===================================================================
RCS file: /data/cvs/libvirt/src/qemu_driver.c,v
retrieving revision 1.39
diff -u -r1.39 qemu_driver.c
--- src/qemu_driver.c	3 Dec 2007 14:30:47 -0000	1.39
+++ src/qemu_driver.c	4 Dec 2007 19:00:01 -0000
@@ -49,7 +49,7 @@
 #include <sys/wait.h>
 #include <libxml/uri.h>
 
-#include <libvirt/virterror.h>
+#include "libvirt/virterror.h"
 
 #include "event.h"
 #include "buf.h"
Index: src/remote_internal.h
===================================================================
RCS file: /data/cvs/libvirt/src/remote_internal.h,v
retrieving revision 1.2
diff -u -r1.2 remote_internal.h
--- src/remote_internal.h	26 Jun 2007 23:48:47 -0000	1.2
+++ src/remote_internal.h	4 Dec 2007 19:00:01 -0000
@@ -24,7 +24,7 @@
 #ifndef __VIR_REMOTE_INTERNAL_H__
 #define __VIR_REMOTE_INTERNAL_H__
 
-#include <libvirt/virterror.h>
+#include "libvirt/virterror.h"
 
 #ifdef __cplusplus
 extern "C" {
Index: src/test.h
===================================================================
RCS file: /data/cvs/libvirt/src/test.h,v
retrieving revision 1.7
diff -u -r1.7 test.h
--- src/test.h	4 Apr 2007 14:19:49 -0000	1.7
+++ src/test.h	4 Dec 2007 19:00:01 -0000
@@ -24,7 +24,7 @@
 #ifndef __VIR_TEST_INTERNAL_H__
 #define __VIR_TEST_INTERNAL_H__
 
-#include <libvirt/virterror.h>
+#include "libvirt/virterror.h"
 
 #ifdef __cplusplus
 extern "C" {
Index: src/util.c
===================================================================
RCS file: /data/cvs/libvirt/src/util.c,v
retrieving revision 1.8
diff -u -r1.8 util.c
--- src/util.c	3 Dec 2007 16:19:41 -0000	1.8
+++ src/util.c	4 Dec 2007 19:00:01 -0000
@@ -36,11 +36,8 @@
 #include <sys/stat.h>
 #include <string.h>
 
-#ifdef HAVE_SYS_SYSLIMITS_H
-#include <sys/syslimits.h>
-#endif
-
-#include <libvirt/virterror.h>
+#include "libvirt/virterror.h"
+#include "internal.h"
 #include "event.h"
 #include "buf.h"
 #include "util.h"
Index: src/xen_unified.c
===================================================================
RCS file: /data/cvs/libvirt/src/xen_unified.c,v
retrieving revision 1.28
diff -u -r1.28 xen_unified.c
--- src/xen_unified.c	3 Dec 2007 09:34:38 -0000	1.28
+++ src/xen_unified.c	4 Dec 2007 19:00:02 -0000
@@ -8,6 +8,8 @@
  * Richard W.M. Jones <rjones@xxxxxxxxxx>
  */
 
+#include "config.h"
+
 #ifdef WITH_XEN
 
 /* Note:
@@ -1193,15 +1195,15 @@
 
 /*----- Register with libvirt.c, and initialise Xen drivers. -----*/
 
-#define VERSION ((DOM0_INTERFACE_VERSION >> 24) * 1000000 +         \
-                 ((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 +	\
-                 (DOM0_INTERFACE_VERSION & 0xFFFF))
+#define HV_VERSION ((DOM0_INTERFACE_VERSION >> 24) * 1000000 +         \
+                    ((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 +   \
+                    (DOM0_INTERFACE_VERSION & 0xFFFF))
 
 /* The interface which we export upwards to libvirt.c. */
 static virDriver xenUnifiedDriver = {
     .no = VIR_DRV_XEN_UNIFIED,
     .name = "Xen",
-    .ver = VERSION,
+    .ver = HV_VERSION,
     .open 			= xenUnifiedOpen,
     .close 			= xenUnifiedClose,
     .supports_feature   = xenUnifiedSupportsFeature,
Index: src/xen_unified.h
===================================================================
RCS file: /data/cvs/libvirt/src/xen_unified.h,v
retrieving revision 1.9
diff -u -r1.9 xen_unified.h
--- src/xen_unified.h	3 Dec 2007 09:34:38 -0000	1.9
+++ src/xen_unified.h	4 Dec 2007 19:00:02 -0000
@@ -13,6 +13,9 @@
 
 #include "internal.h"
 
+#include <sys/un.h>
+#include <netinet/in.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
Index: tests/nodeinfotest.c
===================================================================
RCS file: /data/cvs/libvirt/tests/nodeinfotest.c,v
retrieving revision 1.3
diff -u -r1.3 nodeinfotest.c
--- tests/nodeinfotest.c	26 Nov 2007 12:03:34 -0000	1.3
+++ tests/nodeinfotest.c	4 Dec 2007 19:00:02 -0000
@@ -2,11 +2,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-
-#ifdef HAVE_SYS_SYSLIMITS_H
-#include <sys/syslimits.h>
-#endif
-
 #include <string.h>
 
 #include "testutils.h"
Index: tests/qemuxml2argvtest.c
===================================================================
RCS file: /data/cvs/libvirt/tests/qemuxml2argvtest.c,v
retrieving revision 1.8
diff -u -r1.8 qemuxml2argvtest.c
--- tests/qemuxml2argvtest.c	26 Nov 2007 12:03:34 -0000	1.8
+++ tests/qemuxml2argvtest.c	4 Dec 2007 19:00:02 -0000
@@ -8,15 +8,11 @@
 #include <sys/types.h>
 #include <fcntl.h>
 
-#ifdef HAVE_SYS_SYSLIMITS_H
-#include <sys/syslimits.h>
-#endif
-
 #ifdef WITH_QEMU
 
+#include "internal.h"
 #include "testutils.h"
 #include "qemu_conf.h"
-#include "internal.h"
 
 static char *progname;
 static char *abs_top_srcdir;
Index: tests/qemuxml2xmltest.c
===================================================================
RCS file: /data/cvs/libvirt/tests/qemuxml2xmltest.c,v
retrieving revision 1.7
diff -u -r1.7 qemuxml2xmltest.c
--- tests/qemuxml2xmltest.c	26 Nov 2007 12:03:34 -0000	1.7
+++ tests/qemuxml2xmltest.c	4 Dec 2007 19:00:02 -0000
@@ -8,15 +8,11 @@
 #include <sys/types.h>
 #include <fcntl.h>
 
-#ifdef HAVE_SYS_SYSLIMITS_H
-#include <sys/syslimits.h>
-#endif
-
 #ifdef WITH_QEMU
 
+#include "internal.h"
 #include "testutils.h"
 #include "qemu_conf.h"
-#include "internal.h"
 
 static char *progname;
 static char *abs_top_srcdir;
Index: tests/reconnect.c
===================================================================
RCS file: /data/cvs/libvirt/tests/reconnect.c,v
retrieving revision 1.3
diff -u -r1.3 reconnect.c
--- tests/reconnect.c	6 Mar 2007 21:55:44 -0000	1.3
+++ tests/reconnect.c	4 Dec 2007 19:00:02 -0000
@@ -1,7 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <libvirt/libvirt.h>
-#include <libvirt/virterror.h>
+#include "libvirt/libvirt.h"
+#include "libvirt/virterror.h"
 #include "internal.h"
 
 static void errorHandler(void *userData ATTRIBUTE_UNUSED,
Index: tests/sexpr2xmltest.c
===================================================================
RCS file: /data/cvs/libvirt/tests/sexpr2xmltest.c,v
retrieving revision 1.20
diff -u -r1.20 sexpr2xmltest.c
--- tests/sexpr2xmltest.c	26 Nov 2007 12:03:34 -0000	1.20
+++ tests/sexpr2xmltest.c	4 Dec 2007 19:00:02 -0000
@@ -3,15 +3,12 @@
 #include <stdio.h>
 #include <string.h>
 
-#ifdef HAVE_SYS_SYSLIMITS_H
-#include <sys/syslimits.h>
-#endif
-
 #ifdef WITH_XEN
+
+#include "internal.h"
 #include "xml.h"
 #include "xend_internal.h"
 #include "testutils.h"
-#include "internal.h"
 
 static char *progname;
 static char *abs_top_srcdir;
Index: tests/virshtest.c
===================================================================
RCS file: /data/cvs/libvirt/tests/virshtest.c,v
retrieving revision 1.7
diff -u -r1.7 virshtest.c
--- tests/virshtest.c	26 Nov 2007 12:03:34 -0000	1.7
+++ tests/virshtest.c	4 Dec 2007 19:00:02 -0000
@@ -3,15 +3,10 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
-#include <limits.h>
-
-#ifdef HAVE_SYS_SYSLIMITS_H
-#include <sys/syslimits.h>
-#endif
 
+#include "internal.h"
 #include "xml.h"
 #include "testutils.h"
-#include "internal.h"
 
 static char *progname;
 static char *abs_top_srcdir;
Index: tests/xencapstest.c
===================================================================
RCS file: /data/cvs/libvirt/tests/xencapstest.c,v
retrieving revision 1.6
diff -u -r1.6 xencapstest.c
--- tests/xencapstest.c	26 Nov 2007 12:03:34 -0000	1.6
+++ tests/xencapstest.c	4 Dec 2007 19:00:03 -0000
@@ -2,18 +2,13 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-
-#ifdef HAVE_SYS_SYSLIMITS_H
-#include <sys/syslimits.h>
-#endif
+#include <string.h>
 
 #ifdef WITH_XEN
 
-#include <string.h>
-
+#include "internal.h"
 #include "xml.h"
 #include "testutils.h"
-#include "internal.h"
 #include "xen_internal.h"
 
 static char *progname;
Index: tests/xmconfigtest.c
===================================================================
RCS file: /data/cvs/libvirt/tests/xmconfigtest.c,v
retrieving revision 1.8
diff -u -r1.8 xmconfigtest.c
--- tests/xmconfigtest.c	26 Nov 2007 12:03:34 -0000	1.8
+++ tests/xmconfigtest.c	4 Dec 2007 19:00:03 -0000
@@ -26,15 +26,12 @@
 #include <stdio.h>
 #include <string.h>
 
-#ifdef HAVE_SYS_SYSLIMITS_H
-#include <sys/syslimits.h>
-#endif
-
 #ifdef WITH_XEN
+
+#include "internal.h"
 #include "xen_unified.h"
 #include "xm_internal.h"
 #include "testutils.h"
-#include "internal.h"
 #include "conf.h"
 
 static char *progname;
Index: tests/xml2sexprtest.c
===================================================================
RCS file: /data/cvs/libvirt/tests/xml2sexprtest.c,v
retrieving revision 1.19
diff -u -r1.19 xml2sexprtest.c
--- tests/xml2sexprtest.c	30 Nov 2007 22:51:55 -0000	1.19
+++ tests/xml2sexprtest.c	4 Dec 2007 19:00:03 -0000
@@ -2,21 +2,16 @@
 #include "config.h"
 
 #include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
-
+#include <string.h>
 #include <sys/types.h>
 #include <fcntl.h>
 
-#ifdef HAVE_SYS_SYSLIMITS_H
-#include <sys/syslimits.h>
-#endif
-
 #if WITH_XEN
 
+#include "internal.h"
 #include "xml.h"
 #include "testutils.h"
-#include "internal.h"
 
 static char *progname;
 static char *abs_top_srcdir;

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]