Skip to contentSkip to conversation

rdma: remove tautological comparison

PATCH New Stephen Hemminger 1 participant 1 message Dec 29, 2019

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

PATCH 1/1 rdma: remove tautological comparison

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.

---
 rdma/res.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
rdma/res.c +1 -3
index 251f5041f54c..ff92b0394601 100644
@@ -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)
Signature · 1 line
2.20.1