Skip to contentSkip to conversation

RDMA/siw: Use max() instead of doing it manually

PATCH Applied Jiapeng Chong 3 participants 3 messages Dec 2, 2021 – Dec 6, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/siw: Use max() instead of doing it manually

Fix following coccicheck warning:

./drivers/infiniband/sw/siw/siw_verbs.c:665:28-29: WARNING opportunity for max().

---
 drivers/infiniband/sw/siw/siw_verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/siw/siw_verbs.c +1 -1
index d15a1f9..a3dd2cb 100644
@@ -662,7 +662,7 @@ static int siw_copy_inline_sgl(const struct ib_send_wr *core_wr,
 		kbuf += core_sge->length;
 		core_sge++;
 	}
-	sqe->sge[0].length = bytes > 0 ? bytes : 0;
+	sqe->sge[0].length = max(bytes, 0);
 	sqe->num_sge = bytes > 0 ? 1 : 0;
 
 	return bytes;
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw

-----"Jiapeng Chong" <[email protected]> wrote: -----

Quoted 35 lines

To: [email protected]
From: "Jiapeng Chong" <[email protected]>
Date: 12/02/2021 11:08AM
Cc: [email protected], [email protected], [email protected], "Jiapeng Chong" <[email protected]>
Subject: [EXTERNAL] [PATCH] RDMA/siw: Use max() instead of doing it manually

Fix following coccicheck warning:

./drivers/infiniband/sw/siw/siw_verbs.c:665:28-29: WARNING opportunity
for max().

---
drivers/infiniband/sw/siw/siw_verbs.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/siw/siw_verbs.c +1 -1
index d15a1f9..a3dd2cb 100644
@@ -662,7 +662,7 @@ static int siw_copy_inline_sgl(const struct
 ib_send_wr *core_wr,
 		kbuf += core_sge->length;
 		core_sge++;
 	}
-	sqe->sge[0].length = bytes > 0 ? bytes : 0;
+	sqe->sge[0].length = max(bytes, 0);
 	sqe->num_sge = bytes > 0 ? 1 : 0;
 
Quoted 5 lines
	return bytes;
Signature · 1 line
1.8.3.1

Looks good, thanks!

maintainer Applied
#2 lore raw
In reply to Jiapeng Chong
Quoted 11 lines · Jiapeng Chong

Fix following coccicheck warning:

./drivers/infiniband/sw/siw/siw_verbs.c:665:28-29: WARNING opportunity for max().

---
 drivers/infiniband/sw/siw/siw_verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to for-next, thanks

Jason