Skip to contentSkip to conversation

RDMA/rtrs: Avoid Wtautological-constant-out-of-range-compare

PATCH In review Jack Wang 2 participants 3 messages May 31, 2021 – Jun 1, 2021

Subsystems (2)
lore
Share & tools
lore

Jack Wang

author maintainer
#0 lore raw

PATCH 1/1 RDMA/rtrs: Avoid Wtautological-constant-out-of-range-compare

drivers/infiniband/ulp/rtrs/rtrs-clt.c:1786:19: warning: result of comparison of constant 'MAX_SESS_QUEUE_DEPTH' (65536) with expression of type 'u16' (aka 'unsigned short') is always false [-Wtautological-constant-out-of-range-compare]

To fix it, limit MAX_SESS_QUEUE_DEPTH to u16 max, which is 65535, and drop the check in rtrs-clt, as it's the type u16 max.

---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 5 -----
 drivers/infiniband/ulp/rtrs/rtrs-pri.h | 4 ++--
 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +0 -5
index 8e05a71d8da1..f1fd7ae9ac53 100644
@@ -1775,11 +1775,6 @@ static int rtrs_rdma_conn_established(struct rtrs_clt_con *con,
 	if (con->c.cid == 0) {
 		queue_depth = le16_to_cpu(msg->queue_depth);
 
-		if (queue_depth > MAX_SESS_QUEUE_DEPTH) {
-			rtrs_err(clt, "Invalid RTRS message: queue=%d\n",
-				  queue_depth);
-			return -ECONNRESET;
-		}
 		if (sess->queue_depth > 0 && queue_depth != sess->queue_depth) {
 			rtrs_err(clt, "Error: queue depth changed\n");
 
drivers/infiniband/ulp/rtrs/rtrs-pri.h +2 -2
index 1705197b8c22..bd06a79fd516 100644
@@ -53,9 +53,9 @@ enum {
 	 * But mempool_create, create_qp and ib_post_send fail with
 	 * "cannot allocate memory" error if sess_queue_depth is too big.
 	 * Therefore the pratical max value of sess_queue_depth is
-	 * somewhere between 1 and 65536 and it depends on the system.
+	 * somewhere between 1 and 65534 and it depends on the system.
 	 */
-	MAX_SESS_QUEUE_DEPTH = 65536,
+	MAX_SESS_QUEUE_DEPTH = 65535,
 	MIN_CHUNK_SIZE = 8192,
 
 	RTRS_HB_INTERVAL_MS = 5000,
Signature · 1 line
2.25.1
#1 lore raw
Quoted 4 lines · Jack Wang

drivers/infiniband/ulp/rtrs/rtrs-clt.c:1786:19: warning: result of comparison of constant 'MAX_SESS_QUEUE_DEPTH' (65536) with expression of type 'u16' (aka 'unsigned short') is always false [-Wtautological-constant-out-of-range-compare]

Quoted 8 lines

To fix it, limit MAX_SESS_QUEUE_DEPTH to u16 max, which is 65535, and drop the check in rtrs-clt, as it's the type u16 max.

---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 5 -----
 drivers/infiniband/ulp/rtrs/rtrs-pri.h | 4 ++--
 2 files changed, 2 insertions(+), 7 deletions(-)

I kept the patch as is since the first hunk gets wonky conflicts if it is squashed

Jason

author maintainer
#2 lore raw
Quoted 15 lines · Jason Gunthorpe
Quoted 4 lines · Jack Wang

drivers/infiniband/ulp/rtrs/rtrs-clt.c:1786:19: warning: result of comparison of constant 'MAX_SESS_QUEUE_DEPTH' (65536) with expression of type 'u16' (aka 'unsigned short') is always false [-Wtautological-constant-out-of-range-compare]

Quoted 8 lines

To fix it, limit MAX_SESS_QUEUE_DEPTH to u16 max, which is 65535, and drop the check in rtrs-clt, as it's the type u16 max.

---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 5 -----
 drivers/infiniband/ulp/rtrs/rtrs-pri.h | 4 ++--
 2 files changed, 2 insertions(+), 7 deletions(-)
Quoted 4 lines

I kept the patch as is since the first hunk gets wonky conflicts if it is squashed

Jason

Thanks!