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/test/close_window_v2.c b/test/close_window_v2.c
index 9b646f6..a077a00 100644
--- a/test/close_window_v2.c
+++ b/test/close_window_v2.c
@@ -105,4 +105,4 @@
short_lifetime(ctx);
return 0;
-};
+}
diff --git a/test/create_oversize_window.c b/test/create_oversize_window.c
index 2c842cb..cae128d 100644
--- a/test/create_oversize_window.c
+++ b/test/create_oversize_window.c
@@ -54,4 +54,4 @@
assert(rc == 0);
return rc;
-};
+}
diff --git a/test/create_read_window_v2.c b/test/create_read_window_v2.c
index 4e8d1d2..5bc11e8 100644
--- a/test/create_read_window_v2.c
+++ b/test/create_read_window_v2.c
@@ -59,4 +59,4 @@
assert(rc == 0);
return rc;
-};
+}
diff --git a/test/create_write_window_v2.c b/test/create_write_window_v2.c
index b0e246e..ac51b41 100644
--- a/test/create_write_window_v2.c
+++ b/test/create_write_window_v2.c
@@ -58,4 +58,4 @@
assert(rc == 0);
return rc;
-};
+}
diff --git a/test/create_zero_size_window.c b/test/create_zero_size_window.c
index 3e936d0..b3e8035 100644
--- a/test/create_zero_size_window.c
+++ b/test/create_zero_size_window.c
@@ -54,4 +54,4 @@
assert(rc == 0);
return rc;
-};
+}
diff --git a/test/flash_erase.c b/test/flash_erase.c
index fe80f3b..127bf8c 100644
--- a/test/flash_erase.c
+++ b/test/flash_erase.c
@@ -41,7 +41,7 @@
#define MEM_SIZE 3
#define ERASE_SIZE 1
-int ioctl(int fd, unsigned long request, ...)
+int ioctl(int fd __attribute__((unused)), unsigned long request, ...)
{
va_list ap;
struct erase_info_user *provided, *alloced;
diff --git a/test/flash_write.c b/test/flash_write.c
index c5f998c..d330981 100644
--- a/test/flash_write.c
+++ b/test/flash_write.c
@@ -37,7 +37,7 @@
#define MEM_SIZE 3
#define ERASE_SIZE 1
-int ioctl(int fd, unsigned long request, ...)
+int ioctl(int fd __attribute__((unused)), unsigned long request, ...)
{
va_list ap;
@@ -59,7 +59,7 @@
{
struct mbox_context _context, *context = &_context;
struct backend *backend = &context->backend;
- char src[MEM_SIZE];
+ uint8_t src[MEM_SIZE];
uint8_t *map;
int rc;
diff --git a/test/get_flash_info_v2.c b/test/get_flash_info_v2.c
index 36ef8ac..ec0adea 100644
--- a/test/get_flash_info_v2.c
+++ b/test/get_flash_info_v2.c
@@ -49,4 +49,4 @@
assert(rc == 0);
return rc;
-};
+}
diff --git a/test/implicit_flush.c b/test/implicit_flush.c
index f186d19..41f27c5 100644
--- a/test/implicit_flush.c
+++ b/test/implicit_flush.c
@@ -148,4 +148,4 @@
flush_on_create(ctx);
return 0;
-};
+}
diff --git a/test/mark_read_dirty.c b/test/mark_read_dirty.c
index 766e3dc..75100af 100644
--- a/test/mark_read_dirty.c
+++ b/test/mark_read_dirty.c
@@ -61,4 +61,4 @@
assert(rc == 0);
return rc;
-};
+}
diff --git a/test/mark_write_dirty_v2.c b/test/mark_write_dirty_v2.c
index 0c929fe..91965a8 100644
--- a/test/mark_write_dirty_v2.c
+++ b/test/mark_write_dirty_v2.c
@@ -63,4 +63,4 @@
assert(rc == 0);
return rc;
-};
+}
diff --git a/test/mark_write_erased_v2.c b/test/mark_write_erased_v2.c
index 95cff4b..4a17138 100644
--- a/test/mark_write_erased_v2.c
+++ b/test/mark_write_erased_v2.c
@@ -88,4 +88,4 @@
assert(rc == 0);
return rc;
-};
+}
diff --git a/test/mbox.c b/test/mbox.c
index c224b84..ebd5071 100644
--- a/test/mbox.c
+++ b/test/mbox.c
@@ -28,7 +28,7 @@
void dump_buf(const void *buf, size_t len)
{
const uint8_t *buf8 = buf;
- int i;
+ size_t i;
for (i = 0; i < len; i += STEP) {
int delta;
@@ -38,7 +38,7 @@
delta = len - i;
max = delta > STEP ? STEP : delta;
- printf("0x%08x:\t", i);
+ printf("0x%08zx:\t", i);
for (j = 0; j < max; j++)
printf("0x%02x, ", buf8[i + j]);
@@ -75,7 +75,7 @@
printf("%s:%d: details.st_size: %ld, RESPONSE_OFFSET + len: %ld\n",
__func__, __LINE__, details.st_size, RESPONSE_OFFSET + len);
assert(map != MAP_FAILED);
- assert(details.st_size >= (RESPONSE_OFFSET + len));
+ assert(details.st_size >= (__off_t)(RESPONSE_OFFSET + len));
rc = memcmp(expected, &map[RESPONSE_OFFSET], len);
diff --git a/test/read_window_cycle.c b/test/read_window_cycle.c
index 8220c63..deef2cf 100644
--- a/test/read_window_cycle.c
+++ b/test/read_window_cycle.c
@@ -71,4 +71,4 @@
}
return !(rc == 1);
-};
+}
diff --git a/test/read_window_mark_write_erased.c b/test/read_window_mark_write_erased.c
index 498ac62..f79d993 100644
--- a/test/read_window_mark_write_erased.c
+++ b/test/read_window_mark_write_erased.c
@@ -63,4 +63,4 @@
assert(rc == 0);
return rc;
-};
+}
diff --git a/test/read_window_write_flush.c b/test/read_window_write_flush.c
index 0f1cace..4420976 100644
--- a/test/read_window_write_flush.c
+++ b/test/read_window_write_flush.c
@@ -62,4 +62,4 @@
assert(rc == 0);
return rc;
-};
+}
diff --git a/test/system.c b/test/system.c
index 24fbcdc..babf11d 100644
--- a/test/system.c
+++ b/test/system.c
@@ -11,8 +11,7 @@
#include "linux/aspeed-lpc-ctrl.h"
-static struct aspeed_lpc_ctrl_mapping ctrl = {
-};
+static struct aspeed_lpc_ctrl_mapping ctrl = { .size = 0 };
static struct mtd_info_user mtd = {
.type = MTD_NORFLASH,
diff --git a/test/tmpf.c b/test/tmpf.c
index 483231b..6832f7c 100644
--- a/test/tmpf.c
+++ b/test/tmpf.c
@@ -30,6 +30,5 @@
if (tmpf->fd)
close(tmpf->fd);
- if (tmpf->path)
- unlink(tmpf->path);
+ unlink(tmpf->path);
}
diff --git a/test/write_flush_v2.c b/test/write_flush_v2.c
index b53550d..898b595 100644
--- a/test/write_flush_v2.c
+++ b/test/write_flush_v2.c
@@ -143,4 +143,4 @@
assert(rc == 0);
return rc;
-};
+}