gcc (13.0.1 20230421 (Red Hat 13.0.1-0)) complains: ../test/libndctl.c: In function ‘check_commands’: ../test/libndctl.c:2313:20: warning: storing the address of local variable ‘__check_dimm_cmds’ in ‘check_cmds’ [-Wdangling-poiter=]
...fix it by showing the compiler that the local setting does not escape the function. Signed-off-by: Dan Williams <[email protected]> --- test/libndctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/libndctl.c b/test/libndctl.c index 51245cf4ea98..858110c4dbc1 100644 --- a/test/libndctl.c +++ b/test/libndctl.c @@ -2322,7 +2322,8 @@ static int check_commands(struct ndctl_bus *bus, struct ndctl_dimm *dimm, ndctl_bus_get_provider(bus), ndctl_dimm_get_id(dimm), ndctl_dimm_get_cmd_name(dimm, i)); - return -ENXIO; + rc = -ENXIO; + break; } if (!check->check_fn) @@ -2331,6 +2332,7 @@ static int check_commands(struct ndctl_bus *bus, struct ndctl_dimm *dimm, if (rc) break; } + check_cmds = NULL; for (i = 0; i < ARRAY_SIZE(__check_dimm_cmds); i++) { if (__check_dimm_cmds[i].cmd)
