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/mtd/backend.c b/mtd/backend.c
index 921c041..da43072 100644
--- a/mtd/backend.c
+++ b/mtd/backend.c
@@ -31,6 +31,9 @@
#include "mboxd.h"
#include "mtd/backend.h"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpointer-arith"
+
static int mtd_dev_init(struct backend *backend, void *data)
{
const char *path = data;
@@ -121,8 +124,10 @@
/* Flash Functions */
-int flash_validate(struct mbox_context *context, uint32_t offset,
- uint32_t size, bool ro)
+int flash_validate(struct mbox_context *context __attribute__((unused)),
+ uint32_t offset __attribute__((unused)),
+ uint32_t size __attribute__((unused)),
+ bool ro __attribute__((unused)))
{
/* Default behaviour is all accesses are valid */
return 0;
@@ -333,7 +338,7 @@
* Return: A value from enum backend_reset_mode, otherwise a negative
* error code
*/
-static int mtd_reset(struct backend *backend,
+static int mtd_reset(struct backend *backend __attribute__((unused)),
void *buf __attribute__((unused)),
uint32_t count __attribute__((unused)))
{
@@ -370,3 +375,5 @@
return backend_init(master, &with, (void *)path);
}
+
+#pragma GCC diagnostic pop