[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 32/32] Prevent use of 'int' data type & 'ii', 'jj', 'kk' var names for loops



On 07/08/2013 04:21 PM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange redhat com>
> 
> Add two syntax-check rules
> 
>  - sc_prohibit_int_ijk - block use of 'int' as a data type
>    for any variables named 'i', 'j', 'k'
>  - sc_prohibit_int_iijjkk - block use of 'ii', 'jj', 'kk'
>    for any variable names
> ---
>  cfg.mk | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/cfg.mk b/cfg.mk
> index bbe84b3..2285f08 100644
> --- a/cfg.mk
> +++ b/cfg.mk
> @@ -545,6 +545,17 @@ sc_avoid_attribute_unused_in_header:
>  	halt='use ATTRIBUTE_UNUSED in .c rather than .h files'		\
>  	  $(_sc_search_regexp)
>  
> +sc_prohibit_int_ijk:
> +	@prohibit='\<int ([^=\(]+ )*(i|j|k)(\s|,|;)'			\
> +	halt='use size_t, not int/unsigned int for loop vars i, j, k'	\
> +	  $(_sc_search_regexp)
> +

This misses some variables after the '=' sign:
int n = 0, i;

> +sc_prohibit_loop_iijjkk:
> +	@prohibit='\<int ([^=]+ )*(ii|jj|kk)(\s|,|;)'				\
> +	halt='use i, j, k for loop iterators, not ii, jj, kk' 			\
> +	  $(_sc_search_regexp)
> +
> +
>  # Many of the function names below came from this filter:
>  # git grep -B2 '\<_('|grep -E '\.c- *[[:alpha:]_][[:alnum:]_]* ?\(.*[,;]$' \
>  # |sed 's/.*\.c-  *//'|perl -pe 's/ ?\(.*//'|sort -u \
> @@ -971,3 +982,6 @@ exclude_file_name_regexp--sc_prohibit_include_public_headers_quote = \
>  
>  exclude_file_name_regexp--sc_prohibit_include_public_headers_brackets = \
>    ^(python/|tools/|examples/|include/libvirt/(virterror|libvirt-(qemu|lxc))\.h$$)
> +
> +exclude_file_name_regexp--sc_prohibit_int_ijk = \
> +  ^(src/remote_protocol-structs|src/remote/remote_protocol.x|cfg.mk|include/)$
> 

ACK

Jan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]