All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
@ 2018-03-28 17:57 Varsha Rao
  2018-03-28 18:11   ` [Cocci] " Joe Perches
  0 siblings, 1 reply; 17+ messages in thread
From: Varsha Rao @ 2018-03-28 17:57 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, linux-crypto, linux-kernel; +Cc: Varsha Rao

This patch fixes the clang warning of extraneous parentheses, with the
following coccinelle script.

@@
identifier i;
constant c;
@@
(
-((i == c))
+i == c
|
-((i <= c))
+i <= c
)

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
---
 drivers/crypto/cavium/zip/zip_regs.h | 42 ++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/crypto/cavium/zip/zip_regs.h b/drivers/crypto/cavium/zip/zip_regs.h
index d0be682305c1..874e0236c87e 100644
--- a/drivers/crypto/cavium/zip/zip_regs.h
+++ b/drivers/crypto/cavium/zip/zip_regs.h
@@ -443,7 +443,7 @@ union zip_corex_bist_status {
 
 static inline u64 ZIP_COREX_BIST_STATUS(u64 param1)
 {
-	if (((param1 <= 1)))
+	if (param1 <= 1)
 		return 0x0520ull + (param1 & 1) * 0x8ull;
 	pr_err("ZIP_COREX_BIST_STATUS: %llu\n", param1);
 	return 0;
@@ -537,7 +537,7 @@ union zip_dbg_corex_inst {
 
 static inline u64 ZIP_DBG_COREX_INST(u64 param1)
 {
-	if (((param1 <= 1)))
+	if (param1 <= 1)
 		return 0x0640ull + (param1 & 1) * 0x8ull;
 	pr_err("ZIP_DBG_COREX_INST: %llu\n", param1);
 	return 0;
@@ -568,7 +568,7 @@ union zip_dbg_corex_sta {
 
 static inline u64 ZIP_DBG_COREX_STA(u64 param1)
 {
-	if (((param1 <= 1)))
+	if (param1 <= 1)
 		return 0x0680ull + (param1 & 1) * 0x8ull;
 	pr_err("ZIP_DBG_COREX_STA: %llu\n", param1);
 	return 0;
@@ -599,7 +599,7 @@ union zip_dbg_quex_sta {
 
 static inline u64 ZIP_DBG_QUEX_STA(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x1800ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_DBG_QUEX_STA: %llu\n", param1);
 	return 0;
@@ -817,7 +817,7 @@ union zip_msix_pbax {
 
 static inline u64 ZIP_MSIX_PBAX(u64 param1)
 {
-	if (((param1 == 0)))
+	if (param1 == 0)
 		return 0x0000838000FF0000ull;
 	pr_err("ZIP_MSIX_PBAX: %llu\n", param1);
 	return 0;
@@ -846,7 +846,7 @@ union zip_msix_vecx_addr {
 
 static inline u64 ZIP_MSIX_VECX_ADDR(u64 param1)
 {
-	if (((param1 <= 17)))
+	if (param1 <= 17)
 		return 0x0000838000F00000ull + (param1 & 31) * 0x10ull;
 	pr_err("ZIP_MSIX_VECX_ADDR: %llu\n", param1);
 	return 0;
@@ -875,7 +875,7 @@ union zip_msix_vecx_ctl {
 
 static inline u64 ZIP_MSIX_VECX_CTL(u64 param1)
 {
-	if (((param1 <= 17)))
+	if (param1 <= 17)
 		return 0x0000838000F00008ull + (param1 & 31) * 0x10ull;
 	pr_err("ZIP_MSIX_VECX_CTL: %llu\n", param1);
 	return 0;
@@ -900,7 +900,7 @@ union zip_quex_done {
 
 static inline u64 ZIP_QUEX_DONE(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x2000ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_DONE: %llu\n", param1);
 	return 0;
@@ -925,7 +925,7 @@ union zip_quex_done_ack {
 
 static inline u64 ZIP_QUEX_DONE_ACK(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x2200ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_DONE_ACK: %llu\n", param1);
 	return 0;
@@ -950,7 +950,7 @@ union zip_quex_done_ena_w1c {
 
 static inline u64 ZIP_QUEX_DONE_ENA_W1C(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x2600ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_DONE_ENA_W1C: %llu\n", param1);
 	return 0;
@@ -975,7 +975,7 @@ union zip_quex_done_ena_w1s {
 
 static inline u64 ZIP_QUEX_DONE_ENA_W1S(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x2400ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_DONE_ENA_W1S: %llu\n", param1);
 	return 0;
@@ -1004,7 +1004,7 @@ union zip_quex_done_wait {
 
 static inline u64 ZIP_QUEX_DONE_WAIT(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x2800ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_DONE_WAIT: %llu\n", param1);
 	return 0;
@@ -1029,7 +1029,7 @@ union zip_quex_doorbell {
 
 static inline u64 ZIP_QUEX_DOORBELL(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x4000ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_DOORBELL: %llu\n", param1);
 	return 0;
@@ -1058,7 +1058,7 @@ union zip_quex_err_ena_w1c {
 
 static inline u64 ZIP_QUEX_ERR_ENA_W1C(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x3600ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_ERR_ENA_W1C: %llu\n", param1);
 	return 0;
@@ -1087,7 +1087,7 @@ union zip_quex_err_ena_w1s {
 
 static inline u64 ZIP_QUEX_ERR_ENA_W1S(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x3400ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_ERR_ENA_W1S: %llu\n", param1);
 	return 0;
@@ -1120,7 +1120,7 @@ union zip_quex_err_int {
 
 static inline u64 ZIP_QUEX_ERR_INT(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x3000ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_ERR_INT: %llu\n", param1);
 	return 0;
@@ -1150,7 +1150,7 @@ union zip_quex_err_int_w1s {
 
 static inline u64 ZIP_QUEX_ERR_INT_W1S(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x3200ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_ERR_INT_W1S: %llu\n", param1);
 	return 0;
@@ -1179,7 +1179,7 @@ union zip_quex_gcfg {
 
 static inline u64 ZIP_QUEX_GCFG(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x1A00ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_GCFG: %llu\n", param1);
 	return 0;
@@ -1204,7 +1204,7 @@ union zip_quex_map {
 
 static inline u64 ZIP_QUEX_MAP(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x1400ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_MAP: %llu\n", param1);
 	return 0;
@@ -1236,7 +1236,7 @@ union zip_quex_sbuf_addr {
 
 static inline u64 ZIP_QUEX_SBUF_ADDR(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x1000ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_SBUF_ADDR: %llu\n", param1);
 	return 0;
@@ -1276,7 +1276,7 @@ union zip_quex_sbuf_ctl {
 
 static inline u64 ZIP_QUEX_SBUF_CTL(u64 param1)
 {
-	if (((param1 <= 7)))
+	if (param1 <= 7)
 		return 0x1200ull + (param1 & 7) * 0x8ull;
 	pr_err("ZIP_QUEX_SBUF_CTL: %llu\n", param1);
 	return 0;
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
  2018-03-28 17:57 [PATCH] crypto: cavium: zip: Remove unnecessary parentheses Varsha Rao
@ 2018-03-28 18:11   ` Joe Perches
  0 siblings, 0 replies; 17+ messages in thread
From: Joe Perches @ 2018-03-28 18:11 UTC (permalink / raw)
  To: Varsha Rao, Herbert Xu, David S. Miller, linux-crypto, linux-kernel; +Cc: cocci

On Wed, 2018-03-28 at 23:27 +0530, Varsha Rao wrote:
> This patch fixes the clang warning of extraneous parentheses, with the
> following coccinelle script.
> 
> @@
> identifier i;
> constant c;
> @@
> (
> -((i == c))
> +i == c
> > 
> 
> -((i <= c))
> +i <= c

Why just the "==" and "<=" cases?
Why not "<", ">" and ">=" too?

Why not expression instead of constant?

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
@ 2018-03-28 18:11   ` Joe Perches
  0 siblings, 0 replies; 17+ messages in thread
From: Joe Perches @ 2018-03-28 18:11 UTC (permalink / raw)
  To: cocci

On Wed, 2018-03-28 at 23:27 +0530, Varsha Rao wrote:
> This patch fixes the clang warning of extraneous parentheses, with the
> following coccinelle script.
> 
> @@
> identifier i;
> constant c;
> @@
> (
> -((i == c))
> +i == c
> > 
> 
> -((i <= c))
> +i <= c

Why just the "==" and "<=" cases?
Why not "<", ">" and ">=" too?

Why not expression instead of constant?

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
  2018-03-28 18:11   ` [Cocci] " Joe Perches
@ 2018-03-29 15:33     ` Varsha Rao
  -1 siblings, 0 replies; 17+ messages in thread
From: Varsha Rao @ 2018-03-29 15:33 UTC (permalink / raw)
  To: Joe Perches
  Cc: Herbert Xu, David S. Miller, linux-crypto, linux-kernel, cocci

On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
>
> On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> > This patch fixes the clang warning of extraneous parentheses, with the
> > following coccinelle script.
> >
> > @@
> > identifier i;
> > constant c;
> > @@
> > (
> > -((i == c))
> > +i == c
> > >
> >
> > -((i <= c))
> > +i <= c
>
> Why just the "==" and "<=" cases?
> Why not "<", ">" and ">=" too?
>
> Why not expression instead of constant?

Initially I had the other cases too and used expression instead of
constant. But the results included only "==" and "<=" cases with
constant. Along with one false positive case.

--- a/drivers/crypto/cavium/zip/zip_main.c
+++ b/drivers/crypto/cavium/zip/zip_main.c
@@ -99,7 +99,7 @@ static struct zip_device *zip_alloc_devi
  */
 struct zip_device *zip_get_device(int node)
 {
-    if ((node < MAX_ZIP_DEVICES) && (node >= 0))
+    if (node < MAX_ZIP_DEVICES && node >= 0)
         return zip_dev[node];

     zip_err("ZIP device not found for node id %d\n", node);

I checked if there was any case of extra parentheses around relational
operators left, but there were none. Hence, in the script I included
only the cases present in the result.

Thanks,
Varsha

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
@ 2018-03-29 15:33     ` Varsha Rao
  0 siblings, 0 replies; 17+ messages in thread
From: Varsha Rao @ 2018-03-29 15:33 UTC (permalink / raw)
  To: cocci

On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
>
> On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> > This patch fixes the clang warning of extraneous parentheses, with the
> > following coccinelle script.
> >
> > @@
> > identifier i;
> > constant c;
> > @@
> > (
> > -((i == c))
> > +i == c
> > >
> >
> > -((i <= c))
> > +i <= c
>
> Why just the "==" and "<=" cases?
> Why not "<", ">" and ">=" too?
>
> Why not expression instead of constant?

Initially I had the other cases too and used expression instead of
constant. But the results included only "==" and "<=" cases with
constant. Along with one false positive case.

--- a/drivers/crypto/cavium/zip/zip_main.c
+++ b/drivers/crypto/cavium/zip/zip_main.c
@@ -99,7 +99,7 @@ static struct zip_device *zip_alloc_devi
  */
 struct zip_device *zip_get_device(int node)
 {
-    if ((node < MAX_ZIP_DEVICES) && (node >= 0))
+    if (node < MAX_ZIP_DEVICES && node >= 0)
         return zip_dev[node];

     zip_err("ZIP device not found for node id %d\n", node);

I checked if there was any case of extra parentheses around relational
operators left, but there were none. Hence, in the script I included
only the cases present in the result.

Thanks,
Varsha

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
  2018-03-29 15:33     ` [Cocci] " Varsha Rao
@ 2018-03-30 20:17       ` Joe Perches
  -1 siblings, 0 replies; 17+ messages in thread
From: Joe Perches @ 2018-03-30 20:17 UTC (permalink / raw)
  To: Varsha Rao; +Cc: Herbert Xu, David S. Miller, linux-crypto, linux-kernel, cocci

On Thu, 2018-03-29 at 21:03 +0530, Varsha Rao wrote:
> On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> > 
> > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> > > This patch fixes the clang warning of extraneous parentheses, with the
> > > following coccinelle script.
> > > 
> > > @@
> > > identifier i;
> > > constant c;
> > > @@
> > > (
> > > -((i == c))
> > > +i == c
> > > > 
> > > 
> > > -((i <= c))
> > > +i <= c
> > 
> > Why just the "==" and "<=" cases?
> > Why not "<", ">" and ">=" too?
> > 
> > Why not expression instead of constant?
> 
> Initially I had the other cases too and used expression instead of
> constant. But the results included only "==" and "<=" cases with
> constant. Along with one false positive case.
hmm
Perhaps you should use something like this?
@@
identifier i;
constant c;
@@

-(
\(i == c\|i <= c\|i < c\|i >= c\|i > c\)
-)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
@ 2018-03-30 20:17       ` Joe Perches
  0 siblings, 0 replies; 17+ messages in thread
From: Joe Perches @ 2018-03-30 20:17 UTC (permalink / raw)
  To: cocci

On Thu, 2018-03-29 at 21:03 +0530, Varsha Rao wrote:
> On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> > 
> > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> > > This patch fixes the clang warning of extraneous parentheses, with the
> > > following coccinelle script.
> > > 
> > > @@
> > > identifier i;
> > > constant c;
> > > @@
> > > (
> > > -((i == c))
> > > +i == c
> > > > 
> > > 
> > > -((i <= c))
> > > +i <= c
> > 
> > Why just the "==" and "<=" cases?
> > Why not "<", ">" and ">=" too?
> > 
> > Why not expression instead of constant?
> 
> Initially I had the other cases too and used expression instead of
> constant. But the results included only "==" and "<=" cases with
> constant. Along with one false positive case.
hmm
Perhaps you should use something like this?
@@
identifier i;
constant c;
@@

-(
\(i == c\|i <= c\|i < c\|i >= c\|i > c\)
-)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
  2018-03-30 20:17       ` [Cocci] " Joe Perches
  (?)
@ 2018-03-31  6:17         ` Julia Lawall
  -1 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2018-03-31  6:17 UTC (permalink / raw)
  To: Joe Perches
  Cc: Herbert Xu, Varsha Rao, linux-kernel, cocci, linux-crypto,
	David S. Miller



On Fri, 30 Mar 2018, Joe Perches wrote:

> On Thu, 2018-03-29 at 21:03 +0530, Varsha Rao wrote:
> > On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> > >
> > > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> > > > This patch fixes the clang warning of extraneous parentheses, with the
> > > > following coccinelle script.
> > > >
> > > > @@
> > > > identifier i;
> > > > constant c;
> > > > @@
> > > > (
> > > > -((i == c))
> > > > +i == c
> > > > >
> > > >
> > > > -((i <= c))
> > > > +i <= c
> > >
> > > Why just the "==" and "<=" cases?
> > > Why not "<", ">" and ">=" too?
> > >
> > > Why not expression instead of constant?
> >
> > Initially I had the other cases too and used expression instead of
> > constant. But the results included only "==" and "<=" cases with
> > constant. Along with one false positive case.
> hmm
> Perhaps you should use something like this?
> @@
> identifier i;
> constant c;
> @@
>
> -(
> \(i == c\|i <= c\|i < c\|i >= c\|i > c\)
> -)

This is not safe with respect to !.  The following seems to address this
problem:

@@
identifier i;
constant c;
expression e;
@@

(
!(e)
|
-(
\(i == c\|i <= c\|i < c\|i >= c\|i > c\)
-)
)

julia

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
@ 2018-03-31  6:17         ` Julia Lawall
  0 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2018-03-31  6:17 UTC (permalink / raw)
  To: Joe Perches
  Cc: Varsha Rao, linux-crypto, linux-kernel, cocci, Herbert Xu,
	David S. Miller



On Fri, 30 Mar 2018, Joe Perches wrote:

> On Thu, 2018-03-29 at 21:03 +0530, Varsha Rao wrote:
> > On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> > >
> > > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> > > > This patch fixes the clang warning of extraneous parentheses, with the
> > > > following coccinelle script.
> > > >
> > > > @@
> > > > identifier i;
> > > > constant c;
> > > > @@
> > > > (
> > > > -((i == c))
> > > > +i == c
> > > > >
> > > >
> > > > -((i <= c))
> > > > +i <= c
> > >
> > > Why just the "==" and "<=" cases?
> > > Why not "<", ">" and ">=" too?
> > >
> > > Why not expression instead of constant?
> >
> > Initially I had the other cases too and used expression instead of
> > constant. But the results included only "==" and "<=" cases with
> > constant. Along with one false positive case.
> hmm
> Perhaps you should use something like this?
> @@
> identifier i;
> constant c;
> @@
>
> -(
> \(i == c\|i <= c\|i < c\|i >= c\|i > c\)
> -)

This is not safe with respect to !.  The following seems to address this
problem:

@@
identifier i;
constant c;
expression e;
@@

(
!(e)
|
-(
\(i == c\|i <= c\|i < c\|i >= c\|i > c\)
-)
)

julia

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
@ 2018-03-31  6:17         ` Julia Lawall
  0 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2018-03-31  6:17 UTC (permalink / raw)
  To: cocci



On Fri, 30 Mar 2018, Joe Perches wrote:

> On Thu, 2018-03-29 at 21:03 +0530, Varsha Rao wrote:
> > On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> > >
> > > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> > > > This patch fixes the clang warning of extraneous parentheses, with the
> > > > following coccinelle script.
> > > >
> > > > @@
> > > > identifier i;
> > > > constant c;
> > > > @@
> > > > (
> > > > -((i == c))
> > > > +i == c
> > > > >
> > > >
> > > > -((i <= c))
> > > > +i <= c
> > >
> > > Why just the "==" and "<=" cases?
> > > Why not "<", ">" and ">=" too?
> > >
> > > Why not expression instead of constant?
> >
> > Initially I had the other cases too and used expression instead of
> > constant. But the results included only "==" and "<=" cases with
> > constant. Along with one false positive case.
> hmm
> Perhaps you should use something like this?
> @@
> identifier i;
> constant c;
> @@
>
> -(
> \(i == c\|i <= c\|i < c\|i >= c\|i > c\)
> -)

This is not safe with respect to !.  The following seems to address this
problem:

@@
identifier i;
constant c;
expression e;
@@

(
!(e)
|
-(
\(i == c\|i <= c\|i < c\|i >= c\|i > c\)
-)
)

julia

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
  2018-03-29 15:33     ` [Cocci] " Varsha Rao
  (?)
@ 2018-03-31  6:18       ` Julia Lawall
  -1 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2018-03-31  6:18 UTC (permalink / raw)
  To: Varsha Rao
  Cc: Herbert Xu, linux-kernel, cocci, linux-crypto, Joe Perches,
	David S. Miller



On Thu, 29 Mar 2018, Varsha Rao wrote:

> On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> >
> > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> > > This patch fixes the clang warning of extraneous parentheses, with the
> > > following coccinelle script.
> > >
> > > @@
> > > identifier i;
> > > constant c;
> > > @@
> > > (
> > > -((i == c))
> > > +i == c
> > > >
> > >
> > > -((i <= c))
> > > +i <= c
> >
> > Why just the "==" and "<=" cases?
> > Why not "<", ">" and ">=" too?
> >
> > Why not expression instead of constant?
>
> Initially I had the other cases too and used expression instead of
> constant. But the results included only "==" and "<=" cases with
> constant. Along with one false positive case.
>
> --- a/drivers/crypto/cavium/zip/zip_main.c
> +++ b/drivers/crypto/cavium/zip/zip_main.c
> @@ -99,7 +99,7 @@ static struct zip_device *zip_alloc_devi
>   */
>  struct zip_device *zip_get_device(int node)
>  {
> -    if ((node < MAX_ZIP_DEVICES) && (node >= 0))
> +    if (node < MAX_ZIP_DEVICES && node >= 0)

Why is it a false positive?

julia

>          return zip_dev[node];
>
>      zip_err("ZIP device not found for node id %d\n", node);
>
> I checked if there was any case of extra parentheses around relational
> operators left, but there were none. Hence, in the script I included
> only the cases present in the result.
>
> Thanks,
> Varsha
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
@ 2018-03-31  6:18       ` Julia Lawall
  0 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2018-03-31  6:18 UTC (permalink / raw)
  To: Varsha Rao
  Cc: Joe Perches, linux-crypto, linux-kernel, cocci, Herbert Xu,
	David S. Miller



On Thu, 29 Mar 2018, Varsha Rao wrote:

> On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> >
> > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> > > This patch fixes the clang warning of extraneous parentheses, with the
> > > following coccinelle script.
> > >
> > > @@
> > > identifier i;
> > > constant c;
> > > @@
> > > (
> > > -((i == c))
> > > +i == c
> > > >
> > >
> > > -((i <= c))
> > > +i <= c
> >
> > Why just the "==" and "<=" cases?
> > Why not "<", ">" and ">=" too?
> >
> > Why not expression instead of constant?
>
> Initially I had the other cases too and used expression instead of
> constant. But the results included only "==" and "<=" cases with
> constant. Along with one false positive case.
>
> --- a/drivers/crypto/cavium/zip/zip_main.c
> +++ b/drivers/crypto/cavium/zip/zip_main.c
> @@ -99,7 +99,7 @@ static struct zip_device *zip_alloc_devi
>   */
>  struct zip_device *zip_get_device(int node)
>  {
> -    if ((node < MAX_ZIP_DEVICES) && (node >= 0))
> +    if (node < MAX_ZIP_DEVICES && node >= 0)

Why is it a false positive?

julia

>          return zip_dev[node];
>
>      zip_err("ZIP device not found for node id %d\n", node);
>
> I checked if there was any case of extra parentheses around relational
> operators left, but there were none. Hence, in the script I included
> only the cases present in the result.
>
> Thanks,
> Varsha
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
@ 2018-03-31  6:18       ` Julia Lawall
  0 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2018-03-31  6:18 UTC (permalink / raw)
  To: cocci



On Thu, 29 Mar 2018, Varsha Rao wrote:

> On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> >
> > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> > > This patch fixes the clang warning of extraneous parentheses, with the
> > > following coccinelle script.
> > >
> > > @@
> > > identifier i;
> > > constant c;
> > > @@
> > > (
> > > -((i == c))
> > > +i == c
> > > >
> > >
> > > -((i <= c))
> > > +i <= c
> >
> > Why just the "==" and "<=" cases?
> > Why not "<", ">" and ">=" too?
> >
> > Why not expression instead of constant?
>
> Initially I had the other cases too and used expression instead of
> constant. But the results included only "==" and "<=" cases with
> constant. Along with one false positive case.
>
> --- a/drivers/crypto/cavium/zip/zip_main.c
> +++ b/drivers/crypto/cavium/zip/zip_main.c
> @@ -99,7 +99,7 @@ static struct zip_device *zip_alloc_devi
>   */
>  struct zip_device *zip_get_device(int node)
>  {
> -    if ((node < MAX_ZIP_DEVICES) && (node >= 0))
> +    if (node < MAX_ZIP_DEVICES && node >= 0)

Why is it a false positive?

julia

>          return zip_dev[node];
>
>      zip_err("ZIP device not found for node id %d\n", node);
>
> I checked if there was any case of extra parentheses around relational
> operators left, but there were none. Hence, in the script I included
> only the cases present in the result.
>
> Thanks,
> Varsha
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
  2018-03-31  6:18       ` Julia Lawall
@ 2018-03-31  8:48         ` Varsha Rao
  -1 siblings, 0 replies; 17+ messages in thread
From: Varsha Rao @ 2018-03-31  8:48 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Joe Perches, linux-crypto, linux-kernel, cocci, Herbert Xu,
	David S. Miller

On Sat, Mar 31, 2018 at 11:48 AM, Julia Lawall  wrote:
> On Thu, 29 Mar 2018, Varsha Rao wrote:
>
>> On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
>> >
>> > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
>> > > This patch fixes the clang warning of extraneous parentheses, with the
>> > > following coccinelle script.
>> > >
>> > > @@
>> > > identifier i;
>> > > constant c;
>> > > @@
>> > > (
>> > > -((i == c))
>> > > +i == c
>> > > >
>> > >
>> > > -((i <= c))
>> > > +i <= c
>> >
>> > Why just the "==" and "<=" cases?
>> > Why not "<", ">" and ">=" too?
>> >
>> > Why not expression instead of constant?
>>
>> Initially I had the other cases too and used expression instead of
>> constant. But the results included only "==" and "<=" cases with
>> constant. Along with one false positive case.
>>
>> --- a/drivers/crypto/cavium/zip/zip_main.c
>> +++ b/drivers/crypto/cavium/zip/zip_main.c
>> @@ -99,7 +99,7 @@ static struct zip_device *zip_alloc_devi
>>   */
>>  struct zip_device *zip_get_device(int node)
>>  {
>> -    if ((node < MAX_ZIP_DEVICES) && (node >= 0))
>> +    if (node < MAX_ZIP_DEVICES && node >= 0)
>
> Why is it a false positive?

The parentheses around multiple expressions in if statement is not
considered extra, right?

Thanks,
Varsha

> julia
>
>>          return zip_dev[node];
>>
>>      zip_err("ZIP device not found for node id %d\n", node);
>>
>> I checked if there was any case of extra parentheses around relational
>> operators left, but there were none. Hence, in the script I included
>> only the cases present in the result.
>>
>> Thanks,
>> Varsha
>> _______________________________________________
>> Cocci mailing list
>> Cocci@systeme.lip6.fr
>> https://systeme.lip6.fr/mailman/listinfo/cocci
>>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
@ 2018-03-31  8:48         ` Varsha Rao
  0 siblings, 0 replies; 17+ messages in thread
From: Varsha Rao @ 2018-03-31  8:48 UTC (permalink / raw)
  To: cocci

On Sat, Mar 31, 2018 at 11:48 AM, Julia Lawall  wrote:
> On Thu, 29 Mar 2018, Varsha Rao wrote:
>
>> On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
>> >
>> > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
>> > > This patch fixes the clang warning of extraneous parentheses, with the
>> > > following coccinelle script.
>> > >
>> > > @@
>> > > identifier i;
>> > > constant c;
>> > > @@
>> > > (
>> > > -((i == c))
>> > > +i == c
>> > > >
>> > >
>> > > -((i <= c))
>> > > +i <= c
>> >
>> > Why just the "==" and "<=" cases?
>> > Why not "<", ">" and ">=" too?
>> >
>> > Why not expression instead of constant?
>>
>> Initially I had the other cases too and used expression instead of
>> constant. But the results included only "==" and "<=" cases with
>> constant. Along with one false positive case.
>>
>> --- a/drivers/crypto/cavium/zip/zip_main.c
>> +++ b/drivers/crypto/cavium/zip/zip_main.c
>> @@ -99,7 +99,7 @@ static struct zip_device *zip_alloc_devi
>>   */
>>  struct zip_device *zip_get_device(int node)
>>  {
>> -    if ((node < MAX_ZIP_DEVICES) && (node >= 0))
>> +    if (node < MAX_ZIP_DEVICES && node >= 0)
>
> Why is it a false positive?

The parentheses around multiple expressions in if statement is not
considered extra, right?

Thanks,
Varsha

> julia
>
>>          return zip_dev[node];
>>
>>      zip_err("ZIP device not found for node id %d\n", node);
>>
>> I checked if there was any case of extra parentheses around relational
>> operators left, but there were none. Hence, in the script I included
>> only the cases present in the result.
>>
>> Thanks,
>> Varsha
>> _______________________________________________
>> Cocci mailing list
>> Cocci at systeme.lip6.fr
>> https://systeme.lip6.fr/mailman/listinfo/cocci
>>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
  2018-03-31  8:48         ` Varsha Rao
@ 2018-03-31  8:55           ` Julia Lawall
  -1 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2018-03-31  8:55 UTC (permalink / raw)
  To: Varsha Rao
  Cc: Joe Perches, linux-crypto, linux-kernel, cocci, Herbert Xu,
	David S. Miller



On Sat, 31 Mar 2018, Varsha Rao wrote:

> On Sat, Mar 31, 2018 at 11:48 AM, Julia Lawall  wrote:
> > On Thu, 29 Mar 2018, Varsha Rao wrote:
> >
> >> On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> >> >
> >> > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> >> > > This patch fixes the clang warning of extraneous parentheses, with the
> >> > > following coccinelle script.
> >> > >
> >> > > @@
> >> > > identifier i;
> >> > > constant c;
> >> > > @@
> >> > > (
> >> > > -((i == c))
> >> > > +i == c
> >> > > >
> >> > >
> >> > > -((i <= c))
> >> > > +i <= c
> >> >
> >> > Why just the "==" and "<=" cases?
> >> > Why not "<", ">" and ">=" too?
> >> >
> >> > Why not expression instead of constant?
> >>
> >> Initially I had the other cases too and used expression instead of
> >> constant. But the results included only "==" and "<=" cases with
> >> constant. Along with one false positive case.
> >>
> >> --- a/drivers/crypto/cavium/zip/zip_main.c
> >> +++ b/drivers/crypto/cavium/zip/zip_main.c
> >> @@ -99,7 +99,7 @@ static struct zip_device *zip_alloc_devi
> >>   */
> >>  struct zip_device *zip_get_device(int node)
> >>  {
> >> -    if ((node < MAX_ZIP_DEVICES) && (node >= 0))
> >> +    if (node < MAX_ZIP_DEVICES && node >= 0)
> >
> > Why is it a false positive?
>
> The parentheses around multiple expressions in if statement is not
> considered extra, right?

< and >= should bind tighter than &&.  But perhaps one could fine the
original code to be more readable.

julia

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Cocci] [PATCH] crypto: cavium: zip: Remove unnecessary parentheses
@ 2018-03-31  8:55           ` Julia Lawall
  0 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2018-03-31  8:55 UTC (permalink / raw)
  To: cocci



On Sat, 31 Mar 2018, Varsha Rao wrote:

> On Sat, Mar 31, 2018 at 11:48 AM, Julia Lawall  wrote:
> > On Thu, 29 Mar 2018, Varsha Rao wrote:
> >
> >> On Wed, Mar 28, 2018 at 11:41 PM, Joe Perches wrote:
> >> >
> >> > On Wed, 2018-03-28 at 23:27, Varsha Rao wrote:
> >> > > This patch fixes the clang warning of extraneous parentheses, with the
> >> > > following coccinelle script.
> >> > >
> >> > > @@
> >> > > identifier i;
> >> > > constant c;
> >> > > @@
> >> > > (
> >> > > -((i == c))
> >> > > +i == c
> >> > > >
> >> > >
> >> > > -((i <= c))
> >> > > +i <= c
> >> >
> >> > Why just the "==" and "<=" cases?
> >> > Why not "<", ">" and ">=" too?
> >> >
> >> > Why not expression instead of constant?
> >>
> >> Initially I had the other cases too and used expression instead of
> >> constant. But the results included only "==" and "<=" cases with
> >> constant. Along with one false positive case.
> >>
> >> --- a/drivers/crypto/cavium/zip/zip_main.c
> >> +++ b/drivers/crypto/cavium/zip/zip_main.c
> >> @@ -99,7 +99,7 @@ static struct zip_device *zip_alloc_devi
> >>   */
> >>  struct zip_device *zip_get_device(int node)
> >>  {
> >> -    if ((node < MAX_ZIP_DEVICES) && (node >= 0))
> >> +    if (node < MAX_ZIP_DEVICES && node >= 0)
> >
> > Why is it a false positive?
>
> The parentheses around multiple expressions in if statement is not
> considered extra, right?

< and >= should bind tighter than &&.  But perhaps one could fine the
original code to be more readable.

julia

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2018-03-31  8:55 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-28 17:57 [PATCH] crypto: cavium: zip: Remove unnecessary parentheses Varsha Rao
2018-03-28 18:11 ` Joe Perches
2018-03-28 18:11   ` [Cocci] " Joe Perches
2018-03-29 15:33   ` Varsha Rao
2018-03-29 15:33     ` [Cocci] " Varsha Rao
2018-03-30 20:17     ` Joe Perches
2018-03-30 20:17       ` [Cocci] " Joe Perches
2018-03-31  6:17       ` Julia Lawall
2018-03-31  6:17         ` [Cocci] " Julia Lawall
2018-03-31  6:17         ` Julia Lawall
2018-03-31  6:18     ` Julia Lawall
2018-03-31  6:18       ` [Cocci] " Julia Lawall
2018-03-31  6:18       ` Julia Lawall
2018-03-31  8:48       ` Varsha Rao
2018-03-31  8:48         ` Varsha Rao
2018-03-31  8:55         ` Julia Lawall
2018-03-31  8:55           ` Julia Lawall

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.