infiniband: core: No assignment in if statements
PATCH 1/1 infiniband: core: No assignment in if statements
Does the assignment before the statement 'if'.
Found with Coccinelle:
@r1@
identifier ptr;
expression fn;
statement S;
@@
-if ((ptr = fn)) S
+ptr = fn;
+if (ptr) S
--- drivers/infiniband/core/addr.c | 3 ++- drivers/infiniband/core/cma.c | 3 ++- drivers/infiniband/core/mad.c | 9 ++++++--- 3 files changed, 10 insertions(+), 5 deletions(-)
drivers/infiniband/core/addr.c +2 -1
@@ -445,7 +445,8 @@ static int addr6_resolve(struct sockaddr_in6 *src_in, fl6.flowi6_oif = addr->bound_dev_if; dst =ip6_route_output (addr->net,NULL , &fl6); -if ((ret = dst->error)) + ret = dst->error; +if (ret) goto put; rt = (struct rt6_info *)dst;
drivers/infiniband/core/cma.c +2 -1
@@ -383,7 +383,8 @@ static int cma_comp_exch(struct rdma_id_private *id_priv,int ret;spin_lock_irqsave (&id_priv->lock, flags); -if ((ret = (id_priv->state == comp))) + ret = (id_priv->state == comp); +if (ret) id_priv->state = exch;spin_unlock_irqrestore (&id_priv->lock, flags);return ret;
drivers/infiniband/core/mad.c +6 -3
@@ -1466,13 +1466,15 @@ static int add_nonoui_reg_req(struct ib_mad_reg_req *mad_reg_req,/* Allocate method table for this management class */ method = &(*class)->method_table[mgmt_class]; -if ((ret =allocate_method_table (method))) + ret =allocate_method_table (method); +if (ret) goto error2; }else { method = &(*class)->method_table[mgmt_class];if (!*method) {/* Allocate method table for this management class */ -if ((ret =allocate_method_table (method))) + ret =allocate_method_table (method); +if (ret) goto error1; } }
@@ -1561,7 +1563,8 @@ static int add_oui_reg_req(struct ib_mad_reg_req *mad_reg_req, vclass]->method_table[i];BUG_ON (*method);/* Allocate method table for this OUI */ -if ((ret =allocate_method_table (method))) + ret =allocate_method_table (method); +if (ret) goto error3;memcpy ((*vendor_table)->vendor_class[vclass]->oui[i], mad_reg_req->oui,3 );
Signature · 1 line
2.7.4
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 14 lines · Greg KH
Quoted 13 lines · Mihaela Muraru
Does the assignment before the statement 'if'.
Found with Coccinelle:
@r1@
identifier ptr;
expression fn;
statement S;
@@(quoted diff) +2
-1-if ((ptr = fn)) S +ptr = fn; +if (ptr) S
Quoted 9 lines
Quoted 6 lines
Signed-off-by Mihaela Muraru <[email protected]>--- drivers/infiniband/core/addr.c | 3 ++- drivers/infiniband/core/cma.c | 3 ++- drivers/infiniband/core/mad.c | 9 ++++++--- 3 files changed, 10 insertions(+), 5 deletions(-)I can't take outreachy patches for stuff outside of
drivers/staging/why did you touch the infiniband codebase?
In infiniband, I found a match for my semantic patch.
Quoted 1 line
Is it one of the tasks?
No, I write a semantic patch and I wanted to use it and to send the a patch.
I will write other spatch, that will match with a file from drivers/staging/.
Thank you for reply,
mihaela
Quoted 3 lines
thanks,
greg k-h