]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
checkpatch: more comprehensive split strings warning
authorJoe Perches <joe@perches.com>
Thu, 23 Jan 2014 23:54:40 +0000 (15:54 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 24 Jan 2014 00:36:57 +0000 (16:36 -0800)
The current checkpatch test for split strings does not find several
cases that should be found.

For instance:

  /* Else poor success; go back to mode in "active" table */
  } else {
  IWL_DEBUG_RATE(mvm,
-        "LQ: GOING BACK TO THE OLD TABLE suc=%d cur-tpt=%d old-tpt=%d\n",
+        "GOING BACK TO THE OLD TABLE: SR %d "
+        "cur-tpt %d old-tpt %d\n",
         window->success_ratio,
         window->average_tpt,
        lq_sta->last_tpt);

does not currently emit a warning.

Improve the test to find these cases.

Add more exceptions to reduce false positives for assembly and octal/hex
string constants.

Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/checkpatch.pl

index 9fb30b15c9dc72b948266a5085b51bd8c3e7bb82..59fa00e97878a5344e451369d1d7df241400b2ad 100755 (executable)
@@ -2049,16 +2049,12 @@ sub process {
                }
 
 # Check for user-visible strings broken across lines, which breaks the ability
-# to grep for the string.  Limited to strings used as parameters (those
-# following an open parenthesis), which almost completely eliminates false
-# positives, as well as warning only once per parameter rather than once per
-# line of the string.  Make an exception when the previous string ends in a
-# newline (multiple lines in one string constant) or \n\t (common in inline
-# assembly to indent the instruction on the following line).
+# to grep for the string.  Make exceptions when the previous string ends in a
+# newline (multiple lines in one string constant) or '\t', '\r', ';', or '{'
+# (common in inline assembly) or is a octal \123 or hexadecimal \xaf value
                if ($line =~ /^\+\s*"/ &&
                    $prevline =~ /"\s*$/ &&
-                   $prevline =~ /\(/ &&
-                   $prevrawline !~ /\\n(?:\\t)*"\s*$/) {
+                   $prevrawline !~ /(?:\\(?:[ntr]|[0-7]{1,3}|x[0-9a-fA-F]{1,2})|;\s*|\{\s*)"\s*$/) {
                        WARN("SPLIT_STRING",
                             "quoted string split across lines\n" . $hereprev);
                }