From: Mark Zhang <markzhang@nvidia.com>
To: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>, jgg@ziepe.ca
Cc: leon@kernel.org, linux-rdma@vger.kernel.org,
linux-kernel@vger.kernel.org,
Abaci Robot <abaci@linux.alibaba.com>
Subject: Re: [PATCH] RDMA/cm: fix cond_no_effect.cocci warnings
Date: Tue, 14 Jun 2022 09:19:14 +0800 [thread overview]
Message-ID: <e187af34-d0a8-55ed-cc21-d88845ec1eb5@nvidia.com> (raw)
In-Reply-To: <20220610094530.28950-1-jiapeng.chong@linux.alibaba.com>
On 6/10/2022 5:45 PM, Jiapeng Chong wrote:
> This was found by coccicheck:
>
> ./drivers/infiniband/core/cm.c:685:7-9: WARNING: possible condition with no effect (if == else).
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
> drivers/infiniband/core/cm.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
> index 1c107d6d03b9..bb6a2b6b9657 100644
> --- a/drivers/infiniband/core/cm.c
> +++ b/drivers/infiniband/core/cm.c
> @@ -676,14 +676,9 @@ static struct cm_id_private *cm_find_listen(struct ib_device *device,
> refcount_inc(&cm_id_priv->refcount);
> return cm_id_priv;
> }
> - if (device < cm_id_priv->id.device)
> + if (device < cm_id_priv->id.device ||
> + be64_lt(service_id, cm_id_priv->id.service_id))
> node = node->rb_left;
> - else if (device > cm_id_priv->id.device)
> - node = node->rb_right;
> - else if (be64_lt(service_id, cm_id_priv->id.service_id))
> - node = node->rb_left;
> - else if (be64_gt(service_id, cm_id_priv->id.service_id))
> - node = node->rb_right;
> else
> node = node->rb_right;
> }
Not sure if the fix is correct, e.g. with this condition:
device > cm_id_priv->id.device &&
be64_lt(service_id, cm_id_priv->id.service_id)
The original code gets rb_right but this fix gets rb_left. Maybe the
warning is complain about this:
...
else if (be64_gt(service_id, cm_id_priv->id.service_id))
node = node->rb_right;
else
node = node->rb_right;
Besides cm_insert_listen() has same logic.
next prev parent reply other threads:[~2022-06-14 1:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-10 9:45 Jiapeng Chong
2022-06-14 1:19 ` Mark Zhang [this message]
2022-06-24 20:17 ` Jason Gunthorpe
2022-08-02 2:15 ` Mark Zhang
2022-08-02 13:52 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e187af34-d0a8-55ed-cc21-d88845ec1eb5@nvidia.com \
--to=markzhang@nvidia.com \
--cc=abaci@linux.alibaba.com \
--cc=jgg@ziepe.ca \
--cc=jiapeng.chong@linux.alibaba.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®