Commit 9ef2684c033d325b08133e96e8744b4da9b69a58

Authored by Heinrich Schuchardt
Committed by Tom Rini
1 parent 2d5e6b4aac

checkpatch: Support wide strings

Allow prefixing typical strings with L for wide strings

Patch originally by Joe Perches
https://lkml.org/lkml/2017/10/17/1117

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Showing 1 changed file with 4 additions and 3 deletions Side-by-side Diff

scripts/checkpatch.pl
... ... @@ -392,7 +392,7 @@
392 392 our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?};
393 393 our $Int = qr{[0-9]+$Int_type?};
394 394 our $Octal = qr{0[0-7]+$Int_type?};
395   -our $String = qr{"[X\t]*"};
  395 +our $String = qr{(?:\bL)?"[X\t]*"};
396 396 our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
397 397 our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
398 398 our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
399 399  
... ... @@ -5254,13 +5254,14 @@
5254 5254 }
5255 5255  
5256 5256 # concatenated string without spaces between elements
5257   - if ($line =~ /$String[A-Z_]/ || $line =~ /[A-Za-z0-9_]$String/) {
  5257 + if ($line =~ /$String[A-Z_]/ ||
  5258 + ($line =~ /([A-Za-z0-9_]+)$String/ && $1 !~ /^L$/)) {
5258 5259 CHK("CONCATENATED_STRING",
5259 5260 "Concatenated strings should use spaces between elements\n" . $herecurr);
5260 5261 }
5261 5262  
5262 5263 # uncoalesced string fragments
5263   - if ($line =~ /$String\s*"/) {
  5264 + if ($line =~ /$String\s*L?"/) {
5264 5265 WARN("STRING_FRAGMENTS",
5265 5266 "Consecutive strings are generally better as a single string\n" . $herecurr);
5266 5267 }