Re: [RFC/PATCH] Update coding standard to avoid ungrepable printkformat strings
From: Christer Weinigel
Date:  Sat Feb 23 2008 - 07:55:44 EST
Andi Kleen wrote:
RFC: Update coding standard to avoid split up printk format strings
While we're talking about checkpatch.pl, I'd definitely like to teach 
checkpatch about "list_for_each" and friends.
list_for_each is flow control, not a function call.  I find it much 
easier to see that something is a loop when there is a space between the 
name and the parenthesis rather than when they are smashed together.
old patch follows
  /Christer
checkpatch complains about the following:
WARNING: no space between function name and open parenthesis '('
#520: FILE: drivers/spi/spi_s3c24xx_dma.c:478:
+       list_for_each_entry (transfer, &message->transfers, transfer_list) {
which I think is a bit bogus since it actually is a for statement in
disguise.  The following patch adds list_for_each to the list of things
that look like functions that it shouldn't complain about.
Index: linux-2.6.23/scripts/checkpatch.pl
===================================================================
--- linux-2.6.23.orig/scripts/checkpatch.pl
+++ linux-2.6.23/scripts/checkpatch.pl
@@ -681,7 +681,7 @@ sub process {
 # check for spaces between functions and their parentheses.
 		if ($line =~ /($Ident)\s+\(/ &&
-		    $1 !~ 
/^(?:if|for|while|switch|return|volatile|__volatile__|__attribute__|format|__extension__|Copyright)$/ 
&&
+		    $1 !~ 
/^(?:if|for|while|switch|list_for_each.*|return|volatile|__volatile__|__attribute__|format|__extension__|Copyright)$/ 
&&
 		    $line !~ /$Type\s+\(/ && $line !~ /^.\#\s*define\b/) {
 			WARN("no space between function name and open parenthesis '('\n" . 
$herecurr);
 		}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/