Re: [PATCH linux-kselftest/test v6] lib/list-test: add a test for the 'list' doubly linked list

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

 



On 30/10/2019 20.15, Joe Perches wrote:
> On Wed, 2019-10-30 at 21:46 +0300, Dan Carpenter wrote:
>> Hm...  I imagined the checkpatch code a little different in my head but
>> this would also work to make it stricter.  I doubt it miss very many
>> real life style problems.
> 
> Well, doubts vs reality...
> 
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
>> @@ -3607,7 +3607,7 @@ sub process {
>>  
>>  # if/while/etc brace do not go on next line, unless defining a do while loop,
>>  # or if that brace on the next line is for something else
>> -		if ($line =~ /(.*)\b((?:if|while|for|switch|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) {
>> +		if ($line =~ /(.*)\b((?:if|while|for|switch|(?:list|hlist)_for_each[a-z_]+)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) {
>>  			my $pre_ctx = "$1$2";
>>  
>>  			my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0);
> 
> So - nak

How about changing the check so it only matches the
if/while/for/*for_each*/ thing when it's the first thing on a line _and_
has non-trivial whitespace in front. Then a function declaration as

static void test_for_each()
{

would not fire, nor would it if it were written in the other common style

static void
test_for_each()
{

?

Maybe there'd still be a problem at the call-sites

  test_for_each();
  this_is_not_indented;

but the ending semi-colon should actually make it appear as a loop with
an empty body (though that in itself might fire a different warning,
dunno if checkpatch has that kind of warnings). But in any case the
above should remove _some_ false positives.

Rasmus



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux