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/control_legacy.c b/control_legacy.c
index 2a3461d..c76d1c8 100644
--- a/control_legacy.c
+++ b/control_legacy.c
@@ -41,8 +41,8 @@
  * Resp: NONE
  */
 static int control_legacy_ping(struct mbox_context *context,
-			   struct mbox_dbus_msg *req,
-			   struct mbox_dbus_msg *resp)
+			   struct mbox_dbus_msg *req __attribute__((unused)),
+			   struct mbox_dbus_msg *resp __attribute__((unused)))
 {
 	return control_ping(context);
 }
@@ -55,7 +55,7 @@
  * Resp[0]: Status Code
  */
 static int control_legacy_daemon_state(struct mbox_context *context,
-					  struct mbox_dbus_msg *req,
+					  struct mbox_dbus_msg *req __attribute__((unused)),
 					  struct mbox_dbus_msg *resp)
 {
 	resp->num_args = DAEMON_STATE_NUM_ARGS;
@@ -73,9 +73,10 @@
  * Resp[0]: LPC Bus State Code
  */
 static int control_legacy_lpc_state(struct mbox_context *context,
-				       struct mbox_dbus_msg *req,
+				       struct mbox_dbus_msg *req __attribute__((unused)),
 				       struct mbox_dbus_msg *resp)
 {
+
 	resp->num_args = LPC_STATE_NUM_ARGS;
 	resp->args = calloc(resp->num_args, sizeof(*resp->args));
 	resp->args[0] = control_lpc_state(context);
@@ -92,8 +93,8 @@
  * Resp: NONE
  */
 static int control_legacy_reset(struct mbox_context *context,
-				   struct mbox_dbus_msg *req,
-				   struct mbox_dbus_msg *resp)
+				   struct mbox_dbus_msg *req __attribute__((unused)),
+				   struct mbox_dbus_msg *resp __attribute__((unused)))
 {
 	int rc;
 
@@ -117,8 +118,8 @@
  * Resp: NONE
  */
 static int control_legacy_kill(struct mbox_context *context,
-				  struct mbox_dbus_msg *req,
-				  struct mbox_dbus_msg *resp)
+				  struct mbox_dbus_msg *req __attribute__((unused)),
+				  struct mbox_dbus_msg *resp __attribute__((unused)))
 {
 	return control_kill(context);
 }
@@ -134,8 +135,8 @@
  * Resp: NONE
  */
 static int control_legacy_modified(struct mbox_context *context,
-				      struct mbox_dbus_msg *req,
-				      struct mbox_dbus_msg *resp)
+				      struct mbox_dbus_msg *req __attribute__((unused)),
+				      struct mbox_dbus_msg *resp __attribute__((unused)))
 {
 	return control_modified(context);
 }
@@ -150,8 +151,8 @@
  * Resp: NONE
  */
 static int control_legacy_suspend(struct mbox_context *context,
-				     struct mbox_dbus_msg *req,
-				     struct mbox_dbus_msg *resp)
+				     struct mbox_dbus_msg *req __attribute__((unused)),
+				     struct mbox_dbus_msg *resp __attribute__((unused)))
 {
 	int rc;
 
@@ -173,7 +174,7 @@
  */
 static int control_legacy_resume(struct mbox_context *context,
 				    struct mbox_dbus_msg *req,
-				    struct mbox_dbus_msg *resp)
+				    struct mbox_dbus_msg *resp __attribute__((unused)))
 {
 	int rc;
 
@@ -205,12 +206,13 @@
 };
 
 static int method_cmd(sd_bus_message *m, void *userdata,
-		      sd_bus_error *ret_error)
+		      sd_bus_error *ret_error __attribute__((unused)))
 {
 	struct mbox_dbus_msg req = { 0 }, resp = { 0 };
 	struct mbox_context *context;
 	sd_bus_message *n;
-	int rc, i;
+	int rc;
+	size_t i;
 
 	context = (struct mbox_context *) userdata;
 	if (!context) {
@@ -238,7 +240,7 @@
 	}
 	MSG_DBG("DBUS num_args: %u\n", (unsigned) req.num_args);
 	for (i = 0; i < req.num_args; i++) {
-		MSG_DBG("DBUS arg[%d]: %u\n", i, req.args[i]);
+		MSG_DBG("DBUS arg[%zd]: %u\n", i, req.args[i]);
 	}
 
 	/* Handle the command */
@@ -274,7 +276,7 @@
 	MSG_DBG("DBUS response: %u\n", resp.cmd);
 	MSG_DBG("DBUS num_args: %u\n", (unsigned) resp.num_args);
 	for (i = 0; i < resp.num_args; i++) {
-		MSG_DBG("DBUS arg[%d]: %u\n", i, resp.args[i]);
+		MSG_DBG("DBUS arg[%zd]: %u\n", i, resp.args[i]);
 	}
 
 	rc = sd_bus_send(NULL, n, NULL); /* Send response */