GCC 12.2.1 on Fedora 36 generates the following false-positive
warning that is treated as error with -Werror:
tests/test-list.c: In function 'test_list_construction':
tests/test-list.c:110:9: error: 'values' may be used uninitialized
110 | check_list(&list, values, n);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
For some reason it fails to recognize that array will not
be used if 'n' equals zero.
Fix that by just initializing arrays in full before using,
since it's just a test code.
Signed-off-by: Ilya Maximets <[email protected]>
---
tests/test-list.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/test-list.c b/tests/test-list.c
index 2c6c44448..d278e0395 100644
--- a/tests/test-list.c
+++ b/tests/test-list.c
@@ -20,10 +20,12 @@
#include <config.h>
#undef NDEBUG
#include "openvswitch/list.h"
+#include "openvswitch/util.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "ovstest.h"
+#include "util.h"
/* Sample list element. */
struct element {
@@ -106,6 +108,8 @@ test_list_construction(void)
int values[MAX_ELEMS];
struct ovs_list list;
+ memset(elements, 0, ARRAY_SIZE(elements) * sizeof elements[0]);
+ memset(values, 0, ARRAY_SIZE(values) * sizeof values[0]);
make_list(&list, elements, values, n);
check_list(&list, values, n);
}
--
2.37.3
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev