Re: [ovs-dev] [PATCH] checkpatch: Enforce bracing around conditionals.

2017-08-17 Thread Joe Stringer
On 17 August 2017 at 07:35, Aaron Conole  wrote:
> Hi Joe,
>
> Joe Stringer  writes:
>
>> The coding style states that BSD-style brace placement should be used,
>> and even single statements should be enclosed. Add checks to checkpatch
>> for this.
>>
>> Signed-off-by: Joe Stringer 
>> ---
>>  utilities/checkpatch.py | 13 +
>>  1 file changed, 13 insertions(+)
>>
>> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
>> index 43f10bb3ded3..c8381c98403b 100755
>> --- a/utilities/checkpatch.py
>> +++ b/utilities/checkpatch.py
>> @@ -95,6 +95,8 @@ __regex_ends_with_bracket = \
>>  __regex_ptr_declaration_missing_whitespace = 
>> re.compile(r'[a-zA-Z0-9]\*[^*]')
>>  __regex_is_comment_line = re.compile(r'^\s*(/\*|\*\s)')
>>  __regex_trailing_operator = re.compile(r'^[^ ]* [^ ]*[?:]$')
>> +__regex_conditional_else_bracing = re.compile(r'^\s*else\s*{?$')
>> +__regex_conditional_else_bracing2 = re.compile(r'^\s*}\selse\s*$')
>>
>>  skip_leading_whitespace_check = False
>>  skip_trailing_whitespace_check = False
>> @@ -212,6 +214,12 @@ def trailing_operator(line):
>>  return __regex_trailing_operator.match(line) is not None
>>
>>
>> +def if_else_bracing_check(line):
>> +if __regex_conditional_else_bracing.match(line) is not None:
>> +return True
>> +return __regex_conditional_else_bracing2.match(line) is not None
>> +
>> +
>
> Would it make more sense to put this in with the other bracing checks in
> if_and_for_end_with_bracket_check ?

Yes! Apparently I missed this before. Thanks, I'll respin.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH] checkpatch: Enforce bracing around conditionals.

2017-08-17 Thread Aaron Conole
Hi Joe,

Joe Stringer  writes:

> The coding style states that BSD-style brace placement should be used,
> and even single statements should be enclosed. Add checks to checkpatch
> for this.
>
> Signed-off-by: Joe Stringer 
> ---
>  utilities/checkpatch.py | 13 +
>  1 file changed, 13 insertions(+)
>
> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
> index 43f10bb3ded3..c8381c98403b 100755
> --- a/utilities/checkpatch.py
> +++ b/utilities/checkpatch.py
> @@ -95,6 +95,8 @@ __regex_ends_with_bracket = \
>  __regex_ptr_declaration_missing_whitespace = re.compile(r'[a-zA-Z0-9]\*[^*]')
>  __regex_is_comment_line = re.compile(r'^\s*(/\*|\*\s)')
>  __regex_trailing_operator = re.compile(r'^[^ ]* [^ ]*[?:]$')
> +__regex_conditional_else_bracing = re.compile(r'^\s*else\s*{?$')
> +__regex_conditional_else_bracing2 = re.compile(r'^\s*}\selse\s*$')
>  
>  skip_leading_whitespace_check = False
>  skip_trailing_whitespace_check = False
> @@ -212,6 +214,12 @@ def trailing_operator(line):
>  return __regex_trailing_operator.match(line) is not None
>  
>  
> +def if_else_bracing_check(line):
> +if __regex_conditional_else_bracing.match(line) is not None:
> +return True
> +return __regex_conditional_else_bracing2.match(line) is not None
> +
> +

Would it make more sense to put this in with the other bracing checks in
if_and_for_end_with_bracket_check ?

>  checks = [
>  {'regex': None,
>   'match_name':
> @@ -250,6 +258,11 @@ checks = [
>   'check': lambda x: trailing_operator(x),
>   'print':
>   lambda: print_error("Line has '?' or ':' operator at end of line")},
> +
> +{'regex': '(.c|.h)(.in)?$', 'match_name': None,
> + 'prereq': lambda x: not is_comment_line(x),
> + 'check': lambda x: if_else_bracing_check(x),
> + 'print': lambda: print_error("Improper bracing in conditional 
> statement")}
>  ]
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] checkpatch: Enforce bracing around conditionals.

2017-08-16 Thread Joe Stringer
The coding style states that BSD-style brace placement should be used,
and even single statements should be enclosed. Add checks to checkpatch
for this.

Signed-off-by: Joe Stringer 
---
 utilities/checkpatch.py | 13 +
 1 file changed, 13 insertions(+)

diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index 43f10bb3ded3..c8381c98403b 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -95,6 +95,8 @@ __regex_ends_with_bracket = \
 __regex_ptr_declaration_missing_whitespace = re.compile(r'[a-zA-Z0-9]\*[^*]')
 __regex_is_comment_line = re.compile(r'^\s*(/\*|\*\s)')
 __regex_trailing_operator = re.compile(r'^[^ ]* [^ ]*[?:]$')
+__regex_conditional_else_bracing = re.compile(r'^\s*else\s*{?$')
+__regex_conditional_else_bracing2 = re.compile(r'^\s*}\selse\s*$')
 
 skip_leading_whitespace_check = False
 skip_trailing_whitespace_check = False
@@ -212,6 +214,12 @@ def trailing_operator(line):
 return __regex_trailing_operator.match(line) is not None
 
 
+def if_else_bracing_check(line):
+if __regex_conditional_else_bracing.match(line) is not None:
+return True
+return __regex_conditional_else_bracing2.match(line) is not None
+
+
 checks = [
 {'regex': None,
  'match_name':
@@ -250,6 +258,11 @@ checks = [
  'check': lambda x: trailing_operator(x),
  'print':
  lambda: print_error("Line has '?' or ':' operator at end of line")},
+
+{'regex': '(.c|.h)(.in)?$', 'match_name': None,
+ 'prereq': lambda x: not is_comment_line(x),
+ 'check': lambda x: if_else_bracing_check(x),
+ 'print': lambda: print_error("Improper bracing in conditional statement")}
 ]
 
 
-- 
2.14.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev