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

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

 



On 07/10/2013 05:12 AM, Daniel P. Berrange wrote:
> On Wed, Jul 10, 2013 at 10:38:27AM +0200, Ján Tomko wrote:
>> On 07/08/2013 04:21 PM, Daniel P. Berrange wrote:
>>> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
>>>
>>> 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;
> Yep, I notice that now. Seems I was slightly too clever. The following
> simpler rule catches them
>
>   @prohibit='\<int [^(]* (i|j|k)(\s|,|;)'

Or you could solve it this way:

  "Laine, I know you're fond of "ii", but it annoys the rest of us.
Please stop." :-)

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]