diff mbox series

[v2,1/5] checkpatch: Support wide strings

Message ID 20210718201426.759240-2-sjg@chromium.org
State Superseded
Delegated to: Tom Rini
Headers show
Series Fix compiler warnings for 32-bit ARM | expand

Commit Message

Simon Glass July 18, 2021, 8:14 p.m. UTC
From: Joe Perches <joe@perches.com>

Allow prefixing typical strings with L for wide strings and u for
unicode strings.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
---
This was found on LKML:

https://lore.kernel.org/lkml/1508280192.6530.31.camel@perches.com/T/

It likely wasn't applied because it did not show up in patchwork
correctly, due to the patch being inline:

https://lore.kernel.org/patchwork/patch/842121/

In any case, it needed rebasing and updating to support 'u'.

Heinrich, perhaps you can send this upstream since you have the context?

Changes in v2:
- Add new patch to reduce checkpatch unicode-string spam

 scripts/checkpatch.pl | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Tom Rini Aug. 1, 2021, 3:28 a.m. UTC | #1
On Sun, Jul 18, 2021 at 02:14:22PM -0600, Simon Glass wrote:

> From: Joe Perches <joe@perches.com>
> 
> Allow prefixing typical strings with L for wide strings and u for
> unicode strings.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> This was found on LKML:
> 
> https://lore.kernel.org/lkml/1508280192.6530.31.camel@perches.com/T/
> 
> It likely wasn't applied because it did not show up in patchwork
> correctly, due to the patch being inline:
> 
> https://lore.kernel.org/patchwork/patch/842121/
> 
> In any case, it needed rebasing and updating to support 'u'.
> 
> Heinrich, perhaps you can send this upstream since you have the context?
> 
> Changes in v2:
> - Add new patch to reduce checkpatch unicode-string spam
> 
>  scripts/checkpatch.pl | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

I'm very much against having checkpatch.pl changes that aren't inside of
the u_boot area.  We're currently at I believe just 1 (outside of adding
--u-boot flag) and I'm testing a resync to v5.13 now that just adds one
more for good reason and is also obvious enough to not get lost.  This
however will get lost in a future resync so needs to be brought up with
upstream.
Simon Glass Aug. 2, 2021, 7:20 p.m. UTC | #2
Hi Tom,

On Sat, 31 Jul 2021 at 21:28, Tom Rini <trini@konsulko.com> wrote:
>
> On Sun, Jul 18, 2021 at 02:14:22PM -0600, Simon Glass wrote:
>
> > From: Joe Perches <joe@perches.com>
> >
> > Allow prefixing typical strings with L for wide strings and u for
> > unicode strings.
> >
> > Signed-off-by: Joe Perches <joe@perches.com>
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> > This was found on LKML:
> >
> > https://lore.kernel.org/lkml/1508280192.6530.31.camel@perches.com/T/
> >
> > It likely wasn't applied because it did not show up in patchwork
> > correctly, due to the patch being inline:
> >
> > https://lore.kernel.org/patchwork/patch/842121/
> >
> > In any case, it needed rebasing and updating to support 'u'.
> >
> > Heinrich, perhaps you can send this upstream since you have the context?
> >
> > Changes in v2:
> > - Add new patch to reduce checkpatch unicode-string spam
> >
> >  scripts/checkpatch.pl | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
>
> I'm very much against having checkpatch.pl changes that aren't inside of
> the u_boot area.  We're currently at I believe just 1 (outside of adding
> --u-boot flag) and I'm testing a resync to v5.13 now that just adds one
> more for good reason and is also obvious enough to not get lost.  This
> however will get lost in a future resync so needs to be brought up with
> upstream.

I sent it upstream and Joe seems happy with it this time.

https://lore.kernel.org/patchwork/patch/1470668/

Regards,
Simon
Tom Rini Aug. 2, 2021, 9:30 p.m. UTC | #3
On Mon, Aug 02, 2021 at 01:20:21PM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On Sat, 31 Jul 2021 at 21:28, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Sun, Jul 18, 2021 at 02:14:22PM -0600, Simon Glass wrote:
> >
> > > From: Joe Perches <joe@perches.com>
> > >
> > > Allow prefixing typical strings with L for wide strings and u for
> > > unicode strings.
> > >
> > > Signed-off-by: Joe Perches <joe@perches.com>
> > > Signed-off-by: Simon Glass <sjg@chromium.org>
> > > ---
> > > This was found on LKML:
> > >
> > > https://lore.kernel.org/lkml/1508280192.6530.31.camel@perches.com/T/
> > >
> > > It likely wasn't applied because it did not show up in patchwork
> > > correctly, due to the patch being inline:
> > >
> > > https://lore.kernel.org/patchwork/patch/842121/
> > >
> > > In any case, it needed rebasing and updating to support 'u'.
> > >
> > > Heinrich, perhaps you can send this upstream since you have the context?
> > >
> > > Changes in v2:
> > > - Add new patch to reduce checkpatch unicode-string spam
> > >
> > >  scripts/checkpatch.pl | 7 ++++---
> > >  1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > I'm very much against having checkpatch.pl changes that aren't inside of
> > the u_boot area.  We're currently at I believe just 1 (outside of adding
> > --u-boot flag) and I'm testing a resync to v5.13 now that just adds one
> > more for good reason and is also obvious enough to not get lost.  This
> > however will get lost in a future resync so needs to be brought up with
> > upstream.
> 
> I sent it upstream and Joe seems happy with it this time.
> 
> https://lore.kernel.org/patchwork/patch/1470668/

Thanks!
diff mbox series

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 08a827535aa..b244682c7c9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -411,7 +411,7 @@  our $Binary	= qr{(?i)0b[01]+$Int_type?};
 our $Hex	= qr{(?i)0x[0-9a-f]+$Int_type?};
 our $Int	= qr{[0-9]+$Int_type?};
 our $Octal	= qr{0[0-7]+$Int_type?};
-our $String	= qr{"[X\t]*"};
+our $String	= qr{(?:\b[Lu])?"[X\t]*"};
 our $Float_hex	= qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
 our $Float_dec	= qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
 our $Float_int	= qr{(?i)[0-9]+e-?[0-9]+[fl]?};
@@ -5673,7 +5673,8 @@  sub process {
 		}
 
 # concatenated string without spaces between elements
-		if ($line =~ /$String[A-Za-z0-9_]/ || $line =~ /[A-Za-z0-9_]$String/) {
+		if ($line =~ /$String[A-Z_]/ ||
+		    ($line =~ /([A-Za-z0-9_]+)$String/ && $1 !~ /^[Lu]$/)) {
 			if (CHK("CONCATENATED_STRING",
 				"Concatenated strings should use spaces between elements\n" . $herecurr) &&
 			    $fix) {
@@ -5686,7 +5687,7 @@  sub process {
 		}
 
 # uncoalesced string fragments
-		if ($line =~ /$String\s*"/) {
+		if ($line =~ /$String\s*[Lu]?"/) {
 			if (WARN("STRING_FRAGMENTS",
 				 "Consecutive strings are generally better as a single string\n" . $herecurr) &&
 			    $fix) {