[Spice-devel] [PATCH spice-server 05/10] syntax-check: Check ENABLE_EXTRA_CHECKS is not used incorrectly

Frediano Ziglio fziglio at redhat.com
Mon Sep 11 10:15:42 UTC 2017


Usually configuration macros are defined to 0 or undefined.
For this reason these macros are sometimes checked using #if
and sometimes with #ifndef/#ifdef.
As this macro is always defined with 0 or 1 it makes no sense
to check if defined or not so check the code to avoid this
mistake.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 cfg.mk | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/cfg.mk b/cfg.mk
index 93d7040c5..6bd3c55b3 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -111,6 +111,14 @@ sc_copyright_format:
 	halt='spell Red Hat as two words'				\
 	  $(_sc_search_regexp)
 
+# ENABLE_EXTRA_CHECKS is always defined, do not allow
+# "#ifndef ENABLE_EXTRA_CHECKS"
+sc_extra_checks:
+	@prohibit='#[[:space:]]*ifn?def[[:space:]]+ENABLE_EXTRA_CHECKS'	\
+	in_vc_files='\.[ch]$$'						\
+	halt='ENABLE_EXTRA_CHECKS is always defined'			\
+	  $(_sc_search_regexp)
+
 # We don't use this feature of maint.mk.
 prev_version_file = /dev/null
 
-- 
2.13.5



More information about the Spice-devel mailing list