Skip to contentSkip to conversation

possible new false positive in checkpatch

DISCUSSION Tal Shorer 2 participants 6 messages Sep 12, 2015 – Jun 11, 2016

lore
Share & tools
lore

Tal Shorer

author
#0 lore raw

Since my last pull from upstream (today) , I started seeing some checkpatch warnings regarding suspect code indent I believe are false positive. Take this code for example:

static int foo(void)

{
	while (bar())
		/* do nothing */;
}

When running checkpath on it, the following warning is emitted:

tal@tal:~/Dev/lfs/linux|0 $ scripts/checkpatch.pl -f ~/tmp/foo.c
WARNING: suspect code indent for conditional statements (8, 32) #3: FILE: /home/tal/tmp/foo.c:3:
+ while (bar())
+ /* do nothing */;

total: 0 errors, 1 warnings, 5 lines checked

/home/tal/tmp/foo.c has style problems, please review.

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
tal@tal:~/Dev/lfs/linux|1 $

Using my limited perl knowledge, I believe the lines causing this are 3111-3133:

			# remove inline comments
			$s =~ s/$;/ /g;
			$c =~ s/$;/ /g;
Introduced in commit 9f5af480f4554aac12e002b6f5c2b04895857700:
checkpatch: improve SUSPECT_CODE_INDENT test
Commenting out these lines removes the warning.

This pattern exists in many places around the kernel source. Is this the intended behavior?

#1 lore raw
Quoted 26 lines · Tal Shorer

Since my last pull from upstream (today) , I started seeing some checkpatch warnings regarding suspect code indent I believe are false positive. Take this code for example:

static int foo(void)

{
	while (bar())
		/* do nothing */;
}

When running checkpath on it, the following warning is emitted:

tal@tal:~/Dev/lfs/linux|0 $ scripts/checkpatch.pl -f ~/tmp/foo.c
WARNING: suspect code indent for conditional statements (8, 32) #3: FILE: /home/tal/tmp/foo.c:3:

(quoted diff) +2 -0
+	while (bar())
+		/* do nothing */;

total: 0 errors, 1 warnings, 5 lines checked

/home/tal/tmp/foo.c has style problems, please review.

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
tal@tal:~/Dev/lfs/linux|1 $

Quoted 5 lines

Using my limited perl knowledge, I believe the lines causing this are 3111-3133:

			# remove inline comments
			$s =~ s/$;/ /g;
			$c =~ s/$;/ /g;

Yes it feels like that should be eliding them completely, and likely any following space as well, something like this:

	$s =~ s/$;+\s*//g;
	$c =~ s/$;+\s*//g;
Quoted 6 lines

Introduced in commit 9f5af480f4554aac12e002b6f5c2b04895857700:
checkpatch: improve SUSPECT_CODE_INDENT test Commenting out these lines removes the warning.

This pattern exists in many places around the kernel source. Is this the intended behavior?

Seems wrong to me.

-apw

author
#2 lore raw
Quoted 34 lines · Andy Whitcroft
Quoted 26 lines · Tal Shorer

Since my last pull from upstream (today) , I started seeing some checkpatch warnings regarding suspect code indent I believe are false positive. Take this code for example:

static int foo(void)

{
      while (bar())
              /* do nothing */;
}

When running checkpath on it, the following warning is emitted:

tal@tal:~/Dev/lfs/linux|0 $ scripts/checkpatch.pl -f ~/tmp/foo.c
WARNING: suspect code indent for conditional statements (8, 32) #3: FILE: /home/tal/tmp/foo.c:3:

(quoted diff) +2 -0
+     while (bar())
+             /* do nothing */;

total: 0 errors, 1 warnings, 5 lines checked

/home/tal/tmp/foo.c has style problems, please review.

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
tal@tal:~/Dev/lfs/linux|1 $

Quoted 5 lines

Using my limited perl knowledge, I believe the lines causing this are 3111-3133:

                      # remove inline comments
                      $s =~ s/$;/ /g;
                      $c =~ s/$;/ /g;
Quoted 6 lines

Yes it feels like that should be eliding them completely, and likely any following space as well, something like this:

        $s =~ s/$;+\s*//g;
        $c =~ s/$;+\s*//g;

Replacing the problematic lines with these fixes the issue.

Quoted 10 lines
Quoted 6 lines

Introduced in commit 9f5af480f4554aac12e002b6f5c2b04895857700:
checkpatch: improve SUSPECT_CODE_INDENT test Commenting out these lines removes the warning.

This pattern exists in many places around the kernel source. Is this the intended behavior?

Seems wrong to me.

-apw

Which git tree is checkpatch developed in? Linus's?

#3 lore raw
Quoted 11 lines · Tal Shorer
Quoted 6 lines

Yes it feels like that should be eliding them completely, and likely any following space as well, something like this:

        $s =~ s/$;+\s*//g;
        $c =~ s/$;+\s*//g;

Replacing the problematic lines with these fixes the issue.

Quoted 4 lines
Quoted 4 lines

Introduced in commit 9f5af480f4554aac12e002b6f5c2b04895857700:
checkpatch: improve SUSPECT_CODE_INDENT test Commenting out these lines removes the warning.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

This pattern exists in many places around the kernel source. Is this the intended behavior?

Seems wrong to me.

-apw

Which git tree is checkpatch developed in? Linus's?

Yeah in Linus' tree.

-apw

author
#4 lore raw

ping?
Is there a plan to fix it? should I send your fix? (kinda plagiarism) next release? (which would mean the unnecessary warnings will exist in 4.3 :<)

Quoted 25 lines · Andy Whitcroft
Quoted 11 lines · Tal Shorer
Quoted 6 lines

Yes it feels like that should be eliding them completely, and likely any following space as well, something like this:

        $s =~ s/$;+\s*//g;
        $c =~ s/$;+\s*//g;

Replacing the problematic lines with these fixes the issue.

Quoted 4 lines
Quoted 4 lines

Introduced in commit 9f5af480f4554aac12e002b6f5c2b04895857700:
checkpatch: improve SUSPECT_CODE_INDENT test Commenting out these lines removes the warning.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

This pattern exists in many places around the kernel source. Is this the intended behavior?

Seems wrong to me.

-apw

Which git tree is checkpatch developed in? Linus's?

Yeah in Linus' tree.

-apw

author
#5 lore raw
In reply to Andy Whitcroft
Quoted 18 lines · Andy Whitcroft
Quoted 16 lines · Tal Shorer
Quoted 6 lines

Yes it feels like that should be eliding them completely, and likely any following space as well, something like this:

        $s =~ s/$;+\s*//g;
        $c =~ s/$;+\s*//g;

Replacing the problematic lines with these fixes the issue.

Quoted 9 lines
Quoted 6 lines

Introduced in commit 9f5af480f4554aac12e002b6f5c2b04895857700:
checkpatch: improve SUSPECT_CODE_INDENT test Commenting out these lines removes the warning.

This pattern exists in many places around the kernel source. Is this the intended behavior?

Seems wrong to me.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

-apw

Which git tree is checkpatch developed in? Linus's?

Yeah in Linus' tree.

-apw

This still isn't fixed. Should I submit Andy's change myself? Feels like plagiarize.