Skip to contentSkip to conversation

RDMA/siw: replace redundant ternary operator with just rv

PATCH Applied Colin Ian King 3 participants 3 messages May 7, 2025 – May 12, 2025

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

PATCH 1/1 RDMA/siw: replace redundant ternary operator with just rv

The use of the ternary operator on rv is redundant, rv is either the initialized value of 0 or a negative error return code, so it can never be greater than zero, and hence the zero assignment in ternary operator is redundant. Just return rv instead.

---
 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 7ce0035c54fa..2b2a7b8e93b0 100644
@@ -1102,7 +1102,7 @@ int siw_post_receive(struct ib_qp *base_qp, const struct ib_recv_wr *wr,
 		siw_dbg_qp(qp, "error %d\n", rv);
 		*bad_wr = wr;
 	}
-	return rv > 0 ? 0 : rv;
+	return rv;
 }
 
 int siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata)
Signature · 1 line
2.49.0
Acked-by on v1 1/1
#1 lore raw
Quoted 36 lines

-----Original Message-----
From: Colin Ian King <[email protected]>
Sent: Wednesday, May 7, 2025 3:19 PM
To: Bernard Metzler <[email protected]>; Jason Gunthorpe <[email protected]>; Leon Romanovsky <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: [EXTERNAL] [PATCH][next] RDMA/siw: replace redundant ternary operator with just rv

The use of the ternary operator on rv is redundant, rv is either the initialized value of 0 or a negative error return code, so it can never be greater than zero, and hence the zero assignment in ternary operator is redundant. Just return rv instead.

---
 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 7ce0035c54fa..2b2a7b8e93b0 100644
@@ -1102,7 +1102,7 @@ int siw_post_receive(struct ib_qp *base_qp, const
 struct ib_recv_wr *wr,
 		siw_dbg_qp(qp, "error %d\n", rv);
 		*bad_wr = wr;
 	}
-	return rv > 0 ? 0 : rv;
+	return rv;
 }
 
Quoted 3 lines

int siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata)
--
2.49.0

Thanks Colin, makes sense.

#2 lore raw
In reply to Colin Ian King
Quoted 8 lines · Colin Ian King

The use of the ternary operator on rv is redundant, rv is either the initialized value of 0 or a negative error return code, so it can never be greater than zero, and hence the zero assignment in ternary operator is redundant. Just return rv instead.

[...]

Applied, thanks!

[1/1] RDMA/siw: replace redundant ternary operator with just rv

      https://git.kernel.org/rdma/rdma/c/8536666a52833d

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>