]> xenbits.xensource.com Git - libvirt.git/commitdiff
Added syntax-check rule for return with parentheses
authorMartin Kletzander <mkletzan@redhat.com>
Fri, 23 Mar 2012 07:34:09 +0000 (08:34 +0100)
committerEric Blake <eblake@redhat.com>
Mon, 26 Mar 2012 20:50:48 +0000 (14:50 -0600)
After cleanup introduced with previous commit, there is a need for
syntax-check rule taking care of return(). Regexp used in 'prohibit'
parameter is taken from the cleanup commit and modified so it fits
'grep -E' format. Semicolon at the end is needed, otherwise the regexp
could match return with cast.

Exception is created for python source files because we don't have any
documentation restricting the use of return that matches this case.

cfg.mk

diff --git a/cfg.mk b/cfg.mk
index 24e6a698454dd57d2dde2b43189d451c628eb7b1..c3de533855334243d1826b03738e5f53cdea0428 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -469,6 +469,12 @@ sc_prohibit_xmlURI:
        halt='use virURI(Parse|Format), not xml(ParseURI|SaveUri)'      \
          $(_sc_search_regexp)
 
+# we don't want old old-style return with parentheses around argument
+sc_prohibit_return_as_function:
+       @prohibit='\<return *\(([^()]*(\([^()]*\)[^()]*)*)\) *;'    \
+       halt='avoid extra () with return statements'                \
+         $(_sc_search_regexp)
+
 # ATTRIBUTE_UNUSED should only be applied in implementations, not
 # header declarations
 sc_avoid_attribute_unused_in_header:
@@ -791,6 +797,8 @@ exclude_file_name_regexp--sc_prohibit_xmlGetProp = ^src/util/xml\.c$$
 
 exclude_file_name_regexp--sc_prohibit_xmlURI = ^src/util/viruri\.c$$
 
+exclude_file_name_regexp--sc_prohibit_return_as_function = \.py$$
+
 exclude_file_name_regexp--sc_require_config_h = ^examples/
 
 exclude_file_name_regexp--sc_require_config_h_first = ^examples/