linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RDMA/cma: Fix checkpatch error
@ 2019-12-11 11:16 Max Hirsch
  2019-12-11 16:26 ` Jason Gunthorpe
  0 siblings, 1 reply; 9+ messages in thread
From: Max Hirsch @ 2019-12-11 11:16 UTC (permalink / raw)
  Cc: Max Hirsch, Doug Ledford, Jason Gunthorpe, Parav Pandit,
	Leon Romanovsky, Steve Wise, Bart Van Assche, Danit Goldberg,
	Matthew Wilcox, Dag Moxnes, Myungho Jung, linux-rdma,
	linux-kernel

When running checkpatch on cma.c the following error was found:

ERROR: do not use assignment in if condition
#413: FILE: drivers/infiniband/tmp.c:413:
+	if ((ret = (id_priv->state == comp)))

This patch moves the assignment of ret to the previous line. The if statement then checks the value of ret assigned on the previous line. The assigned value of ret is not changed. Testing involved recompiling and loading the kernel. After the changes checkpatch does not report this the error in cma.c.

Signed-off-by: Max Hirsch <max.hirsch@gmail.com>
---
 drivers/infiniband/core/cma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 25f2b70fd8ef..bdb7a8493517 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -410,7 +410,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;
-- 
2.17.1


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

end of thread, other threads:[~2019-12-18 12:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11 11:16 [PATCH] RDMA/cma: Fix checkpatch error Max Hirsch
2019-12-11 16:26 ` Jason Gunthorpe
2019-12-12  1:33   ` Max Hirsch
2019-12-18 12:52     ` Jason Gunthorpe
2019-12-12  8:49   ` Leon Romanovsky
2019-12-12 12:10     ` Gal Pressman
2019-12-12 12:28       ` Max Hirsch
2019-12-12 13:47         ` Leon Romanovsky
2019-12-12 13:41       ` Leon Romanovsky

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).