Enforce the rule that .h files don't need to (redundantly)
include <config.h>.
* cfg.mk (sc_prohibit_config_h_in_headers): New rule.
(_virsh_includes): Delete; instead, inline a smaller number of
exclusions...
(exclude_file_name_regexp--sc_require_config_h)
(exclude_file_name_regexp--sc_require_config_h_first): ...here.
* daemon/libvirtd.h (includes): Fix offenders.
* src/driver.h (includes): Likewise.
* src/gnutls_1_0_compat.h (includes): Likewise.
* src/libxl/libxl_conf.h (includes): Likewise.
* src/libxl/libxl_driver.h (includes): Likewise.
* src/lxc/lxc_conf.h (includes): Likewise.
* src/lxc/lxc_driver.h (includes): Likewise.
* src/lxc/lxc_fuse.h (includes): Likewise.
* src/network/bridge_driver.h (includes): Likewise.
* src/phyp/phyp_driver.h (includes): Likewise.
* src/qemu/qemu_conf.h (includes): Likewise.
* src/util/virnetlink.h (includes): Likewise.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Not a build-breaker, and not trivial enough to push without
review; but it should have no impact on the resulting binary
so it is safe for 1.0.6 if I get a review in time.
cfg.mk | 16 +++++++++++++---
daemon/libvirtd.h | 4 +---
src/driver.h | 2 --
src/gnutls_1_0_compat.h | 4 +---
src/libxl/libxl_conf.h | 2 --
src/libxl/libxl_driver.h | 2 --
src/lxc/lxc_conf.h | 4 +---
src/lxc/lxc_driver.h | 2 --
src/lxc/lxc_fuse.h | 1 -
src/network/bridge_driver.h | 4 +---
src/phyp/phyp_driver.h | 3 +--
src/qemu/qemu_conf.h | 2 --
src/util/virnetlink.h | 3 +--
13 files changed, 19 insertions(+), 30 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 4ffa020..c093bf2 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -797,6 +797,15 @@ sc_prohibit_include_public_headers_brackets:
halt='Do not include libvirt/*.h in internal source' \
$(_sc_search_regexp)
+# <config.h> is only needed in .c files; .h files do not need it since
+# .c files must include config.h before any other .h.
+sc_prohibit_config_h_in_headers:
+ @prohibit='^# *include\>.*config\.h' \
+ in_vc_files='\.h$$' \
+ halt='headers should not include <config.h>' \
+ $(_sc_search_regexp)
+
+
# We don't use this feature of maint.mk.
prev_version_file = /dev/null
@@ -937,10 +946,11 @@ exclude_file_name_regexp--sc_prohibit_xmlURI =
^src/util/viruri\.c$$
exclude_file_name_regexp--sc_prohibit_return_as_function = \.py$$
-_virsh_includes=(edit|domain-monitor|domain|volume|pool|network|interface|nwfilter|secret|snapshot|host|nodedev)
-exclude_file_name_regexp--sc_require_config_h =
^(examples/|tools/virsh-$(_virsh_includes)\.c$$)
+exclude_file_name_regexp--sc_require_config_h = \
+ ^(examples/|tools/virsh-edit\.c$$)
-exclude_file_name_regexp--sc_require_config_h_first =
^(examples/|tools/virsh-$(_virsh_includes)\.c$$)
+exclude_file_name_regexp--sc_require_config_h_first = \
+ ^(examples/|tools/virsh-edit\.c$$)
exclude_file_name_regexp--sc_trailing_blank = \
(/qemuhelpdata/|/sysinfodata/.*\.data|\.(fig|gif|ico|png)$$)
diff --git a/daemon/libvirtd.h b/daemon/libvirtd.h
index c07637a..d0afdc8 100644
--- a/daemon/libvirtd.h
+++ b/daemon/libvirtd.h
@@ -1,7 +1,7 @@
/*
* libvirtd.h: daemon data structure definitions
*
- * Copyright (C) 2006-2012 Red Hat, Inc.
+ * Copyright (C) 2006-2013 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -27,8 +27,6 @@
# define VIR_ENUM_SENTINELS
-# include <config.h>
-
# include <rpc/types.h>
# include <rpc/xdr.h>
# include "remote_protocol.h"
diff --git a/src/driver.h b/src/driver.h
index e998adf..ec5fc53 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -22,8 +22,6 @@
#ifndef __VIR_DRIVER_H__
# define __VIR_DRIVER_H__
-# include "config.h"
-
# include <unistd.h>
# include "internal.h"
diff --git a/src/gnutls_1_0_compat.h b/src/gnutls_1_0_compat.h
index 217bc8c..b006e2b 100644
--- a/src/gnutls_1_0_compat.h
+++ b/src/gnutls_1_0_compat.h
@@ -1,7 +1,7 @@
/*
* gnutls_1_0_compat.h: GnuTLS 1.0 compatibility
*
- * Copyright (C) 2007 Red Hat, Inc.
+ * Copyright (C) 2007, 2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -23,8 +23,6 @@
#ifndef LIBVIRT_GNUTLS_1_0_COMPAT_H__
# define LIBVIRT_GNUTLS_1_0_COMPAT_H__
-# include <config.h>
-
# include <gnutls/gnutls.h>
/* enable backward compatibility macros for gnutls 1.x.y */
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index fed878d..44ecd41 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -25,8 +25,6 @@
#ifndef LIBXL_CONF_H
# define LIBXL_CONF_H
-# include <config.h>
-
# include <libxl.h>
# include "internal.h"
diff --git a/src/libxl/libxl_driver.h b/src/libxl/libxl_driver.h
index cb8921f..fba6c5a 100644
--- a/src/libxl/libxl_driver.h
+++ b/src/libxl/libxl_driver.h
@@ -23,8 +23,6 @@
#ifndef LIBXL_DRIVER_H
# define LIBXL_DRIVER_H
-# include <config.h>
-
int libxlRegister(void);
#endif /* LIBXL_DRIVER_H */
diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h
index 4332fb9..5a5b9aa 100644
--- a/src/lxc/lxc_conf.h
+++ b/src/lxc/lxc_conf.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Red Hat, Inc.
+ * Copyright (C) 2010, 2013 Red Hat, Inc.
* Copyright IBM Corp. 2008
*
* lxc_conf.h: header file for linux container config functions
@@ -25,8 +25,6 @@
#ifndef LXC_CONF_H
# define LXC_CONF_H
-# include <config.h>
-
# include "internal.h"
# include "domain_conf.h"
# include "domain_event.h"
diff --git a/src/lxc/lxc_driver.h b/src/lxc/lxc_driver.h
index 113d1ce..656831c 100644
--- a/src/lxc/lxc_driver.h
+++ b/src/lxc/lxc_driver.h
@@ -24,8 +24,6 @@
#ifndef LXC_DRIVER_H
# define LXC_DRIVER_H
-# include <config.h>
-
/* Function declarations */
int lxcRegister(void);
diff --git a/src/lxc/lxc_fuse.h b/src/lxc/lxc_fuse.h
index a42c39a..b3713af 100644
--- a/src/lxc/lxc_fuse.h
+++ b/src/lxc/lxc_fuse.h
@@ -26,7 +26,6 @@
# define FUSE_USE_VERSION 26
-# include <config.h>
# if WITH_FUSE
# include <fuse.h>
# endif
diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h
index 4bf64ea..50258b5 100644
--- a/src/network/bridge_driver.h
+++ b/src/network/bridge_driver.h
@@ -1,7 +1,7 @@
/*
* network_driver.h: core driver methods for managing networks
*
- * Copyright (C) 2006-2012 Red Hat, Inc.
+ * Copyright (C) 2006-2013 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -25,8 +25,6 @@
#ifndef __VIR_NETWORK__DRIVER_H
# define __VIR_NETWORK__DRIVER_H
-# include <config.h>
-
# include "internal.h"
# include "network_conf.h"
# include "domain_conf.h"
diff --git a/src/phyp/phyp_driver.h b/src/phyp/phyp_driver.h
index 59a4370..ad05b15 100644
--- a/src/phyp/phyp_driver.h
+++ b/src/phyp/phyp_driver.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Red Hat, Inc.
+ * Copyright (C) 2010, 2013 Red Hat, Inc.
* Copyright IBM Corp. 2009
*
* phyp_driver.c: ssh layer to access Power Hypervisors
@@ -27,7 +27,6 @@
# include "conf/capabilities.h"
# include "conf/domain_conf.h"
-# include <config.h>
# include <libssh2.h>
# define LPAR_EXEC_ERR -1
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 42566b4..19893c8 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -24,8 +24,6 @@
#ifndef __QEMUD_CONF_H
# define __QEMUD_CONF_H
-# include <config.h>
-
# include "virebtables.h"
# include "internal.h"
# include "capabilities.h"
diff --git a/src/util/virnetlink.h b/src/util/virnetlink.h
index 9a69a0b..8351000 100644
--- a/src/util/virnetlink.h
+++ b/src/util/virnetlink.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2012 Red Hat, Inc.
+ * Copyright (C) 2010-2013 Red Hat, Inc.
* Copyright (C) 2010-2012 IBM Corporation
*
* This library is free software; you can redistribute it and/or
@@ -20,7 +20,6 @@
#ifndef __VIR_NETLINK_H__
# define __VIR_NETLINK_H__
-# include "config.h"
# include "internal.h"
# include "virmacaddr.h"
--
1.8.1.4