lkml.org 
[lkml]   [2018]   [Apr]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH v4 4/9] vsprintf: Consolidate handling of unknown pointer specifiers
From
Date
On Sat, 2018-04-07 at 09:33 +0900, Sergey Senozhatsky wrote:
> Hi Joe,
>
> On (04/06/18 16:59), Joe Perches wrote:
> > >
> > > Can we tweak checkpatch to catch such things?
> >
> > Not really, no.
> >
> > Adding regex logic for this is tricky at best
> > and probably not worth the effort because of
> > the various bits of patch contexts aren't
> > necessarily visible.
>
> Agreed. I was more thinking about catching "... %p" and saying
> that we'd rather prefer either "... %p," or "... %p " or "... %p\n".
> Doesn't sound so complex, can probably catch something fishy one day
> (or may be not), and more or less is visible to checkpatch. Well,
> more or less...

This finds the current two bad uses in addition to
the existing similar message for string concatenation
without a space char between concatenated fragments.

For example:

WARNING: break quoted strings at a space character
#3550: FILE: drivers/scsi/megaraid/megaraid_sas_base.c:3550:
+ dev_notice(&instance->pdev->dev, "moving cmd[%d]:%p:%d:%p"
+ "on the defer queue as internal\n",

WARNING: vsprintf %p<extension> string concatenation
#3550: FILE: drivers/scsi/megaraid/megaraid_sas_base.c:3550:
+ dev_notice(&instance->pdev->dev, "moving cmd[%d]:%p:%d:%p"
+ "on the defer queue as internal\n",

I think the new message is not that useful really as the
existing warning is probably enough.

---
scripts/checkpatch.pl | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index eb534d48140e..a0e43232431e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5313,6 +5313,12 @@ sub process {
"break quoted strings at a space character\n" . $hereprev);
}

+# check for vsprintf pointer extension concatenation
+ if ($prevrawline =~ /\%p"\s*$/ && $rawline =~ /^\+\s*"\w/) {
+ WARN('POINTER_CONCATENATION',
+ "vsprintf %p<extension> string concatenation\n" . $hereprev);
+ }
+
# check for an embedded function name in a string when the function is known
# This does not work very well for -f --file checking as it depends on patch
# context providing the function name or a single line form for in-file
\
 
 \ /
  Last update: 2018-04-07 03:01    [W:0.066 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site