From: Andrew Morton <akpm@linux-foundation.org>
To: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] checkpatch: Add a --strict test for macro argument reuse
Date: Tue, 6 Nov 2012 12:00:27 -0800 [thread overview]
Message-ID: <20121106120027.94648924.akpm@linux-foundation.org> (raw)
In-Reply-To: <1352198139.16194.21.camel@joe-AO722>
On Tue, 06 Nov 2012 02:35:39 -0800
Joe Perches <joe@perches.com> wrote:
> Add a test for reuse of macro arguments to highlight
> any possible side-effects from this reuse.
>
> Avoid this check on token name pasting and when the
> argument is used in a typeof or a __builtin.
Does this mean that if I do
#define foo(a) bar(a, a)
that checkpatch will not generate a warning unless I give it
"--strict"? If so: whaaah! I want that warning to come out by
default.
Not being totally lazy, I tried it myself but my perl v5.10.1 had
conniptions over this patch:
akpm:/usr/src/25> perl scripts/checkpatch.pl -f a.c
Illegal character in prototype for main::CHECK : "MACRO_ARG_REUSE","Macroargumentreuse'$arg'-possibleside-effects?\n"."$herectx" at scripts/checkpatch.pl line 3039.
syntax error at scripts/checkpatch.pl line 3039, near ""Macro argument reuse '$arg' - possible side-effects?\n" . "$herectx")"
(Might be a runaway multi-line () string starting on line 3038)
syntax error at scripts/checkpatch.pl line 3045, near "} else"
Global symbol "$herecurr" requires explicit package name at scripts/checkpatch.pl line 3049.
syntax error at scripts/checkpatch.pl line 3051, near "}"
Global symbol "$realfile" requires explicit package name at scripts/checkpatch.pl line 3057.
Global symbol "$line" requires explicit package name at scripts/checkpatch.pl line 3058.
Global symbol "$realcnt" requires explicit package name at scripts/checkpatch.pl line 3060.
Global symbol "$realcnt" requires explicit package name at scripts/checkpatch.pl line 3064.
Global symbol "$here" requires explicit package name at scripts/checkpatch.pl line 3075.
syntax error at scripts/checkpatch.pl line 3091, near "}"
scripts/checkpatch.pl has too many errors.
<looks at the patch>
<fixes it>
--- a/scripts/checkpatch.pl~checkpatch-add-a-strict-test-for-macro-argument-reuse-fix
+++ a/scripts/checkpatch.pl
@@ -3035,7 +3035,7 @@ sub process {
$tmp =~ s/\b$arg\s*\#\#//g;
my $use_cnt = $tmp =~ s/\b$arg\b//g;
if ($use_cnt > 1) {
- CHECK("MACRO_ARG_REUSE",
+ ERROR("MACRO_ARG_REUSE",
"Macro argument reuse '$arg' - possible side-effects?\n" . "$herectx");
}
}
_
Ah, good:
akpm:/usr/src/25> perl scripts/checkpatch.pl -f a.c
ERROR: Macro argument reuse 'a' - possible side-effects?
#1: FILE: a.c:1:
+#define foo(a) bar(a, a)
total: 1 errors, 0 warnings, 1 lines checked
a.c has style problems, please review.
If any of these errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
So what's all this stuff about "--strict" in the patch title?
next prev parent reply other threads:[~2012-11-06 20:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-06 10:35 Joe Perches
2012-11-06 20:00 ` Andrew Morton [this message]
2012-11-08 13:25 ` Joe Perches
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=20121106120027.94648924.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®