resolve stricter warnings

In order to convert this repository to Meson, we need to make it
compile under `warning_level=3`.  Fix a number of warning classes
across the repository or disable them.

Some fixes are:

* Add missing header files.
* Fully initialize structs as necessary.
* Add `__attribute__((unused))` on parameters as necessary.
* Fix comparisons between signed and unsigned.
* Fix printf specifiers as necessary.
* Avoid case-fallthrough.
* Remove if conditions which are always true.

Some warnings would require extensive code changes, due to their
pervasive use, and so are disabled at a per-file level:
* `-Wpointer-arith`
* `-Wunused-result`

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: If8992b9108f12b39f796ed090ba29868c9f3c627
diff --git a/transport_mbox.c b/transport_mbox.c
index 2759fa5..92d6358 100644
--- a/transport_mbox.c
+++ b/transport_mbox.c
@@ -30,6 +30,9 @@
 #include "windows.h"
 #include "lpc.h"
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpointer-arith"
+
 struct errno_map {
 	int rc;
 	int mbox_errno;
@@ -128,7 +131,8 @@
 }
 
 static int transport_mbox_update_events(struct mbox_context *context,
-					uint8_t events, uint8_t mask)
+					uint8_t events __attribute__((unused)),
+					uint8_t mask)
 {
 	return transport_mbox_flush_events(context, context->bmc_events & mask);
 }
@@ -147,7 +151,8 @@
  * using a virtual pnor.
  */
 static int mbox_handle_reset(struct mbox_context *context,
-			     union mbox_regs *req, struct mbox_msg *resp)
+			     union mbox_regs *req __attribute__((unused)),
+			     struct mbox_msg *resp __attribute__((unused)))
 {
 	return context->protocol->reset(context);
 }
@@ -218,7 +223,8 @@
  * RESP[2:3]: Erase Size (number of blocks)
  */
 static int mbox_handle_flash_info(struct mbox_context *context,
-				  union mbox_regs *req, struct mbox_msg *resp)
+				  union mbox_regs *req __attribute__((unused)),
+				  struct mbox_msg *resp)
 {
 	struct protocol_get_flash_info io;
 	int rc;
@@ -357,7 +363,8 @@
  * ARGS[2:3]: Number to mark dirty (number of blocks)
  */
 static int mbox_handle_dirty_window(struct mbox_context *context,
-				    union mbox_regs *req, struct mbox_msg *resp)
+				    union mbox_regs *req,
+				    struct mbox_msg *resp __attribute__((unused)))
 {
 	struct protocol_mark_dirty io;
 
@@ -386,7 +393,8 @@
  * ARGS[2:3]: Number to erase (number of blocks)
  */
 static int mbox_handle_erase_window(struct mbox_context *context,
-				    union mbox_regs *req, struct mbox_msg *resp)
+				    union mbox_regs *req,
+				    struct mbox_msg *resp __attribute__((unused)))
 {
 	struct protocol_erase io;
 
@@ -419,7 +427,8 @@
  * NONE
  */
 static int mbox_handle_flush_window(struct mbox_context *context,
-				    union mbox_regs *req, struct mbox_msg *resp)
+				    union mbox_regs *req,
+				    struct mbox_msg *resp __attribute__((unused)))
 {
 	struct protocol_flush io = { 0 };
 
@@ -443,7 +452,8 @@
  * ARGS[0]: FLAGS
  */
 static int mbox_handle_close_window(struct mbox_context *context,
-				    union mbox_regs *req, struct mbox_msg *resp)
+				    union mbox_regs *req,
+				    struct mbox_msg *resp __attribute__((unused)))
 {
 	struct protocol_close io = { 0 };
 
@@ -461,7 +471,7 @@
  * ARGS[0]: Bitmap of bits to ack (by clearing)
  */
 static int mbox_handle_ack(struct mbox_context *context, union mbox_regs *req,
-			   struct mbox_msg *resp)
+			   struct mbox_msg *resp __attribute__((unused)))
 {
 	struct protocol_ack io;
 
@@ -581,7 +591,7 @@
 	}
 	MSG_INFO("Writing MBOX response: %u\n", resp.response);
 	len = write(context->fds[MBOX_FD].fd, &resp, sizeof(resp));
-	if (len < sizeof(resp)) {
+	if (len < (ssize_t)sizeof(resp)) {
 		MSG_ERR("Didn't write the full response\n");
 		rc = -errno;
 	}
@@ -610,7 +620,7 @@
 	if (rc < 0) {
 		MSG_ERR("Couldn't read: %s\n", strerror(errno));
 		return -errno;
-	} else if (rc < sizeof(msg->raw)) {
+	} else if (rc < (ssize_t)sizeof(msg->raw)) {
 		MSG_ERR("Short read: %d expecting %zu\n", rc, sizeof(msg->raw));
 		return -1;
 	}
@@ -685,3 +695,5 @@
 {
 	close(context->fds[MBOX_FD].fd);
 }
+
+#pragma GCC diagnostic pop