Message ID | 20220915121730.644549-1-i.maximets@ovn.org |
---|---|
State | Accepted |
Commit | 2e74c44756137d624d8f0e4418e91275849d9622 |
Headers | show |
Series | [ovs-dev,v2] test-list: Fix false-positive build failure with GCC 12. | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/github-robot-_Build_and_Test | success | github build: passed |
ovsrobot/intel-ovs-compilation | success | test: success |
On 15 Sep 2022, at 14:17, Ilya Maximets wrote: > 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 <i.maximets@ovn.org> Thanks for taking the suggestion :) Looks good to me, and compiled without any problem in my environment. Acked-by: Eelco Chaudron <echaudro@redhat.com>
On 9/15/22 15:06, Eelco Chaudron wrote: > > > On 15 Sep 2022, at 14:17, Ilya Maximets wrote: > >> 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 <i.maximets@ovn.org> > > Thanks for taking the suggestion :) Looks good to me, and compiled without any problem in my environment. > > Acked-by: Eelco Chaudron <echaudro@redhat.com> > Thanks! Applied and backported down to 2.13. Best regards, Ilya Maximets.
diff --git a/tests/test-list.c b/tests/test-list.c index 2c6c44448..ac82f2048 100644 --- a/tests/test-list.c +++ b/tests/test-list.c @@ -106,6 +106,8 @@ test_list_construction(void) int values[MAX_ELEMS]; struct ovs_list list; + memset(elements, 0, sizeof elements); + memset(values, 0, sizeof values); make_list(&list, elements, values, n); check_list(&list, values, n); }
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 <i.maximets@ovn.org> --- tests/test-list.c | 2 ++ 1 file changed, 2 insertions(+)