[libvirt] [PATCH 05/10] syntax-check: Don't include duplicate header

Osier Yang jyang at redhat.com
Tue Apr 16 13:41:47 UTC 2013


Except gnulib...
---
 cfg.mk | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/cfg.mk b/cfg.mk
index e60c4e3..71f7ee4 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -722,6 +722,28 @@ sc_prohibit_exit_in_tests:
 	halt='use return, not exit(), in tests'				\
 	  $(_sc_search_regexp)
 
+# Don't include duplicate header in the source (either *.c or *.h)
+sc_prohibit_duplicate_header:
+	@for i in $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); do		\
+	  awk 'BEGIN {							\
+	    FS=" ";							\
+	    fail=0;							\
+	  }								\
+	  /^# *include.*\.h[">]$$/ {					\
+	    arr[$$NF]++;						\
+	  }								\
+	  END {								\
+	    for (key in arr) {						\
+	      if (arr[key] > 1) {					\
+		fail=1;							\
+		printf("%d %s are included\n", arr[key], key);		\
+	      }								\
+	    }								\
+	    if (fail == 1)						\
+	      exit 1;							\
+	  }' $$i || { echo "Duplicate header(s) in $$i"; exit 1; };	\
+	done
+
 # We don't use this feature of maint.mk.
 prev_version_file = /dev/null
 
-- 
1.8.1.4




More information about the libvir-list mailing list