Fix warnings reported by -Wpedantic
Previously CI hasn't been running with -Wpedantic (using autoconf), so
these haven't been reported previously.
- replace BUILD_ASSERT with static_assert()
- don't use %m GNU extension for printf
- don't use arithmetic on void*
- remove unused variables
Change-Id: I97d1acc908f06773b8b1ee95bfee80760fdc7a63
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
diff --git a/core.c b/core.c
index cc39dcf..33f5093 100644
--- a/core.c
+++ b/core.c
@@ -72,13 +72,6 @@
size_t max_message_size;
};
-#ifndef BUILD_ASSERT
-#define BUILD_ASSERT(x) \
- do { \
- (void)sizeof(char[0 - (!(x))]); \
- } while (0)
-#endif
-
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#endif
@@ -317,7 +310,7 @@
size_t i;
/* Cleanup message assembly contexts */
- BUILD_ASSERT(ARRAY_SIZE(mctp->msg_ctxs) < SIZE_MAX);
+ static_assert(ARRAY_SIZE(mctp->msg_ctxs) < SIZE_MAX, "size");
for (i = 0; i < ARRAY_SIZE(mctp->msg_ctxs); i++) {
struct mctp_msg_ctx *tmp = &mctp->msg_ctxs[i];
if (tmp->buf)
@@ -439,8 +432,11 @@
static inline bool mctp_ctrl_cmd_is_transport(struct mctp_ctrl_msg_hdr *hdr)
{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits"
return ((hdr->command_code >= MCTP_CTRL_CMD_FIRST_TRANSPORT) &&
(hdr->command_code <= MCTP_CTRL_CMD_LAST_TRANSPORT));
+#pragma GCC diagnostic pop
}
static bool mctp_ctrl_handle_msg(struct mctp_bus *bus, mctp_eid_t src,