checkpatch: handle string concatenation in simple #defines
authorAndy Whitcroft <apw@canonical.com>
Fri, 23 Mar 2012 22:02:18 +0000 (15:02 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 23 Mar 2012 23:58:36 +0000 (16:58 -0700)
Adjacent strings indicate concatentation, therefore look at identifiers
directly adjacent to literal strings as strings too.  This allows us to
better detect the form below and accept it as a simple constant:

    #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

Signed-off-by: Andy Whitcroft <apw@canonical.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/checkpatch.pl

index 95ba30a24dcf019ac0632540fdf1abe6e64d8d04..01a65988a057bdc6b3c0d888b9ca8190da2ed20d 100755 (executable)
@@ -2894,6 +2894,12 @@ sub process {
                        {
                        }
 
+                       # Flatten any obvious string concatentation.
+                       while ($dstat =~ s/("X*")\s*$Ident/$1/ ||
+                              $dstat =~ s/$Ident\s*("X*")/$1/)
+                       {
+                       }
+
                        my $exceptions = qr{
                                $Declare|
                                module_param_named|