lkml.org 
[lkml]   [2019]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] RDMA/cma: Fix checkpatch error
On Wed, Dec 11, 2019 at 11:16:26AM +0000, Max Hirsch wrote:
> When running checkpatch on cma.c the following error was found:

I think checkpatch will complain about your patch, did you run it?

> 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
> +++ 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);

Brackets are not needed

Ret and the return result should be changed to a bool

Jason

\
 
 \ /
  Last update: 2019-12-11 17:27    [W:0.086 / U:7.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site