libmctp: Introduce compiler.h
Define __unused here and include compiler.h in all the places we can
make use of it. Clean up some header ordering and include styles while
we're at it.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I33ddbdacbddbbf557dc02e42d8dde71a16e1cabe
diff --git a/compiler.h b/compiler.h
new file mode 100644
index 0000000..6aefbf9
--- /dev/null
+++ b/compiler.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
+#ifndef _COMPILER_H
+#define _COMPILER_H
+
+#define __unused __attribute__((unused))
+
+#endif
diff --git a/tests/test_astlpc.c b/tests/test_astlpc.c
index 32c221f..054eda1 100644
--- a/tests/test_astlpc.c
+++ b/tests/test_astlpc.c
@@ -12,9 +12,10 @@
#define pr_fmt(x) "test: " x
#endif
+#include "compiler.h"
+#include "container_of.h"
#include "libmctp-astlpc.h"
#include "libmctp-log.h"
-#include "container_of.h"
#ifdef NDEBUG
#undef NDEBUG
@@ -149,8 +150,6 @@
.lpc_write = mctp_astlpc_mmio_lpc_write,
};
-#define __unused __attribute__((unused))
-
static void rx_message(uint8_t eid __unused, void *data __unused, void *msg,
size_t len)
{
diff --git a/tests/test_cmds.c b/tests/test_cmds.c
index 057a755..1b7536a 100644
--- a/tests/test_cmds.c
+++ b/tests/test_cmds.c
@@ -2,14 +2,15 @@
#include "test-utils.h"
+#include "compiler.h"
+#include "libmctp.h"
+#include "libmctp-alloc.h"
+#include "libmctp-cmds.h"
+
#include <stdio.h>
#include <string.h>
#include <assert.h>
-#include <libmctp.h>
-#include <libmctp-alloc.h>
-#include <libmctp-cmds.h>
-
#ifdef NDEBUG
#undef NDEBUG
#endif
@@ -30,8 +31,6 @@
};
};
-#define __unused __attribute__((unused))
-
static void control_message_transport_callback(mctp_eid_t src __unused,
void *data, void *buf,
size_t len __unused)
diff --git a/tests/test_core.c b/tests/test_core.c
index f571084..dacf197 100644
--- a/tests/test_core.c
+++ b/tests/test_core.c
@@ -19,6 +19,7 @@
#include <string.h>
#include <unistd.h>
+#include "compiler.h"
#include "libmctp-alloc.h"
#include "libmctp-log.h"
#include "range.h"
@@ -31,8 +32,6 @@
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#endif
-#define __unused __attribute__((unused))
-
#define MAX_PAYLOAD_SIZE 50000
struct pktbuf {
diff --git a/tests/test_eid.c b/tests/test_eid.c
index 51f989c..031d044 100644
--- a/tests/test_eid.c
+++ b/tests/test_eid.c
@@ -5,11 +5,10 @@
#include <stdio.h>
#include <string.h>
-#include <libmctp.h>
-
+#include "compiler.h"
+#include "libmctp.h"
#include "test-utils.h"
-
struct test_ctx {
struct mctp *mctp;
struct mctp_binding_test *binding;
diff --git a/tests/test_seq.c b/tests/test_seq.c
index e99dc94..8838acb 100644
--- a/tests/test_seq.c
+++ b/tests/test_seq.c
@@ -5,8 +5,8 @@
#include <stdio.h>
#include <string.h>
-#include <libmctp.h>
-
+#include "compiler.h"
+#include "libmctp.h"
#include "test-utils.h"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
diff --git a/tests/test_serial.c b/tests/test_serial.c
index 12d1476..3c6d147 100644
--- a/tests/test_serial.c
+++ b/tests/test_serial.c
@@ -6,6 +6,7 @@
#include "config.h"
#endif
+#include "compiler.h"
#include "libmctp-log.h"
#include "libmctp-serial.h"
@@ -43,8 +44,6 @@
static bool seen;
-#define __unused __attribute__((unused))
-
static void rx_message(uint8_t eid __unused, void *data __unused, void *msg,
size_t len)
{
diff --git a/utils/mctp-capture.h b/utils/mctp-capture.h
index 90feb66..e97d547 100644
--- a/utils/mctp-capture.h
+++ b/utils/mctp-capture.h
@@ -5,6 +5,7 @@
#include "config.h"
+#include "compiler.h"
#include "libmctp.h"
#include <sys/types.h>
@@ -19,8 +20,6 @@
#define CAPTURE_LINKTYPE_FIRST 147
#define CAPTURE_LINKTYPE_LAST 162
-#define __unused __attribute__((unused))
-
struct capture {
const char *path;
int linktype;
diff --git a/utils/mctp-demux-daemon.c b/utils/mctp-demux-daemon.c
index 968079f..d7ab9bc 100644
--- a/utils/mctp-demux-daemon.c
+++ b/utils/mctp-demux-daemon.c
@@ -3,6 +3,13 @@
#define _GNU_SOURCE
#include "config.h"
+
+#define SD_LISTEN_FDS_START 3
+
+#include "compiler.h"
+#include "libmctp.h"
+#include "libmctp-serial.h"
+#include "libmctp-astlpc.h"
#include "utils/mctp-capture.h"
#include <assert.h>
@@ -22,14 +29,7 @@
#include <sys/socket.h>
#include <sys/un.h>
-#define SD_LISTEN_FDS_START 3
-
-#include "libmctp.h"
-#include "libmctp-serial.h"
-#include "libmctp-astlpc.h"
-
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-#define __unused __attribute__((unused))
#if HAVE_SYSTEMD_SD_DAEMON_H
#include <systemd/sd-daemon.h>
diff --git a/utils/mctp-in.c b/utils/mctp-in.c
index c2792b6..eff4abf 100644
--- a/utils/mctp-in.c
+++ b/utils/mctp-in.c
@@ -1,5 +1,9 @@
/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
+#include "compiler.h"
+#include "libmctp.h"
+#include "libmctp-serial.h"
+
#include <assert.h>
#include <err.h>
#include <stdio.h>
@@ -8,9 +12,6 @@
#include <sys/poll.h>
#include <sys/socket.h>
-#include "libmctp.h"
-#include "libmctp-serial.h"
-
static void rx_message(uint8_t eid, void *data, void *msg, size_t len)
{
ssize_t rc;
diff --git a/utils/mctp-pipe.c b/utils/mctp-pipe.c
index 91389aa..ad466fb 100644
--- a/utils/mctp-pipe.c
+++ b/utils/mctp-pipe.c
@@ -1,5 +1,9 @@
/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
+#include "compiler.h"
+#include "libmctp.h"
+#include "libmctp-serial.h"
+
#include <assert.h>
#include <err.h>
#include <stdio.h>
@@ -8,9 +12,6 @@
#include <sys/poll.h>
#include <sys/socket.h>
-#include "libmctp.h"
-#include "libmctp-serial.h"
-
static void rx_message(uint8_t eid, void *data, void *msg, size_t len)
{
ssize_t rc;