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/protocol.c b/protocol.c
index ab1c332..4efa83a 100644
--- a/protocol.c
+++ b/protocol.c
@@ -14,6 +14,9 @@
#include "protocol.h"
#include "windows.h"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpointer-arith"
+#pragma GCC diagnostic ignored "-Wunused-result"
#define BLOCK_SIZE_SHIFT_V1 12 /* 4K */
@@ -368,8 +371,9 @@
static int generic_flush(struct mbox_context *context)
{
- int rc, i, offset, count;
+ int rc, offset, count;
uint8_t prev;
+ size_t i;
offset = 0;
count = 0;
@@ -617,8 +621,8 @@
return 0;
}
-static int protocol_v2_flush(struct mbox_context *context,
- struct protocol_flush *io)
+static int protocol_v2_flush(struct mbox_context *context __attribute__((unused)),
+ struct protocol_flush *io __attribute__((unused)))
{
if (!(context->current && context->current_is_write)) {
MSG_ERR("Tried to call flush without open write window\n");
@@ -705,7 +709,7 @@
return 0;
}
-void protocol_free(struct mbox_context *context)
+void protocol_free(struct mbox_context *context __attribute__((unused)))
{
return;
}
@@ -759,3 +763,5 @@
return 0;
}
+
+#pragma GCC diagnostic pop