syntax-check: Only allows to include public headers in external tools

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.
This commit is contained in:
Osier Yang 2013-04-17 18:19:19 +08:00
parent 1d69c6334b
commit 9969ade669
9 changed files with 29 additions and 19 deletions

19
cfg.mk
View File

@ -747,9 +747,17 @@ 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]$$' \
in_vc_files='\.[ch]$$' \
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='\.[ch]$$' \
halt='Do not include libvirt/*.h in internal source' \
$(_sc_search_regexp)
@ -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$$)

View File

@ -26,7 +26,7 @@
#ifndef __VIR_LXC_H__
# define __VIR_LXC_H__
# include "libvirt/libvirt.h"
# include <libvirt/libvirt.h>
# ifdef __cplusplus
extern "C" {

View File

@ -26,7 +26,7 @@
#ifndef __VIR_QEMU_H__
# define __VIR_QEMU_H__
# include "libvirt/libvirt.h"
# include <libvirt/libvirt.h>
# ifdef __cplusplus
extern "C" {

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

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

View File

@ -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)
{

View File

@ -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"