From: Joe Perches <joe@perches.com>
To: Prakruthi Deepak Heragu <pheragu@codeaurora.org>, apw@canonical.com
Cc: linux-kernel@vger.kernel.org, ckadabi@codeaurora.org,
tsoni@codeaurora.org, bryanh@codeaurora.org,
Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Subject: Re: [PATCH v1] checkpatch: check for #if 0/#if 1
Date: Wed, 25 Jul 2018 18:27:00 -0700 [thread overview]
Message-ID: <2a56b48632fe8982735769b52aafe721b29b1bcf.camel@perches.com> (raw)
In-Reply-To: <1532560446-15827-1-git-send-email-pheragu@codeaurora.org>
On Wed, 2018-07-25 at 16:14 -0700, Prakruthi Deepak Heragu wrote:
> The #if 0 or #if 1 is used to toggle features. Warn if #if 0 or #if 1
> is present and suggest that they can be removed.
>
> Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
> Signed-off-by: Prakruthi Deepak Heragu <pheragu@codeaurora.org>
> ---
> Changes in v1:
> - Rephrase the warning message to fit in a single line without
> 80 column limit
>
> scripts/checkpatch.pl | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 3394ed8..72513c2 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5383,9 +5383,14 @@ sub process {
>
> # warn about #if 0
> if ($line =~ /^.\s*\#\s*if\s+0\b/) {
> - CHK("REDUNDANT_CODE",
> - "if this code is redundant consider removing it\n" .
> - $herecurr);
> + WARN("IF_0",
> + "Consider removing the #if 0 and its #endif\n". $herecurr);
No, this wording is not correct at all.
The entire block, i.e.: 'this code' should be considered
to be removed, not just the #if 0 and its #endif.
For #if 1 code, then just the #if 1 and the #endif should
be removed.
> + }
> +
> +# warn about #if 1
> + if ($line =~ /^.\s*\#\s*if\s+1\b/) {
> + WARN("IF_1",
> + "Consider removing the #if 1 and its #endif\n". $herecurr);
> }
>
> # check for needless "if (<foo>) fn(<foo>)" uses
prev parent reply other threads:[~2018-07-26 1:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-25 23:14 Prakruthi Deepak Heragu
2018-07-26 1:27 ` Joe Perches [this message]
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=2a56b48632fe8982735769b52aafe721b29b1bcf.camel@perches.com \
--to=joe@perches.com \
--cc=adharmap@codeaurora.org \
--cc=apw@canonical.com \
--cc=bryanh@codeaurora.org \
--cc=ckadabi@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pheragu@codeaurora.org \
--cc=tsoni@codeaurora.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®