[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20191229175054.12017-1-stephen@networkplumber.org>
Date: Sun, 29 Dec 2019 09:50:54 -0800
From: Stephen Hemminger <stephen@...workplumber.org>
To: netdev@...r.kernel.org
Cc: Stephen Hemminger <stephen@...workplumber.org>
Subject: [PATCH iproute2] 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.
Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
rdma/res.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
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)
--
2.20.1
Powered by blists - more mailing lists