[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <563d48b520713634b633bc859a8f87b73181a043.1641753491.git.leonro@nvidia.com>
Date: Sun, 9 Jan 2022 20:41:39 +0200
From: Leon Romanovsky <leon@...nel.org>
To: netdev@...r.kernel.org
Cc: Leon Romanovsky <leonro@...dia.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
Stephen Hemminger <stephen@...workplumber.org>
Subject: [PATCH iproute2-next 2/2] rdma: Don't allocate sparse array
From: Leon Romanovsky <leonro@...dia.com>
The addition of driver QP type with index 0xFF caused to the following
clang compilation error:
res.c:152: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])
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~
Instead of allocating very sparse array, simply create separate check
for the driver QP type.
Fixes: 39307384cea7 ("rdma: Add driver QP type string")
Reported-by: Stephen Hemminger <stephen@...workplumber.org>
Signed-off-by: Leon Romanovsky <leonro@...dia.com>
---
rdma/res.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/rdma/res.c b/rdma/res.c
index 9aae5d4b..21fef9bd 100644
--- a/rdma/res.c
+++ b/rdma/res.c
@@ -146,12 +146,12 @@ const char *qp_types_to_str(uint8_t idx)
"RAW_ETHERTYPE",
"UNKNOWN", "RAW_PACKET",
"XRC_INI", "XRC_TGT",
- [0xFF] = "DRIVER",
};
- if (idx < ARRAY_SIZE(qp_types_str) && qp_types_str[idx])
+ if (idx < ARRAY_SIZE(qp_types_str))
return qp_types_str[idx];
- return "UNKNOWN";
+
+ return (idx == 0xFF) ? "DRIVER" : "UNKNOWN";
}
void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line)
--
2.33.1
Powered by blists - more mailing lists