[PATCH 2/3] syntax-check: Only allows to include public headers in external tools

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

 



With this patch, include public headers in "" form is only allowed
for "internal.h". And only the external tools (examples|tools|python
|include/libvirt) can include the public headers in <> form.
---
 cfg.mk                         | 17 ++++++++++++++---
 include/libvirt/libvirt-lxc.h  |  2 +-
 include/libvirt/libvirt-qemu.h |  2 +-
 python/libvirt-lxc-override.c  |  4 ++--
 python/libvirt-override.c      |  4 ++--
 python/libvirt-qemu-override.c |  4 ++--
 python/typewrappers.h          |  4 ++--
 tests/shunloadhelper.c         |  5 ++---
 tools/virsh.c                  |  4 ++--
 9 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index 5f422de..4128ebb 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -747,12 +747,20 @@ sc_prohibit_duplicate_header:
 	fi;
 
 # Don't include "libvirt/*.h" in "" form.
-sc_prohibit_include_public_headers:
+sc_prohibit_include_public_headers_quote:
 	@prohibit='# *include *"libvirt/.*\.h"'				\
 	in_vc_files='\.[chx]$$'						\
 	halt='Do not include libvirt/*.h in internal source'		\
 	  $(_sc_search_regexp)
 
+# Don't include "libvirt/*.h" in <> form. Except for external tools,
+# e.g. Python binding, examples and tools subdirectories.
+sc_prohibit_include_public_headers_brackets:
+	@prohibit='# *include *<libvirt/.*\.h>'				\
+	in_vc_files='\.[chx]$$'						\
+	halt='Do not include libvirt/*.h in internal source'		\
+	  $(_sc_search_regexp)
+
 # We don't use this feature of maint.mk.
 prev_version_file = /dev/null
 
@@ -907,5 +915,8 @@ exclude_file_name_regexp--sc_correct_id_types = \
 
 exclude_file_name_regexp--sc_m4_quote_check = m4/virt-lib.m4
 
-exclude_file_name_regexp--sc_prohibit_include_public_headers = \
-  ^(src/internal\.h$$|python/|tools/|examples/|include/libvirt/libvirt-(qemu|lxc)\.h$$)
+exclude_file_name_regexp--sc_prohibit_include_public_headers_quote = \
+  ^src/internal\.h$$
+
+exclude_file_name_regexp--sc_prohibit_include_public_headers_brackets = \
+  ^(python/|tools/|examples/|include/libvirt/(virterror|libvirt-(qemu|lxc))\.h$$)
diff --git a/include/libvirt/libvirt-lxc.h b/include/libvirt/libvirt-lxc.h
index 5021813..1901fce 100644
--- a/include/libvirt/libvirt-lxc.h
+++ b/include/libvirt/libvirt-lxc.h
@@ -26,7 +26,7 @@
 #ifndef __VIR_LXC_H__
 # define __VIR_LXC_H__
 
-# include "libvirt/libvirt.h"
+# include <libvirt/libvirt.h>
 
 # ifdef __cplusplus
 extern "C" {
diff --git a/include/libvirt/libvirt-qemu.h b/include/libvirt/libvirt-qemu.h
index 8ec12b4..3e79a8c 100644
--- a/include/libvirt/libvirt-qemu.h
+++ b/include/libvirt/libvirt-qemu.h
@@ -26,7 +26,7 @@
 #ifndef __VIR_QEMU_H__
 # define __VIR_QEMU_H__
 
-# include "libvirt/libvirt.h"
+# include <libvirt/libvirt.h>
 
 # ifdef __cplusplus
 extern "C" {
diff --git a/python/libvirt-lxc-override.c b/python/libvirt-lxc-override.c
index c80668e..ead175f 100644
--- a/python/libvirt-lxc-override.c
+++ b/python/libvirt-lxc-override.c
@@ -17,8 +17,8 @@
 #undef HAVE_PTHREAD_H
 
 #include <Python.h>
-#include "libvirt/libvirt-lxc.h"
-#include "libvirt/virterror.h"
+#include <libvirt/libvirt-lxc.h>
+#include <libvirt/virterror.h>
 #include "typewrappers.h"
 #include "libvirt-lxc.h"
 #include "viralloc.h"
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index f6573e1..3d8490c 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -20,8 +20,8 @@
 #define VIR_ENUM_SENTINELS
 
 #include <Python.h>
-#include "libvirt/libvirt.h"
-#include "libvirt/virterror.h"
+#include <libvirt/libvirt.h>
+#include <libvirt/virterror.h>
 #include "typewrappers.h"
 #include "libvirt.h"
 #include "viralloc.h"
diff --git a/python/libvirt-qemu-override.c b/python/libvirt-qemu-override.c
index 243692a..8f1ce5e 100644
--- a/python/libvirt-qemu-override.c
+++ b/python/libvirt-qemu-override.c
@@ -17,8 +17,8 @@
 #undef HAVE_PTHREAD_H
 
 #include <Python.h>
-#include "libvirt/libvirt-qemu.h"
-#include "libvirt/virterror.h"
+#include <libvirt/libvirt-qemu.h>
+#include <libvirt/virterror.h>
 #include "typewrappers.h"
 #include "libvirt-qemu.h"
 
diff --git a/python/typewrappers.h b/python/typewrappers.h
index af68bce..d871d3f 100644
--- a/python/typewrappers.h
+++ b/python/typewrappers.h
@@ -8,8 +8,8 @@
 
 #include <Python.h>
 #include <stdbool.h>
-#include "libvirt/libvirt.h"
-#include "libvirt/virterror.h"
+#include <libvirt/libvirt.h>
+#include <libvirt/virterror.h>
 
 #ifdef __GNUC__
 # ifdef ATTRIBUTE_UNUSED
diff --git a/tests/shunloadhelper.c b/tests/shunloadhelper.c
index 1b025ee..a8f5aef 100644
--- a/tests/shunloadhelper.c
+++ b/tests/shunloadhelper.c
@@ -26,12 +26,11 @@
  */
 
 #include <config.h>
-#include "internal.h"
 
-#include <libvirt/libvirt.h>
-#include <libvirt/virterror.h>
 #include <stdlib.h>
 
+#include "internal.h"
+
 static void shunloadError(void *userData ATTRIBUTE_UNUSED,
                           virErrorPtr error ATTRIBUTE_UNUSED)
 {
diff --git a/tools/virsh.c b/tools/virsh.c
index b7a5cc1..4cd93ca 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -60,8 +60,8 @@
 #include "virutil.h"
 #include "viralloc.h"
 #include "virxml.h"
-#include "libvirt/libvirt-qemu.h"
-#include "libvirt/libvirt-lxc.h"
+#include <libvirt/libvirt-qemu.h>
+#include <libvirt/libvirt-lxc.h>
 #include "virfile.h"
 #include "configmake.h"
 #include "virthread.h"
-- 
1.8.1.4

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