changeset 17752:89ba0beadf6a

maintainer-makefile: add syntax check for useless ';;' Most instances of ;; in C code are mistakes, where the second semicolon is a no-op. This rule tries to make it easy to flag the typos occuring at the end of a statement. It intentionally does not flag for(;;) loops, and misses grammar problems in comments if the problem occurs in the middle of the line. Shell files (including configure.ac and Makefile.am, which can contain shell snippets) are too likely to use case statements where ;; is legitimate, so those are not scanned. * top/maint.mk (sc_prohibit_double_semicolon): New rule. Signed-off-by: Eric Blake <eblake@redhat.com>
author Eric Blake <eblake@redhat.com>
date Thu, 04 Sep 2014 13:11:04 -0600
parents 9e8d98ca3311
children c91f916e943e
files ChangeLog top/maint.mk
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Sep 04 14:55:12 2014 -0700
+++ b/ChangeLog	Thu Sep 04 13:11:04 2014 -0600
@@ -1,3 +1,8 @@
+2014-09-04  Eric Blake  <eblake@redhat.com>
+
+	maintainer-makefile: add syntax check for useless ';;'
+	* top/maint.mk (sc_prohibit_double_semicolon): New rule.
+
 2014-09-04  Paul Eggert  <eggert@cs.ucla.edu>
 
 	pthread, pthread_sigmask, threadlib: port to Ubuntu 14.04
--- a/top/maint.mk	Thu Sep 04 14:55:12 2014 -0700
+++ b/top/maint.mk	Thu Sep 04 13:11:04 2014 -0600
@@ -996,6 +996,14 @@
 	  | grep -vE '$(ignore_undesirable_word_sequence_RE_)' | grep .	\
 	  && { echo '$(ME): undesirable word sequence' >&2; exit 1; } || :
 
+# Except for shell files and for loops, double semicolon is probably a mistake
+sc_prohibit_double_semicolon:
+	@prohibit='; *;[	{} \]*(/[/*]|$$)'			\
+	in_vc_files='\.[chly]$$'					\
+	exclude='\bfor *\(.*\)'						\
+	halt="Double semicolon detected"				\
+	  $(_sc_search_regexp)
+
 _ptm1 = use "test C1 && test C2", not "test C1 -''a C2"
 _ptm2 = use "test C1 || test C2", not "test C1 -''o C2"
 # Using test's -a and -o operators is not portable.