Re: [PATCH] RDMA/hw/hfi1/tid_rdma: remove unnecessary conversion to bool

From: Tom Talpey
Date: Thu Feb 25 2021 - 09:34:04 EST


On 2/25/2021 4:26 AM, Jiapeng Chong wrote:
Fix the following coccicheck warnings:

./drivers/infiniband/hw/hfi1/tid_rdma.c:1118:36-41: WARNING: conversion
to bool not needed here.

Reported-by: Abaci Robot <abaci@xxxxxxxxxxxxxxxxx>
Signed-off-by: Jiapeng Chong <jiapeng.chong@xxxxxxxxxxxxxxxxx>
---
drivers/infiniband/hw/hfi1/tid_rdma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hfi1/tid_rdma.c b/drivers/infiniband/hw/hfi1/tid_rdma.c
index 0b1f9e4..8958ea3 100644
--- a/drivers/infiniband/hw/hfi1/tid_rdma.c
+++ b/drivers/infiniband/hw/hfi1/tid_rdma.c
@@ -1115,7 +1115,7 @@ static u32 kern_find_pages(struct tid_rdma_flow *flow,
}
flow->length = flow->req->seg_len - length;
- *last = req->isge == ss->num_sge ? false : true;
+ *last = req->isge == !ss->num_sge;

Are you sure this is what you want? The new code seems to compare
an index to a bool (refactoring)

*last = req->isge == (ss->num_sge != 0);

Don't you actually want

*last = req->isge != ss->num_sge;

??

Even then, it seems really hard to read.

return i;
}