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/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);