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/vpnor/backend.cpp b/vpnor/backend.cpp
index b155cf3..606acee 100644
--- a/vpnor/backend.cpp
+++ b/vpnor/backend.cpp
@@ -519,7 +519,7 @@
struct backend backend_get_vpnor(void)
{
- struct backend be = {0};
+ struct backend be = {nullptr, nullptr, 0, 0, 0};
be.ops = &vpnor_ops;
diff --git a/vpnor/backend.h b/vpnor/backend.h
index 0102238..949e5c1 100644
--- a/vpnor/backend.h
+++ b/vpnor/backend.h
@@ -3,6 +3,7 @@
#pragma once
#include <limits.h>
+#include <string.h>
struct mbox_context;
struct vpnor_partition_table;
diff --git a/vpnor/test/dump_flash.cpp b/vpnor/test/dump_flash.cpp
index 2d5dc5d..1c2e865 100644
--- a/vpnor/test/dump_flash.cpp
+++ b/vpnor/test/dump_flash.cpp
@@ -18,8 +18,8 @@
struct test_context
{
- uint8_t seq;
- struct mbox_context* ctx;
+ uint8_t seq = 0;
+ struct mbox_context* ctx = nullptr;
};
// Configure the system and the paritions such that we eventually request a
@@ -60,7 +60,7 @@
{
namespace test = openpower::virtual_pnor::test;
- struct test_context _tctx = {0}, *tctx = &_tctx;
+ test_context _tctx{}, *tctx = &_tctx;
size_t len;
size_t pos;
int rc;