Skip to content

Commit

Permalink
tests: lib: notify: Fix uninitialised variable warning
Browse files Browse the repository at this point in the history
This commit sets an initial value of 0 for the `res` variable, whose
pointer is passed to other functions and is not directly assigned
within the calling function.

Note that, when the test completes successfully, the value of the `res`
variable should be set to `423` (the value of `set_res`).

This fixes the "‘res’ may be used uninitialized" warning generated by
the GCC 12.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
  • Loading branch information
stephanosio committed Jul 29, 2022
1 parent 73dccf6 commit dd36024
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/lib/notify/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ZTEST(sys_notify_api, test_spinwait)
{
int rc;
int set_res = 423;
int res;
int res = 0;
sys_notify_generic_callback cb;
struct sys_notify notify;
uint32_t xflags = 0x1234;
Expand Down

0 comments on commit dd36024

Please sign in to comment.