From 1add9c78da3d8a3ea048b229ab3f0153702ea106 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 31 May 2013 11:52:51 -0600 Subject: [PATCH] maint: don't use config.h in .h files Enforce the rule that .h files don't need to (redundantly) include . * 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 --- 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 4ffa020afb..c093bf2483 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) +# 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 ' \ + $(_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 c07637a294..d0afdc8e50 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 - # include # include # include "remote_protocol.h" diff --git a/src/driver.h b/src/driver.h index e998adf872..ec5fc53771 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 # include "internal.h" diff --git a/src/gnutls_1_0_compat.h b/src/gnutls_1_0_compat.h index 217bc8c43c..b006e2b541 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 - # include /* enable backward compatibility macros for gnutls 1.x.y */ diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h index fed878d898..44ecd4105e 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 - # include # include "internal.h" diff --git a/src/libxl/libxl_driver.h b/src/libxl/libxl_driver.h index cb8921f93d..fba6c5a8ba 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 - int libxlRegister(void); #endif /* LIBXL_DRIVER_H */ diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h index 4332fb9edf..5a5b9aa355 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 - # 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 113d1ceb1f..656831cce8 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 - /* Function declarations */ int lxcRegister(void); diff --git a/src/lxc/lxc_fuse.h b/src/lxc/lxc_fuse.h index a42c39a15b..b3713af81d 100644 --- a/src/lxc/lxc_fuse.h +++ b/src/lxc/lxc_fuse.h @@ -26,7 +26,6 @@ # define FUSE_USE_VERSION 26 -# include # if WITH_FUSE # include # endif diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h index 4bf64eafb1..50258b571f 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 - # 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 59a43704c1..ad05b15daf 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 # include # define LPAR_EXEC_ERR -1 diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 42566b4103..19893c89a5 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 - # include "virebtables.h" # include "internal.h" # include "capabilities.h" diff --git a/src/util/virnetlink.h b/src/util/virnetlink.h index 9a69a0b450..8351000ba0 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" -- 2.39.5