From: Joe Perches <joe@perches.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Valentin Vidic" <Valentin.Vidic@CARNet.hr>,
"David Miller" <davem@davemloft.net>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
"Marcin Ciupak" <marcin.s.ciupak@gmail.com>,
"Marcus Wolf" <linux@wolf-entwicklungen.de>,
"Simon Sandström" <simon@nikanor.nu>
Subject: Re: [PATCH] staging: pi433: remove unnecessary parentheses
Date: Tue, 09 Jan 2018 11:42:16 -0800 [thread overview]
Message-ID: <1515526936.9619.121.camel@perches.com> (raw)
In-Reply-To: <20180109192844.GB20280@kroah.com>
On Tue, 2018-01-09 at 20:28 +0100, Greg Kroah-Hartman wrote:
> On Tue, Jan 09, 2018 at 11:21:37AM -0800, Joe Perches wrote:
> > On Tue, 2018-01-09 at 15:31 +0100, Greg Kroah-Hartman wrote:
> > > On Mon, Jan 08, 2018 at 06:38:55PM +0100, Valentin Vidic wrote:
> > > > Fixes checkpatch warnings:
> > > > CHECK: Unnecessary parentheses around 'mantisse != mantisse16'
> > > > CHECK: Unnecessary parentheses around 'mantisse != mantisse20'
> > > > CHECK: Unnecessary parentheses around 'mantisse != mantisse24'
> >
> > []
> > > > diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
> >
> > []
> > > > @@ -391,9 +391,9 @@ static int rf69_set_bandwidth_intern(struct spi_device *spi, u8 reg,
> > > > return -EINVAL;
> > > > }
> > > >
> > > > - if ((mantisse != mantisse16) &&
> > > > - (mantisse != mantisse20) &&
> > > > - (mantisse != mantisse24)) {
> > > > + if (mantisse != mantisse16 &&
> > > > + mantisse != mantisse20 &&
> > > > + mantisse != mantisse24) {
> > >
> > > I'm getting really tired of seeing this checkpatch warning, when it's a
> > > major pain.
> >
> > Your idea of major pain and mine differ a bit.
>
> I don't like taking patches that cause future problems.
What future problems might this particular case present
that isn't generic in all patches.
> > > Joe, can you please turn these off. Patches like this will force people
> > > to have to remember that != is higher precidence than &&.
> >
> > As it's not just 1 precedence level but 4 and 5, it
> > really shouldn't be that hard to remember.
>
> I can't remember any of them, and I should not have to.
That depends on how well you know your C.
> That's the
> point, you should not assume anyone knows the levels, code is written
> for developers to understand first, and the compiler second.
And someone that knows C knows those levels and the parentheses
can just be visual noise requiring extra thought.
Sometimes it's useful, sometimes it's not.
if (a == b && c == d)
is pretty trivial.
and I believe
if ((a == b))
emits clang warnings
> By
> removing these, it doesn't do anything for the compiler, but makes the
> developer think longer about them.
Generally I have to think more with more parentheses.
> > > The original code here was just fine.
> >
> > And I don't really disagree with you.
> >
> > David Miller has a preference for the parenthesis free
> > style. I believe he mentioned it sometime in August 2017
> > but I can't find it right now.
> >
> > Anyway, perhaps
> > ---
> > scripts/checkpatch.pl | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index d2464058ab5d..3a7499de2c2d 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -4526,7 +4526,9 @@ sub process {
> > }
> >
> > # check for unnecessary parentheses around comparisons in if uses
> > - if ($^V && $^V ge 5.10.0 && defined($stat) &&
> > +# when !drivers/staging or the command-line uses --strict
> > + if (($realfile !~ m@^(?:drivers/staging/)@ || $check_orig) &&
> > + $^V && $^V ge 5.10.0 && defined($stat) &&
>
> How about only if in the networking area? I don't want to take patches
> for this for other parts of the kernel either, it's really useless.
AFAIK: Almost no one thinks when sending staging patches.
For other parts of the tree, it requires --strict on the
command line. AFAIK: almost no one uses that and if they
do, then they can determine for themselves if they want
to remove excessive parentheses.
next prev parent reply other threads:[~2018-01-09 19:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-08 17:38 [PATCH] staging: pi433: remove unnecessary parentheses Valentin Vidic
2018-01-09 14:31 ` Greg Kroah-Hartman
2018-01-09 19:21 ` Joe Perches
2018-01-09 19:28 ` Greg Kroah-Hartman
2018-01-09 19:42 ` Joe Perches [this message]
2018-01-10 8:44 ` Greg Kroah-Hartman
2018-01-10 9:05 ` Joe Perches
2018-01-10 9:49 ` marcus.wolf
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=1515526936.9619.121.camel@perches.com \
--to=joe@perches.com \
--cc=Valentin.Vidic@CARNet.hr \
--cc=davem@davemloft.net \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@wolf-entwicklungen.de \
--cc=marcin.s.ciupak@gmail.com \
--cc=simon@nikanor.nu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.