From: Joe Perches <joe@perches.com>
To: David Miller <davem@davemloft.net>,
Andrew Morton <akpm@linux-foundation.org>
Cc: ogerlitz@mellanox.com, netdev@vger.kernel.org,
amirv@mellanox.com, yanb@mellanox.com, ast@plumgrid.com,
Andy Whitcroft <apw@shadowen.org>
Subject: [PATCH] checkpatch: Add warning with unnecessary parentheses in if statements
Date: Sun, 22 Dec 2013 17:02:55 -0800 [thread overview]
Message-ID: <1387760575.22671.36.camel@joe-AO722> (raw)
In-Reply-To: <20131222.191400.620087948725635345.davem@davemloft.net>
Using doubled parentheses in statements like "if ((foo == bar))"
is unnecessary or may be a sign of an intended single assignment
instead of a comparison.
Bleat a warning message on those uses.
Signed-off-by: Joe Perches <joe@perches.com>
---
> > On Sun, 2013-12-22 at 18:12 -0500, David Miller wrote:
> >> > + if ((mdev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)) {
> >> > + if ((mdev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)) {
> >> > + if ((mdev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)) {
> >> > + (mdev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)) {
> >> > + if ((mdev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)) {
> >>
> >> Way too many parenthesis, this isn't LISP :-)
> >
> > Is patchwork stuttering?
>
> I edited it, I'm quoting all of the lines in your patch that add the
> "too many parenthsis" problem.
OK then. Or's patch, not mine, but maybe this is useful...
(this also happened today with another nominal cleanup patch)
scripts/checkpatch.pl | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8f3aecd..29af02a 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3251,6 +3251,13 @@ sub process {
}
}
+# if statements using unnecessary parentheses - ie: if ((foo == bar))
+ if ($^V && $^V ge 5.10.0 &&
+ $line =~ /\bif\s*\(\s*\(\s*$LvalOrFunc\s*$Compare\s*$LvalOrFunc\s*\)\s*\)/) {
+ WARN("UNNECESSARY_PARENTHESES",
+ "Unnecessary parentheses\n" . $herecurr);
+ }
+
# Return of what appears to be an errno should normally be -'ve
if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) {
my $name = $1;
next prev parent reply other threads:[~2013-12-23 1:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-22 15:26 [PATCH net-next V2 0/2] net/mlx4: Add support for TCP/IP offloads of vxlan tunneling Or Gerlitz
2013-12-22 15:26 ` [PATCH net-next V2 1/2] net/mlx4_core: Add basic support for TCP/IP offloads under tunneling Or Gerlitz
2013-12-22 15:26 ` [PATCH net-next V2 2/2] net/mlx4_en: Add netdev support for TCP/IP offloads of vxlan tunneling Or Gerlitz
2013-12-22 23:12 ` David Miller
2013-12-22 23:32 ` Joe Perches
2013-12-23 0:14 ` David Miller
2013-12-23 1:02 ` Joe Perches [this message]
2013-12-23 10:54 ` Or Gerlitz
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=1387760575.22671.36.camel@joe-AO722 \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=amirv@mellanox.com \
--cc=apw@shadowen.org \
--cc=ast@plumgrid.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=yanb@mellanox.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).