Skip to content

Commit d2af5aa

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: support wide strings
Allow prefixing typical strings with L for wide strings and u for unicode strings. Link: https://lkml.kernel.org/r/20210801170733.1.I3f9784fd3c1007d08ec2e70b151d137687575495@changeid Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Simon Glass <sjg@chromium.org> Cc: Dwaipayan Ray <dwaipayanray1@gmail.com> Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7fc5b57 commit d2af5aa

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎scripts/checkpatch.pl‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ sub hash_show_words {
501501
our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?};
502502
our $Int = qr{[0-9]+$Int_type?};
503503
our $Octal = qr{0[0-7]+$Int_type?};
504-
our $String = qr{"[X\t]*"};
504+
our $String = qr{(?:\b[Lu])?"[X\t]*"};
505505
our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
506506
our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
507507
our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
@@ -6132,7 +6132,8 @@ sub process {
61326132
}
61336133

61346134
# concatenated string without spaces between elements
6135-
if ($line =~ /$String[A-Za-z0-9_]/ || $line =~ /[A-Za-z0-9_]$String/) {
6135+
if ($line =~ /$String[A-Z_]/ ||
6136+
($line =~ /([A-Za-z0-9_]+)$String/ && $1 !~ /^[Lu]$/)) {
61366137
if (CHK("CONCATENATED_STRING",
61376138
"Concatenated strings should use spaces between elements\n" . $herecurr) &&
61386139
$fix) {
@@ -6145,7 +6146,7 @@ sub process {
61456146
}
61466147

61476148
# uncoalesced string fragments
6148-
if ($line =~ /$String\s*"/) {
6149+
if ($line =~ /$String\s*[Lu]?"/) {
61496150
if (WARN("STRING_FRAGMENTS",
61506151
"Consecutive strings are generally better as a single string\n" . $herecurr) &&
61516152
$fix) {

0 commit comments

Comments
 (0)