format: reformat with clang-format

Reformat everything with clang-format and remove .clang-ignore and
custom code formatter.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I93dfca67948d3fbcc0f05ece4ae3e4dd9495ab57
diff --git a/.clang-ignore b/.clang-ignore
deleted file mode 100644
index bcefaf6..0000000
--- a/.clang-ignore
+++ /dev/null
@@ -1,8 +0,0 @@
-astlpc.c
-core.c
-libmctp.h
-serial.c
-tests/test_bridge.c
-tests/test_eid.c
-tests/test_seq.c
-utils/mctp-demux-daemon.c
diff --git a/astlpc.c b/astlpc.c
index 4cf5dac..0281099 100644
--- a/astlpc.c
+++ b/astlpc.c
@@ -113,7 +113,7 @@
 };
 
 struct mctp_binding_astlpc {
-	struct mctp_binding	binding;
+	struct mctp_binding binding;
 
 	void *lpc_map;
 	struct mctp_astlpc_layout layout;
@@ -132,7 +132,7 @@
 	uint8_t kcs_status;
 };
 
-#define binding_to_astlpc(b) \
+#define binding_to_astlpc(b)                                                   \
 	container_of(b, struct mctp_binding_astlpc, binding)
 
 #define astlpc_prlog(ctx, lvl, fmt, ...)                                       \
@@ -276,12 +276,12 @@
 
 static const uint32_t control_size = 0x100;
 
-#define LPC_WIN_SIZE                (1 * 1024 * 1024)
+#define LPC_WIN_SIZE (1 * 1024 * 1024)
 
-#define KCS_STATUS_BMC_READY		0x80
-#define KCS_STATUS_CHANNEL_ACTIVE	0x40
-#define KCS_STATUS_IBF			0x02
-#define KCS_STATUS_OBF			0x01
+#define KCS_STATUS_BMC_READY	  0x80
+#define KCS_STATUS_CHANNEL_ACTIVE 0x40
+#define KCS_STATUS_IBF		  0x02
+#define KCS_STATUS_OBF		  0x01
 
 static inline int mctp_astlpc_kcs_write(struct mctp_binding_astlpc *astlpc,
 					enum mctp_binding_astlpc_kcs_reg reg,
@@ -416,8 +416,9 @@
 		hdr.layout.tx_size = htobe32(layout->rx.size);
 
 		return mctp_astlpc_lpc_write(astlpc, &hdr.layout,
-				offsetof(struct mctp_lpcmap_hdr, layout),
-				sizeof(hdr.layout));
+					     offsetof(struct mctp_lpcmap_hdr,
+						      layout),
+					     sizeof(hdr.layout));
 	}
 
 	assert(astlpc->mode == MCTP_BINDING_ASTLPC_MODE_HOST);
@@ -428,8 +429,9 @@
 	 */
 	rx_size_be = htobe32(layout->rx.size);
 	return mctp_astlpc_lpc_write(astlpc, &rx_size_be,
-			offsetof(struct mctp_lpcmap_hdr, layout.rx_size),
-			sizeof(rx_size_be));
+				     offsetof(struct mctp_lpcmap_hdr,
+					      layout.rx_size),
+				     sizeof(rx_size_be));
 }
 
 static bool
@@ -457,9 +459,11 @@
 	}
 
 	/* Check that the baseline transmission unit is supported */
-	if (buf->size < astlpc->proto->packet_size(MCTP_PACKET_SIZE(MCTP_BTU))) {
+	if (buf->size <
+	    astlpc->proto->packet_size(MCTP_PACKET_SIZE(MCTP_BTU))) {
 		mctp_prerr(
-			"%s packet buffer too small: Require %" PRIu32 " bytes to support the %u byte baseline transmission unit, found %" PRIu32,
+			"%s packet buffer too small: Require %" PRIu32
+			" bytes to support the %u byte baseline transmission unit, found %" PRIu32,
 			name,
 			astlpc->proto->packet_size(MCTP_PACKET_SIZE(MCTP_BTU)),
 			MCTP_BTU, buf->size);
@@ -697,9 +701,8 @@
 	bmc_ver_cur = be16toh(hdr.bmc_ver_cur);
 
 	/* Calculate the expected value of negotiated_ver */
-	negotiated = mctp_astlpc_negotiate_version(bmc_ver_min, bmc_ver_cur,
-						   ASTLPC_VER_MIN,
-						   ASTLPC_VER_CUR);
+	negotiated = mctp_astlpc_negotiate_version(
+		bmc_ver_min, bmc_ver_cur, ASTLPC_VER_MIN, ASTLPC_VER_CUR);
 	if (!negotiated) {
 		astlpc_prerr(astlpc, "Cannot negotiate with invalid versions");
 		return -EINVAL;
@@ -781,13 +784,12 @@
 }
 
 static int mctp_astlpc_kcs_send(struct mctp_binding_astlpc *astlpc,
-		uint8_t data)
+				uint8_t data)
 {
 	uint8_t status;
 	int rc;
 
-	rc = mctp_astlpc_kcs_read(astlpc, MCTP_ASTLPC_KCS_REG_STATUS,
-			&status);
+	rc = mctp_astlpc_kcs_read(astlpc, MCTP_ASTLPC_KCS_REG_STATUS, &status);
 	if (rc) {
 		astlpc_prwarn(astlpc, "KCS status read failed");
 		return -EIO;
@@ -805,7 +807,7 @@
 }
 
 static int mctp_binding_astlpc_tx(struct mctp_binding *b,
-		struct mctp_pktbuf *pkt)
+				  struct mctp_pktbuf *pkt)
 {
 	struct mctp_binding_astlpc *astlpc = binding_to_astlpc(b);
 	uint32_t len, len_be;
@@ -997,7 +999,8 @@
 	packet = astlpc->proto->packet_size(body) - 4;
 	pkt = mctp_pktbuf_alloc(&astlpc->binding, packet);
 	if (!pkt) {
-		astlpc_prwarn(astlpc, "unable to allocate pktbuf len 0x%x", packet);
+		astlpc_prwarn(astlpc, "unable to allocate pktbuf len 0x%x",
+			      packet);
 		return;
 	}
 
@@ -1117,7 +1120,7 @@
 	}
 
 	if (astlpc->proto->version == 0 ||
-			updated & KCS_STATUS_CHANNEL_ACTIVE) {
+	    updated & KCS_STATUS_CHANNEL_ACTIVE) {
 		bool enable;
 
 		astlpc->layout.rx.state = buffer_state_idle;
@@ -1176,18 +1179,20 @@
 		break;
 	case 0x1:
 		if (astlpc->layout.rx.state != buffer_state_released) {
-			astlpc_prerr(astlpc,
-				     "Protocol error: Invalid Rx buffer state for event %d: %d\n",
-				     data, astlpc->layout.rx.state);
+			astlpc_prerr(
+				astlpc,
+				"Protocol error: Invalid Rx buffer state for event %d: %d\n",
+				data, astlpc->layout.rx.state);
 			return 0;
 		}
 		mctp_astlpc_rx_start(astlpc);
 		break;
 	case 0x2:
 		if (astlpc->layout.tx.state != buffer_state_released) {
-			astlpc_prerr(astlpc,
-				     "Protocol error: Invalid Tx buffer state for event %d: %d\n",
-				     data, astlpc->layout.tx.state);
+			astlpc_prerr(
+				astlpc,
+				"Protocol error: Invalid Tx buffer state for event %d: %d\n",
+				data, astlpc->layout.tx.state);
 			return 0;
 		}
 		mctp_astlpc_tx_complete(astlpc);
@@ -1349,13 +1354,15 @@
 
 	/* Map the reserved memory at the top of the 28-bit LPC firmware address space */
 	map.addr = 0x0FFFFFFF & -map.size;
-	astlpc_prinfo(astlpc,
-		      "Configuring FW2AHB to map reserved memory at 0x%08x for 0x%x in the LPC FW cycle address-space",
-		      map.addr, map.size);
+	astlpc_prinfo(
+		astlpc,
+		"Configuring FW2AHB to map reserved memory at 0x%08x for 0x%x in the LPC FW cycle address-space",
+		map.addr, map.size);
 
 	rc = ioctl(fd, ASPEED_LPC_CTRL_IOCTL_MAP, &map);
 	if (rc) {
-		astlpc_prwarn(astlpc, "Failed to map FW2AHB to reserved memory");
+		astlpc_prwarn(astlpc,
+			      "Failed to map FW2AHB to reserved memory");
 		close(fd);
 		return -1;
 	}
@@ -1385,7 +1392,8 @@
 }
 
 static int __mctp_astlpc_fileio_kcs_read(void *arg,
-		enum mctp_binding_astlpc_kcs_reg reg, uint8_t *val)
+					 enum mctp_binding_astlpc_kcs_reg reg,
+					 uint8_t *val)
 {
 	struct mctp_binding_astlpc *astlpc = arg;
 	off_t offset = reg;
@@ -1397,7 +1405,8 @@
 }
 
 static int __mctp_astlpc_fileio_kcs_write(void *arg,
-		enum mctp_binding_astlpc_kcs_reg reg, uint8_t val)
+					  enum mctp_binding_astlpc_kcs_reg reg,
+					  uint8_t val)
 {
 	struct mctp_binding_astlpc *astlpc = arg;
 	off_t offset = reg;
@@ -1417,7 +1426,7 @@
 	pollfd->events = 0;
 
 	release = astlpc->layout.rx.state == buffer_state_prepared ||
-			astlpc->layout.tx.state == buffer_state_prepared;
+		  astlpc->layout.tx.state == buffer_state_prepared;
 
 	pollfd->events = release ? POLLOUT : POLLIN;
 
diff --git a/core.c b/core.c
index 2f87692..5a5d247 100644
--- a/core.c
+++ b/core.c
@@ -38,43 +38,45 @@
 };
 
 struct mctp_msg_ctx {
-	uint8_t		src;
-	uint8_t		dest;
-	uint8_t		tag;
-	uint8_t		last_seq;
-	void		*buf;
-	size_t		buf_size;
-	size_t		buf_alloc_size;
-	size_t		fragment_size;
+	uint8_t src;
+	uint8_t dest;
+	uint8_t tag;
+	uint8_t last_seq;
+	void *buf;
+	size_t buf_size;
+	size_t buf_alloc_size;
+	size_t fragment_size;
 };
 
 struct mctp {
-	int			n_busses;
-	struct mctp_bus		*busses;
+	int n_busses;
+	struct mctp_bus *busses;
 
 	/* Message RX callback */
-	mctp_rx_fn		message_rx;
-	void			*message_rx_data;
+	mctp_rx_fn message_rx;
+	void *message_rx_data;
 
 	/* Packet capture callback */
-	mctp_capture_fn		capture;
-	void			*capture_data;
+	mctp_capture_fn capture;
+	void *capture_data;
 
 	/* Message reassembly.
 	 * @todo: flexible context count
 	 */
-	struct mctp_msg_ctx	msg_ctxs[16];
+	struct mctp_msg_ctx msg_ctxs[16];
 
 	enum {
 		ROUTE_ENDPOINT,
 		ROUTE_BRIDGE,
-	}			route_policy;
+	} route_policy;
 	size_t max_message_size;
 };
 
 #ifndef BUILD_ASSERT
-#define BUILD_ASSERT(x) \
-	do { (void)sizeof(char[0-(!(x))]); } while (0)
+#define BUILD_ASSERT(x)                                                        \
+	do {                                                                   \
+		(void)sizeof(char[0 - (!(x))]);                                \
+	} while (0)
 #endif
 
 #ifndef ARRAY_SIZE
@@ -172,8 +174,8 @@
 }
 
 /* Message reassembly */
-static struct mctp_msg_ctx *mctp_msg_ctx_lookup(struct mctp *mctp,
-		uint8_t src, uint8_t dest, uint8_t tag)
+static struct mctp_msg_ctx *mctp_msg_ctx_lookup(struct mctp *mctp, uint8_t src,
+						uint8_t dest, uint8_t tag)
 {
 	unsigned int i;
 
@@ -188,8 +190,8 @@
 	return NULL;
 }
 
-static struct mctp_msg_ctx *mctp_msg_ctx_create(struct mctp *mctp,
-		uint8_t src, uint8_t dest, uint8_t tag)
+static struct mctp_msg_ctx *mctp_msg_ctx_create(struct mctp *mctp, uint8_t src,
+						uint8_t dest, uint8_t tag)
 {
 	struct mctp_msg_ctx *ctx = NULL;
 	unsigned int i;
@@ -225,7 +227,7 @@
 }
 
 static int mctp_msg_ctx_add_pkt(struct mctp_msg_ctx *ctx,
-		struct mctp_pktbuf *pkt, size_t max_size)
+				struct mctp_pktbuf *pkt, size_t max_size)
 {
 	size_t len;
 
@@ -243,14 +245,14 @@
 		if (!ctx->buf_alloc_size) {
 			new_alloc_size = MAX(len, 4096UL);
 		} else {
-			new_alloc_size = MAX(ctx->buf_alloc_size * 2, len + ctx->buf_size);
+			new_alloc_size = MAX(ctx->buf_alloc_size * 2,
+					     len + ctx->buf_size);
 		}
 
 		/* Don't allow heap to grow beyond a limit */
 		if (new_alloc_size > max_size)
 			return -1;
 
-
 		lbuf = __mctp_realloc(ctx->buf, new_alloc_size);
 		if (lbuf) {
 			ctx->buf = lbuf;
@@ -274,7 +276,7 @@
 
 	mctp = __mctp_alloc(sizeof(*mctp));
 
-	if(!mctp)
+	if (!mctp)
 		return NULL;
 
 	memset(mctp, 0, sizeof(*mctp));
@@ -330,8 +332,8 @@
 	return 0;
 }
 
-static struct mctp_bus *find_bus_for_eid(struct mctp *mctp,
-		mctp_eid_t dest __attribute__((unused)))
+static struct mctp_bus *find_bus_for_eid(struct mctp *mctp, mctp_eid_t dest
+					 __attribute__((unused)))
 {
 	if (mctp->n_busses == 0)
 		return NULL;
@@ -341,9 +343,8 @@
 	return &mctp->busses[0];
 }
 
-int mctp_register_bus(struct mctp *mctp,
-		struct mctp_binding *binding,
-		mctp_eid_t eid)
+int mctp_register_bus(struct mctp *mctp, struct mctp_binding *binding,
+		      mctp_eid_t eid)
 {
 	int rc = 0;
 
@@ -388,8 +389,8 @@
 	free(mctp->busses);
 }
 
-int mctp_bridge_busses(struct mctp *mctp,
-		struct mctp_binding *b1, struct mctp_binding *b2)
+int mctp_bridge_busses(struct mctp *mctp, struct mctp_binding *b1,
+		       struct mctp_binding *b2)
 {
 	int rc = 0;
 
@@ -524,7 +525,6 @@
 			mctp_message_tx_on_bus(dest_bus, src, dest, tag_owner,
 					       msg_tag, buf, len);
 		}
-
 	}
 }
 
@@ -579,8 +579,8 @@
 		if (ctx) {
 			mctp_msg_ctx_reset(ctx);
 		} else {
-			ctx = mctp_msg_ctx_create(mctp,
-					hdr->src, hdr->dest, tag);
+			ctx = mctp_msg_ctx_create(mctp, hdr->src, hdr->dest,
+						  tag);
 			/* If context creation fails due to exhaution of contexts we
 			* can support, drop the packet */
 			if (!ctx) {
@@ -620,9 +620,9 @@
 		len = mctp_pktbuf_size(pkt);
 
 		if (len > ctx->fragment_size) {
-			mctp_prdebug("Unexpected fragment size. Expected" \
-				" less than %zu, received = %zu",
-				ctx->fragment_size, len);
+			mctp_prdebug("Unexpected fragment size. Expected"
+				     " less than %zu, received = %zu",
+				     ctx->fragment_size, len);
 			mctp_msg_ctx_drop(ctx);
 			goto out;
 		}
@@ -637,7 +637,7 @@
 
 	case 0:
 		/* Neither SOM nor EOM */
-		ctx = mctp_msg_ctx_lookup(mctp, hdr->src,hdr->dest, tag);
+		ctx = mctp_msg_ctx_lookup(mctp, hdr->src, hdr->dest, tag);
 		if (!ctx)
 			goto out;
 
@@ -653,8 +653,9 @@
 		len = mctp_pktbuf_size(pkt);
 
 		if (len != ctx->fragment_size) {
-			mctp_prdebug("Unexpected fragment size. Expected = %zu " \
-				"received = %zu", ctx->fragment_size, len);
+			mctp_prdebug("Unexpected fragment size. Expected = %zu "
+				     "received = %zu",
+				     ctx->fragment_size, len);
 			mctp_msg_ctx_drop(ctx);
 			goto out;
 		}
@@ -672,8 +673,7 @@
 	mctp_pktbuf_free(pkt);
 }
 
-static int mctp_packet_tx(struct mctp_bus *bus,
-		struct mctp_pktbuf *pkt)
+static int mctp_packet_tx(struct mctp_bus *bus, struct mctp_pktbuf *pkt)
 {
 	struct mctp *mctp = bus->binding->mctp;
 
@@ -716,22 +716,22 @@
 cleanup_tail:
 	if (!bus->tx_queue_head)
 		bus->tx_queue_tail = NULL;
-
 }
 
 void mctp_binding_set_tx_enabled(struct mctp_binding *binding, bool enable)
 {
 	struct mctp_bus *bus = binding->bus;
 
-	switch(bus->state) {
+	switch (bus->state) {
 	case mctp_bus_state_constructed:
 		if (!enable)
 			return;
 
 		if (binding->pkt_size < MCTP_PACKET_SIZE(MCTP_BTU)) {
-			mctp_prerr("Cannot start %s binding with invalid MTU: %zu",
-				   binding->name,
-				   MCTP_BODY_SIZE(binding->pkt_size));
+			mctp_prerr(
+				"Cannot start %s binding with invalid MTU: %zu",
+				binding->name,
+				MCTP_BODY_SIZE(binding->pkt_size));
 			return;
 		}
 
@@ -780,8 +780,9 @@
 			return -EINVAL;
 	}
 
-	mctp_prdebug("%s: Generating packets for transmission of %zu byte message from %hhu to %hhu",
-		     __func__, msg_len, src, dest);
+	mctp_prdebug(
+		"%s: Generating packets for transmission of %zu byte message from %hhu to %hhu",
+		__func__, msg_len, src, dest);
 
 	/* queue up packets, each of max MCTP_MTU size */
 	for (p = 0, i = 0; p < msg_len; i++) {
@@ -790,7 +791,7 @@
 			payload_len = max_payload_len;
 
 		pkt = mctp_pktbuf_alloc(bus->binding,
-				payload_len + sizeof(*hdr));
+					payload_len + sizeof(*hdr));
 		hdr = mctp_pktbuf_hdr(pkt);
 
 		hdr->ver = bus->binding->version & 0xf;
@@ -803,8 +804,8 @@
 			hdr->flags_seq_tag |= MCTP_HDR_FLAG_SOM;
 		if (p + payload_len >= msg_len)
 			hdr->flags_seq_tag |= MCTP_HDR_FLAG_EOM;
-		hdr->flags_seq_tag |=
-			(i & MCTP_HDR_SEQ_MASK) << MCTP_HDR_SEQ_SHIFT;
+		hdr->flags_seq_tag |= (i & MCTP_HDR_SEQ_MASK)
+				      << MCTP_HDR_SEQ_SHIFT;
 
 		memcpy(mctp_pktbuf_data(pkt), (uint8_t *)msg + p, payload_len);
 
diff --git a/format-code.sh b/format-code.sh
deleted file mode 100755
index d34554d..0000000
--- a/format-code.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-
-: ${CLANG_FORMAT:=clang-format}
-
-FILES=$(comm -3 <(sort .clang-ignore) <(git ls-files | grep '.*\.[ch]$' | sort))
-
-if [ -n "$FILES" ]
-then
-    $CLANG_FORMAT -style=file -i $FILES
-fi
diff --git a/libmctp.h b/libmctp.h
index 8e13c29..b34abfe 100644
--- a/libmctp.h
+++ b/libmctp.h
@@ -15,15 +15,15 @@
 typedef uint8_t mctp_eid_t;
 
 /* Special Endpoint ID values */
-#define MCTP_EID_NULL 0
+#define MCTP_EID_NULL	   0
 #define MCTP_EID_BROADCAST 0xff
 
 /* MCTP packet definitions */
 struct mctp_hdr {
-	uint8_t	ver;
-	uint8_t	dest;
-	uint8_t	src;
-	uint8_t	flags_seq_tag;
+	uint8_t ver;
+	uint8_t dest;
+	uint8_t src;
+	uint8_t flags_seq_tag;
 };
 
 /* Definitions for flags_seq_tag field */
@@ -41,17 +41,17 @@
 #define MCTP_MESSAGE_TO_DST false
 
 /* Baseline Transmission Unit and packet size */
-#define MCTP_BTU		64
-#define MCTP_PACKET_SIZE(unit)	((unit) + sizeof(struct mctp_hdr))
-#define MCTP_BODY_SIZE(unit)	((unit) - sizeof(struct mctp_hdr))
+#define MCTP_BTU	       64
+#define MCTP_PACKET_SIZE(unit) ((unit) + sizeof(struct mctp_hdr))
+#define MCTP_BODY_SIZE(unit)   ((unit) - sizeof(struct mctp_hdr))
 
 /* packet buffers */
 
 struct mctp_pktbuf {
-	size_t		start, end, size;
-	size_t		mctp_hdr_off;
+	size_t start, end, size;
+	size_t mctp_hdr_off;
 	struct mctp_pktbuf *next;
-	unsigned char	data[];
+	unsigned char data[];
 };
 
 struct mctp_binding;
@@ -73,7 +73,8 @@
 struct mctp *mctp_init(void);
 void mctp_set_max_message_size(struct mctp *mctp, size_t message_size);
 typedef void (*mctp_capture_fn)(struct mctp_pktbuf *pkt, void *user);
-void mctp_set_capture_handler(struct mctp *mctp, mctp_capture_fn fn, void *user);
+void mctp_set_capture_handler(struct mctp *mctp, mctp_capture_fn fn,
+			      void *user);
 void mctp_destroy(struct mctp *mctp);
 
 /* Register a binding to the MCTP core, and creates a bus (populating
@@ -83,9 +84,8 @@
  * and will deliver local packets to a RX callback - see `mctp_set_rx_all()`
  * below.
  */
-int mctp_register_bus(struct mctp *mctp,
-		struct mctp_binding *binding,
-		mctp_eid_t eid);
+int mctp_register_bus(struct mctp *mctp, struct mctp_binding *binding,
+		      mctp_eid_t eid);
 
 void mctp_unregister_bus(struct mctp *mctp, struct mctp_binding *binding);
 
@@ -95,8 +95,8 @@
  * defined, so no packets are considered local. Instead, all messages from one
  * binding are forwarded to the other.
  */
-int mctp_bridge_busses(struct mctp *mctp,
-		struct mctp_binding *b1, struct mctp_binding *b2);
+int mctp_bridge_busses(struct mctp *mctp, struct mctp_binding *b1,
+		       struct mctp_binding *b2);
 
 typedef void (*mctp_rx_fn)(uint8_t src_eid, bool tag_owner, uint8_t msg_tag,
 			   void *data, void *msg, size_t len);
@@ -138,9 +138,8 @@
 void mctp_bus_rx(struct mctp_binding *binding, struct mctp_pktbuf *pkt);
 
 /* environment-specific allocation */
-void mctp_set_alloc_ops(void *(*alloc)(size_t),
-		void (*free)(void *),
-		void *(realloc)(void *, size_t));
+void mctp_set_alloc_ops(void *(*alloc)(size_t), void (*free)(void *),
+			void *(realloc)(void *, size_t));
 
 /* environment-specific logging */
 
@@ -150,12 +149,11 @@
 
 /* these should match the syslog-standard LOG_* definitions, for
  * easier use with syslog */
-#define MCTP_LOG_ERR		3
-#define MCTP_LOG_WARNING	4
-#define MCTP_LOG_NOTICE		5
-#define MCTP_LOG_INFO		6
-#define MCTP_LOG_DEBUG		7
-
+#define MCTP_LOG_ERR	 3
+#define MCTP_LOG_WARNING 4
+#define MCTP_LOG_NOTICE	 5
+#define MCTP_LOG_INFO	 6
+#define MCTP_LOG_DEBUG	 7
 
 #ifdef __cplusplus
 }
diff --git a/serial.c b/serial.c
index 35c4a02..22517a7 100644
--- a/serial.c
+++ b/serial.c
@@ -65,14 +65,14 @@
 	int fd;
 	unsigned long bus_id;
 
-	mctp_serial_tx_fn	tx_fn;
-	void			*tx_fn_data;
+	mctp_serial_tx_fn tx_fn;
+	void *tx_fn_data;
 
 	/* receive buffer and state */
-	uint8_t			rxbuf[1024];
-	struct mctp_pktbuf	*rx_pkt;
-	uint8_t			rx_exp_len;
-	uint16_t		rx_fcs;
+	uint8_t rxbuf[1024];
+	struct mctp_pktbuf *rx_pkt;
+	uint8_t rx_exp_len;
+	uint16_t rx_fcs;
 	enum {
 		STATE_WAIT_SYNC_START,
 		STATE_WAIT_REVISION,
@@ -85,26 +85,26 @@
 	} rx_state;
 
 	/* temporary transmit buffer */
-	uint8_t			txbuf[256];
+	uint8_t txbuf[256];
 };
 
-#define binding_to_serial(b) \
+#define binding_to_serial(b)                                                   \
 	container_of(b, struct mctp_binding_serial, binding)
 
-#define MCTP_SERIAL_REVISION		0x01
-#define MCTP_SERIAL_FRAMING_FLAG	0x7e
-#define MCTP_SERIAL_ESCAPE		0x7d
+#define MCTP_SERIAL_REVISION	 0x01
+#define MCTP_SERIAL_FRAMING_FLAG 0x7e
+#define MCTP_SERIAL_ESCAPE	 0x7d
 
 struct mctp_serial_header {
-	uint8_t	flag;
+	uint8_t flag;
 	uint8_t revision;
-	uint8_t	len;
+	uint8_t len;
 };
 
 struct mctp_serial_trailer {
-	uint8_t	fcs_msb;
+	uint8_t fcs_msb;
 	uint8_t fcs_lsb;
-	uint8_t	flag;
+	uint8_t flag;
 };
 
 static size_t mctp_serial_pkt_escape(struct mctp_pktbuf *pkt, uint8_t *buf)
@@ -133,7 +133,7 @@
 }
 
 static int mctp_binding_serial_tx(struct mctp_binding *b,
-		struct mctp_pktbuf *pkt)
+				  struct mctp_pktbuf *pkt)
 {
 	struct mctp_binding_serial *serial = binding_to_serial(b);
 	struct mctp_serial_header *hdr;
@@ -172,12 +172,12 @@
 		return mctp_write_all(mctp_serial_write, serial->fd,
 				      &serial->txbuf[0], len);
 
-	return mctp_write_all(serial->tx_fn, serial->tx_fn_data, &serial->txbuf[0],
-			      len);
+	return mctp_write_all(serial->tx_fn, serial->tx_fn_data,
+			      &serial->txbuf[0], len);
 }
 
 static void mctp_serial_finish_packet(struct mctp_binding_serial *serial,
-		bool valid)
+				      bool valid)
 {
 	struct mctp_pktbuf *pkt = serial->rx_pkt;
 	assert(pkt);
@@ -189,13 +189,12 @@
 }
 
 static void mctp_serial_start_packet(struct mctp_binding_serial *serial,
-		uint8_t len)
+				     uint8_t len)
 {
 	serial->rx_pkt = mctp_pktbuf_alloc(&serial->binding, len);
 }
 
-static void mctp_rx_consume_one(struct mctp_binding_serial *serial,
-		uint8_t c)
+static void mctp_rx_consume_one(struct mctp_binding_serial *serial, uint8_t c)
 {
 	struct mctp_pktbuf *pkt = serial->rx_pkt;
 
@@ -226,7 +225,7 @@
 		break;
 	case STATE_WAIT_LEN:
 		if (c > serial->binding.pkt_size ||
-				c < sizeof(struct mctp_hdr)) {
+		    c < sizeof(struct mctp_hdr)) {
 			mctp_prdebug("invalid size %d", c);
 			serial->rx_state = STATE_WAIT_SYNC_START;
 		} else {
@@ -279,8 +278,8 @@
 
 	mctp_prdebug(" -> state: %d", serial->rx_state);
 }
-static void mctp_rx_consume(struct mctp_binding_serial *serial,
-		const void *buf, size_t len)
+static void mctp_rx_consume(struct mctp_binding_serial *serial, const void *buf,
+			    size_t len)
 {
 	size_t i;
 
@@ -317,7 +316,7 @@
 }
 
 int mctp_serial_open_path(struct mctp_binding_serial *serial,
-		const char *device)
+			  const char *device)
 {
 	serial->fd = open(device, O_RDWR);
 	if (serial->fd < 0)
@@ -333,14 +332,14 @@
 #endif
 
 void mctp_serial_set_tx_fn(struct mctp_binding_serial *serial,
-		mctp_serial_tx_fn fn, void *data)
+			   mctp_serial_tx_fn fn, void *data)
 {
 	serial->tx_fn = fn;
 	serial->tx_fn_data = data;
 }
 
-int mctp_serial_rx(struct mctp_binding_serial *serial,
-		const void *buf, size_t len)
+int mctp_serial_rx(struct mctp_binding_serial *serial, const void *buf,
+		   size_t len)
 {
 	mctp_rx_consume(serial, buf, len);
 	return 0;
diff --git a/tests/test_bridge.c b/tests/test_bridge.c
index 923ee82..a37fbd0 100644
--- a/tests/test_bridge.c
+++ b/tests/test_bridge.c
@@ -11,22 +11,22 @@
 #include "test-utils.h"
 
 struct mctp_binding_bridge {
-	struct mctp_binding	binding;
-	int			rx_count;
-	int			tx_count;
-	uint8_t			last_pkt_data;
+	struct mctp_binding binding;
+	int rx_count;
+	int tx_count;
+	uint8_t last_pkt_data;
 };
 
 struct test_ctx {
-	struct mctp			*mctp;
-	struct mctp_binding_bridge	*bindings[2];
+	struct mctp *mctp;
+	struct mctp_binding_bridge *bindings[2];
 };
 
 static int mctp_binding_bridge_tx(struct mctp_binding *b,
-		struct mctp_pktbuf *pkt)
+				  struct mctp_pktbuf *pkt)
 {
-	struct mctp_binding_bridge *binding = container_of(b,
-			struct mctp_binding_bridge, binding);
+	struct mctp_binding_bridge *binding =
+		container_of(b, struct mctp_binding_bridge, binding);
 
 	binding->tx_count++;
 	assert(mctp_pktbuf_size(pkt) == sizeof(struct mctp_hdr) + 1);
@@ -36,14 +36,13 @@
 }
 
 static void mctp_binding_bridge_rx(struct mctp_binding_bridge *binding,
-		uint8_t key)
+				   uint8_t key)
 {
 	struct mctp_pktbuf *pkt;
 	struct mctp_hdr *hdr;
 	uint8_t *buf;
 
-	pkt = mctp_pktbuf_alloc(&binding->binding,
-			sizeof(struct mctp_hdr) + 1);
+	pkt = mctp_pktbuf_alloc(&binding->binding, sizeof(struct mctp_hdr) + 1);
 	assert(pkt);
 
 	hdr = mctp_pktbuf_hdr(pkt);
@@ -83,9 +82,8 @@
 	ctx->bindings[0] = mctp_binding_bridge_init();
 	ctx->bindings[1] = mctp_binding_bridge_init();
 
-	mctp_bridge_busses(ctx->mctp,
-			&ctx->bindings[0]->binding,
-			&ctx->bindings[1]->binding);
+	mctp_bridge_busses(ctx->mctp, &ctx->bindings[0]->binding,
+			   &ctx->bindings[1]->binding);
 
 	mctp_binding_set_tx_enabled(&ctx->bindings[0]->binding, true);
 	mctp_binding_set_tx_enabled(&ctx->bindings[1]->binding, true);
diff --git a/tests/test_eid.c b/tests/test_eid.c
index 5c089ad..2fbbd5a 100644
--- a/tests/test_eid.c
+++ b/tests/test_eid.c
@@ -10,15 +10,15 @@
 #include "test-utils.h"
 
 struct test_ctx {
-	struct mctp			*mctp;
-	struct mctp_binding_test	*binding;
-	int				rx_count;
-	mctp_eid_t			src_eid;
+	struct mctp *mctp;
+	struct mctp_binding_test *binding;
+	int rx_count;
+	mctp_eid_t src_eid;
 };
 
-static void
-test_rx(uint8_t eid, bool tag_owner __unused, uint8_t msg_tag __unused,
-	void *data, void *msg __unused, size_t len __unused)
+static void test_rx(uint8_t eid, bool tag_owner __unused,
+		    uint8_t msg_tag __unused, void *data, void *msg __unused,
+		    size_t len __unused)
 {
 	struct test_ctx *ctx = data;
 
@@ -29,8 +29,7 @@
 	ctx->src_eid = eid;
 }
 
-static void create_packet(struct mctp_hdr *pkt,
-		mctp_eid_t src, mctp_eid_t dest)
+static void create_packet(struct mctp_hdr *pkt, mctp_eid_t src, mctp_eid_t dest)
 {
 	memset(pkt, 0, sizeof(*pkt));
 	pkt->src = src;
@@ -45,8 +44,8 @@
 	const mctp_eid_t remote_eid = 9;
 	const mctp_eid_t other_eid = 10;
 	struct {
-		struct mctp_hdr	hdr;
-		uint8_t		payload[1];
+		struct mctp_hdr hdr;
+		uint8_t payload[1];
 	} pktbuf;
 
 	mctp_test_stack_init(&ctx->mctp, &ctx->binding, local_eid);
diff --git a/tests/test_seq.c b/tests/test_seq.c
index e128457..22242ba 100644
--- a/tests/test_seq.c
+++ b/tests/test_seq.c
@@ -14,16 +14,15 @@
 #endif
 
 struct test_ctx {
-	struct mctp			*mctp;
-	struct mctp_binding_test	*binding;
-	int				rx_count;
-	uint8_t				rx_data[4];
-	size_t				rx_len;
+	struct mctp *mctp;
+	struct mctp_binding_test *binding;
+	int rx_count;
+	uint8_t rx_data[4];
+	size_t rx_len;
 };
 
-static void
-test_rx(uint8_t eid __unused, bool tag_owner __unused,
-	uint8_t msg_tag __unused, void *data, void *msg, size_t len)
+static void test_rx(uint8_t eid __unused, bool tag_owner __unused,
+		    uint8_t msg_tag __unused, void *data, void *msg, size_t len)
 {
 	struct test_ctx *ctx = data;
 
@@ -40,10 +39,10 @@
 #define SEQ(x) (x << MCTP_HDR_SEQ_SHIFT)
 
 struct test {
-	int		n_packets;
-	uint8_t		flags_seq_tags[4];
-	int		exp_rx_count;
-	size_t		exp_rx_len;
+	int n_packets;
+	uint8_t flags_seq_tags[4];
+	int exp_rx_count;
+	size_t exp_rx_len;
 } tests[] = {
 	{
 		/* single packet */
@@ -102,8 +101,8 @@
 	const mctp_eid_t local_eid = 8;
 	const mctp_eid_t remote_eid = 9;
 	struct {
-		struct mctp_hdr	hdr;
-		uint8_t		payload[1];
+		struct mctp_hdr hdr;
+		uint8_t payload[1];
 	} pktbuf;
 	int i;
 
@@ -121,8 +120,7 @@
 		pktbuf.hdr.flags_seq_tag = test->flags_seq_tags[i];
 		pktbuf.payload[0] = i;
 
-		mctp_binding_test_rx_raw(ctx->binding,
-				&pktbuf, sizeof(pktbuf));
+		mctp_binding_test_rx_raw(ctx->binding, &pktbuf, sizeof(pktbuf));
 	}
 
 	assert(ctx->rx_count == test->exp_rx_count);
@@ -136,7 +134,6 @@
 	mctp_destroy(ctx->mctp);
 }
 
-
 int main(void)
 {
 	struct test_ctx ctx;
diff --git a/utils/mctp-demux-daemon.c b/utils/mctp-demux-daemon.c
index c356769..f9893bb 100644
--- a/utils/mctp-demux-daemon.c
+++ b/utils/mctp-demux-daemon.c
@@ -54,24 +54,24 @@
 };
 
 struct client {
-	bool		active;
-	int		sock;
-	uint8_t		type;
+	bool active;
+	int sock;
+	uint8_t type;
 };
 
 struct ctx {
-	struct mctp	*mctp;
-	struct binding	*binding;
-	bool		verbose;
-	int		local_eid;
-	void		*buf;
-	size_t		buf_size;
+	struct mctp *mctp;
+	struct binding *binding;
+	bool verbose;
+	int local_eid;
+	void *buf;
+	size_t buf_size;
 
-	int		sock;
-	struct pollfd	*pollfds;
+	int sock;
+	struct pollfd *pollfds;
 
-	struct client	*clients;
-	int		n_clients;
+	struct client *clients;
+	int n_clients;
 
 	struct {
 		struct capture binding;
@@ -99,16 +99,16 @@
 		close(client->sock);
 
 		ctx->n_clients--;
-		memmove(&ctx->clients[i], &ctx->clients[i+1],
-				(ctx->n_clients - i) * sizeof(*ctx->clients));
+		memmove(&ctx->clients[i], &ctx->clients[i + 1],
+			(ctx->n_clients - i) * sizeof(*ctx->clients));
 		ctx->clients = realloc(ctx->clients,
-				ctx->n_clients * sizeof(*ctx->clients));
+				       ctx->n_clients * sizeof(*ctx->clients));
 	}
 }
 
-static void
-rx_message(uint8_t eid, bool tag_owner __unused, uint8_t msg_tag __unused,
-	   void *data, void *msg, size_t len)
+static void rx_message(uint8_t eid, bool tag_owner __unused,
+		       uint8_t msg_tag __unused, void *data, void *msg,
+		       size_t len)
 {
 	struct ctx *ctx = data;
 	struct iovec iov[2];
@@ -124,7 +124,7 @@
 
 	if (ctx->verbose)
 		fprintf(stderr, "MCTP message received: len %zd, type %d\n",
-				len, type);
+			len, type);
 
 	memset(&msghdr, 0, sizeof(msghdr));
 	msghdr.msg_iov = iov;
@@ -152,13 +152,12 @@
 
 	if (removed)
 		client_remove_inactive(ctx);
-
 }
 
 static int binding_null_init(struct mctp *mctp __unused,
-		struct binding *binding __unused,
-		mctp_eid_t eid __unused,
-		int n_params, char * const *params __unused)
+			     struct binding *binding __unused,
+			     mctp_eid_t eid __unused, int n_params,
+			     char *const *params __unused)
 {
 	if (n_params != 0) {
 		warnx("null binding doesn't accept parameters");
@@ -168,7 +167,8 @@
 }
 
 static int binding_serial_init(struct mctp *mctp, struct binding *binding,
-		mctp_eid_t eid, int n_params, char * const *params)
+			       mctp_eid_t eid, int n_params,
+			       char *const *params)
 {
 	struct mctp_binding_serial *serial;
 	const char *path;
@@ -207,8 +207,8 @@
 }
 
 static int binding_astlpc_init(struct mctp *mctp, struct binding *binding,
-		mctp_eid_t eid, int n_params,
-		char * const *params __attribute__((unused)))
+			       mctp_eid_t eid, int n_params,
+			       char *const *params __attribute__((unused)))
 {
 	struct mctp_binding_astlpc *astlpc;
 
@@ -249,26 +249,24 @@
 	return mctp_astlpc_poll(binding->data);
 }
 
-struct binding bindings[] = {
-	{
-		.name = "null",
-		.init = binding_null_init,
-	},
-	{
-		.name = "serial",
-		.init = binding_serial_init,
-		.destroy = NULL,
-		.init_pollfd = binding_serial_init_pollfd,
-		.process = binding_serial_process,
-	},
-	{
-		.name = "astlpc",
-		.init = binding_astlpc_init,
-		.destroy = binding_astlpc_destroy,
-		.init_pollfd = binding_astlpc_init_pollfd,
-		.process = binding_astlpc_process,
-	}
-};
+struct binding bindings[] = { {
+				      .name = "null",
+				      .init = binding_null_init,
+			      },
+			      {
+				      .name = "serial",
+				      .init = binding_serial_init,
+				      .destroy = NULL,
+				      .init_pollfd = binding_serial_init_pollfd,
+				      .process = binding_serial_process,
+			      },
+			      {
+				      .name = "astlpc",
+				      .init = binding_astlpc_init,
+				      .destroy = binding_astlpc_destroy,
+				      .init_pollfd = binding_astlpc_init_pollfd,
+				      .process = binding_astlpc_process,
+			      } };
 
 struct binding *binding_lookup(const char *name)
 {
@@ -301,7 +299,7 @@
 	}
 
 	rc = bind(ctx->sock, (struct sockaddr *)&addr,
-			sizeof(addr.sun_family) + namelen);
+		  sizeof(addr.sun_family) + namelen);
 	if (rc) {
 		warn("can't bind socket");
 		goto err_close;
@@ -330,10 +328,10 @@
 		return -1;
 
 	ctx->n_clients++;
-	ctx->clients = realloc(ctx->clients,
-			ctx->n_clients * sizeof(struct client));
+	ctx->clients =
+		realloc(ctx->clients, ctx->n_clients * sizeof(struct client));
 
-	client = &ctx->clients[ctx->n_clients-1];
+	client = &ctx->clients[ctx->n_clients - 1];
 	memset(client, 0, sizeof(*client));
 	client->active = true;
 	client->sock = fd;
@@ -361,7 +359,7 @@
 		}
 		if (ctx->verbose)
 			fprintf(stderr, "client[%d] registered for type %u\n",
-					idx, type);
+				idx, type);
 		client->type = type;
 		return 0;
 	}
@@ -407,11 +405,9 @@
 	eid = *(uint8_t *)ctx->buf;
 
 	if (ctx->verbose)
-		fprintf(stderr,
-			"client[%d] sent message: dest 0x%02x len %d\n",
+		fprintf(stderr, "client[%d] sent message: dest 0x%02x len %d\n",
 			idx, eid, rc - 1);
 
-
 	if (eid == ctx->local_eid)
 		rx_message(eid, MCTP_MESSAGE_TO_DST, 0, ctx, ctx->buf + 1,
 			   rc - 1);
@@ -425,8 +421,8 @@
 	return rc;
 }
 
-static int binding_init(struct ctx *ctx, const char *name,
-		int argc, char * const *argv)
+static int binding_init(struct ctx *ctx, const char *name, int argc,
+			char *const *argv)
 {
 	int rc;
 
@@ -436,8 +432,8 @@
 		return -1;
 	}
 
-	rc = ctx->binding->init(ctx->mctp, ctx->binding, ctx->local_eid,
-			argc, argv);
+	rc = ctx->binding->init(ctx->mctp, ctx->binding, ctx->local_eid, argc,
+				argv);
 	return rc;
 }
 
@@ -490,13 +486,13 @@
 			int i;
 
 			ctx->pollfds = realloc(ctx->pollfds,
-					(ctx->n_clients + FD_NR) *
-						sizeof(struct pollfd));
+					       (ctx->n_clients + FD_NR) *
+						       sizeof(struct pollfd));
 
 			for (i = 0; i < ctx->n_clients; i++) {
-				ctx->pollfds[FD_NR+i].fd =
+				ctx->pollfds[FD_NR + i].fd =
 					ctx->clients[i].sock;
-				ctx->pollfds[FD_NR+i].events = POLLIN;
+				ctx->pollfds[FD_NR + i].events = POLLIN;
 			}
 			clients_changed = false;
 		}
@@ -541,7 +537,7 @@
 		}
 
 		for (i = 0; i < ctx->n_clients; i++) {
-			if (!ctx->pollfds[FD_NR+i].revents)
+			if (!ctx->pollfds[FD_NR + i].revents)
 				continue;
 
 			rc = client_process_recv(ctx, i);
@@ -560,7 +556,6 @@
 			client_remove_inactive(ctx);
 	}
 
-
 	free(ctx->pollfds);
 
 	return rc;
@@ -586,7 +581,7 @@
 		fprintf(stderr, "  %s\n", bindings[i].name);
 }
 
-int main(int argc, char * const *argv)
+int main(int argc, char *const *argv)
 {
 	struct ctx *ctx, _ctx;
 	int rc;
@@ -667,7 +662,8 @@
 	if (ctx->pcap.binding.path) {
 		rc = capture_prepare(&ctx->pcap.binding);
 		if (rc == -1) {
-			fprintf(stderr, "Failed to initialise capture: %d\n", rc);
+			fprintf(stderr, "Failed to initialise capture: %d\n",
+				rc);
 			rc = EXIT_FAILURE;
 			goto cleanup_mctp;
 		}
@@ -679,13 +675,15 @@
 	if (ctx->pcap.socket.path) {
 		rc = capture_prepare(&ctx->pcap.socket);
 		if (rc == -1) {
-			fprintf(stderr, "Failed to initialise capture: %d\n", rc);
+			fprintf(stderr, "Failed to initialise capture: %d\n",
+				rc);
 			rc = EXIT_FAILURE;
 			goto cleanup_pcap_binding;
 		}
 	}
 
-	rc = binding_init(ctx, argv[optind], argc - optind - 1, argv + optind + 1);
+	rc = binding_init(ctx, argv[optind], argc - optind - 1,
+			  argv + optind + 1);
 	if (rc) {
 		fprintf(stderr, "Failed to initialise binding: %d\n", rc);
 		rc = EXIT_FAILURE;
@@ -720,5 +718,4 @@
 cleanup_mctp:
 
 	return rc;
-
 }