2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 01:51:26 +00:00

test-list: Fix false-positive build failure with GCC 12.

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.

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
Ilya Maximets 2022-09-15 14:17:30 +02:00
parent a93d0b74dd
commit 2e74c44756

View File

@ -106,6 +106,8 @@ test_list_construction(void)
int values[MAX_ELEMS]; int values[MAX_ELEMS];
struct ovs_list list; struct ovs_list list;
memset(elements, 0, sizeof elements);
memset(values, 0, sizeof values);
make_list(&list, elements, values, n); make_list(&list, elements, values, n);
check_list(&list, values, n); check_list(&list, values, n);
} }