Skip to contentSkip to conversation

Spurious warning in checkpatch.pl?

PATCH New Larry Finger 2 participants 5 messages Oct 12, 2012 – Oct 14, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Andy,

The checkpatch.pl version in mainline is issuing what I think are false warnings of the type

WARNING: networking block comments put the trailing */ on a separate line #93: FILE: drivers/net/wireless/rtlwifi/wifi.h:208:
+ u32 rf_rb; /* rflssi_readback */

Is a trailing comment for the member of a struct not allowed?

Thanks,

Larry

maintainer
#1 lore raw
Quoted 10 lines · Larry Finger

Andy,

The checkpatch.pl version in mainline is issuing what I think are false warnings of the type

WARNING: networking block comments put the trailing */ on a separate line #93: FILE: drivers/net/wireless/rtlwifi/wifi.h:208:
+ u32 rf_rb; /* rflssi_readback */

Is a trailing comment for the member of a struct not allowed?

It's allowed. Maybe even better, encouraged.

It's a change I made in commit 058806007450 ("checkpatch: check networking specific block comment style") without sufficient testing.

I'll see about fixing it.

#2 lore raw
Quoted 12 lines · Joe Perches
Quoted 10 lines · Larry Finger

Andy,

The checkpatch.pl version in mainline is issuing what I think are false warnings of the type

WARNING: networking block comments put the trailing */ on a separate line #93: FILE: drivers/net/wireless/rtlwifi/wifi.h:208:
+ u32 rf_rb; /* rflssi_readback */

Is a trailing comment for the member of a struct not allowed?

Quoted 7 lines

It's allowed. Maybe even better, encouraged.

It's a change I made in commit 058806007450 ("checkpatch: check networking specific block comment style") without sufficient testing.

I'll see about fixing it.

Joe,

Good. I will ignore those warnings.

One more question. Was the warning below intended?

WARNING: networking block comments put the trailing */ on a separate line #1846: FILE: drivers/net/wireless/rtlwifi/rtl8723ae/hal_btc.h:27:
+ *****************************************************************************/

To me, that line at the end of a copyright block looks better then

****************************************************************************
*/

Larry

maintainer
#3 lore raw
Quoted 11 lines · Larry Finger

One more question. Was the warning below intended?

WARNING: networking block comments put the trailing */ on a separate line #1846: FILE: drivers/net/wireless/rtlwifi/rtl8723ae/hal_btc.h:27:
+ *****************************************************************************/

To me, that line at the end of a copyright block looks better then

****************************************************************************
*/

No, not really. It's a side effect of the nominal block comment style that networking uses.

Maybe it could be improved by ignoring lines that end in "**/" (\*\*\/\s*$) too.

maintainer
#4 lore raw

PATCH 1/1 checkpatch: Improve network block comment style checking

In reply to Larry Finger

Some comment styles in net and drivers/net are flagged inappropriately.

Avoid proclaiming inline comments like:
int a = b; /* some comment */
and block comments like:

	/*********************
	 * some comment
	 ********************/

are defective.

Tested with

$ cat drivers/net/t.c
/* foo */

/*
* foo
*/

/* foo
*/

/* foo
* bar */

/****************************
* some long block comment
***************************/

struct foo {
int bar; /* another test */
};
$

---
 scripts/checkpatch.pl |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +4 -2
index 21a9f5d..f18750e 100755
@@ -1890,8 +1890,10 @@ sub process {
 		}
 
 		if ($realfile =~ m@^(drivers/net/|net/)@ &&
-		    $rawline !~ m@^\+[ \t]*(\/\*|\*\/)@ &&
-		    $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) {
+		    $rawline !~ m@^\+[ \t]*\*/[ \t]*$@ &&	#trailing */
+		    $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ &&	#inline /*...*/
+		    $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ &&	#trailing **/
+		    $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) {	#non blank */
 			WARN("NETWORKING_BLOCK_COMMENT_STYLE",
 			     "networking block comments put the trailing */ on a separate line\n" . $herecurr);
 		}