diff mbox series

[iproute2] rdma: remove tautological comparison

Message ID 20191229175054.12017-1-stephen@networkplumber.org
State Accepted
Delegated to: stephen hemminger
Headers show
Series [iproute2] rdma: remove tautological comparison | expand

Commit Message

Stephen Hemminger Dec. 29, 2019, 5:50 p.m. UTC
The qp_type is a uint8 and the comparison with ARRAY_SIZE would
always be true as reported by clang 10.

res.c:148:10: warning: result of comparison of constant 256 with expression of type 'uint8_t' (aka 'unsigned char') is always true [-Wtautological-constant-out-of-range-compare]
        if (idx < ARRAY_SIZE(qp_types_str) && qp_types_str[idx])
            ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~
Removing the comparison also allows for simpler trigraph
form of return.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 rdma/res.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/rdma/res.c b/rdma/res.c
index 251f5041f54c..ff92b0394601 100644
--- a/rdma/res.c
+++ b/rdma/res.c
@@ -145,9 +145,7 @@  const char *qp_types_to_str(uint8_t idx)
 						     [0xFF] = "DRIVER",
 	};
 
-	if (idx < ARRAY_SIZE(qp_types_str) && qp_types_str[idx])
-		return qp_types_str[idx];
-	return "UNKNOWN";
+	return qp_types_str[idx] ? : "UNKNOWN";
 }
 
 void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line)