]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Require K&R styled curly braces around function bodies
authorMartin Kletzander <mkletzan@redhat.com>
Fri, 20 Sep 2013 15:56:38 +0000 (17:56 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 20 Mar 2014 16:27:17 +0000 (17:27 +0100)
Although not explicitly requested, we are using K&R (or Kernel)
indentation for curly braces around functions in HACKING file and most
of the code.  Using grep -P, this patch add the syntax-check rule for
it (while skipping all the false positives with foreach constructs).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
cfg.mk

diff --git a/cfg.mk b/cfg.mk
index 7a65d1eac273d283f5bac4b5c5a342174b715e9f..559f719c9274ef2f7d6e69f5d8d68ad0393f0fae 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -898,6 +898,13 @@ sc_prohibit_virConnectOpen_in_virsh:
        halt='Use vshConnect() in virsh instead of virConnectOpen*'    \
          $(_sc_search_regexp)
 
+sc_curly_braces_style:
+       @files=$$($(VC_LIST_EXCEPT) | grep '\.[ch]$$');                \
+       $(GREP) -nHP                                                   \
+'^\s*(?!([a-zA-Z_]*for_?each[a-zA-Z_]*) ?\()([_a-zA-Z0-9]+( [_a-zA-Z0-9]+)* ?\()?(\*?[_a-zA-Z0-9]+(,? \*?[_a-zA-Z0-9\[\]]+)+|void)\) ?\{' \
+       $$files && { echo '$(ME): Non-K&R style used for curly'        \
+                         'braces around function body, see'           \
+                         'HACKING' 1>&2; exit 1; } || :
 
 # We don't use this feature of maint.mk.
 prev_version_file = /dev/null