From: Dwaipayan Ray <dwaipayanray1@gmail.com>
To: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [Linux-kernel-mentees] checkpatch.pl investigation: MULTISTATEMENT_MACRO_USE_DO_WHILE issues
Date: Mon, 28 Sep 2020 22:41:58 +0530 [thread overview]
Message-ID: <CABJPP5DCnie+iLeeu0hVgvaVsOPk2fX9K59hLdhKO+SzoCJOQQ@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.21.2009281805030.4154@felia>
On Mon, Sep 28, 2020 at 9:44 PM Lukas Bulwahn <lukas.bulwahn@gmail.com> wrote:
>
>
>
> On Mon, 28 Sep 2020, Dwaipayan Ray wrote:
>
> > Hi,
> > Checkpatch seems to generate some false positives on
> > certain macros.
> >
> > For example running checkpatch on (kernel/trace/trace_export.c),
> >
> > ERROR: Macros with multiple statements should be enclosed in a do - while loop
> > #49: FILE: kernel/trace/trace_export.c:49:
> > +#define __field_packed(type, container, item) type item;
> >
> > ERROR: Macros with multiple statements should be enclosed in a do - while loop
> > #52: FILE: kernel/trace/trace_export.c:52:
> > +#define __array(type, item, size) type item[size];
> >
>
> I guess checkpatch.pl detects the semicolon and thinks it must be two
> statements. How about checking if the semicolon is actually followed by
> anything or not?
>
> > and several other same errors.
> >
>
> Are they all in one file or spread around in the kernel everywhere?
>
Yes, there were all in the same file. I have to run checkpatch on other
files extensively before I can confirm these issues exist elsewhere.
But yes, checking for a semicolon followed by some characters
does solve the problem, and changes the warning to a (Macros
with complex values...).
I do agree that such complex checks should be left to clang-format or
likewise.
Not sure if it is worthwhile merging, but here goes the diff:
---
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 9e65d21456f1..8382977e95fd 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5351,7 +5367,7 @@ sub process {
if ($dstat =~ /^\s*if\b/) {
ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE",
"Macros starting with if
should be enclosed by a do - while loop to avoid possible if/else
logic defects\n" . "$herectx");
- } elsif ($dstat =~ /;/) {
+ } elsif ($dstat =~ /;.+/) {
ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE",
"Macros with multiple
statements should be enclosed in a do - while loop\n" . "$herectx");
} else {
---
Thanks,
Dwaipayan.
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
next prev parent reply other threads:[~2020-09-28 17:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-28 15:47 [Linux-kernel-mentees] checkpatch.pl investigation: MULTISTATEMENT_MACRO_USE_DO_WHILE issues Dwaipayan Ray
2020-09-28 16:14 ` Lukas Bulwahn
2020-09-28 17:11 ` Dwaipayan Ray [this message]
2020-09-29 7:58 ` Lukas Bulwahn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABJPP5DCnie+iLeeu0hVgvaVsOPk2fX9K59hLdhKO+SzoCJOQQ@mail.gmail.com \
--to=dwaipayanray1@gmail.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=lukas.bulwahn@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).