lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 22 Dec 2013 17:02:55 -0800
From:	Joe Perches <joe@...ches.com>
To:	David Miller <davem@...emloft.net>,
	Andrew Morton <akpm@...ux-foundation.org>
Cc:	ogerlitz@...lanox.com, netdev@...r.kernel.org, amirv@...lanox.com,
	yanb@...lanox.com, ast@...mgrid.com,
	Andy Whitcroft <apw@...dowen.org>
Subject: [PATCH] checkpatch: Add warning with unnecessary parentheses in if
 statements

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@...ches.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;


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ