[Devel] [PATCH vz10 01/15] selftests/cgroup: fix -Wmaybe-uninitialized warning in test_numa_migrate
Vasileios Almpanis
vasileios.almpanis at virtuozzo.com
Mon Mar 30 11:25:05 MSK 2026
Reviewed-by: Vasileios Almpanis <vasileios.almpanis at virtuozzo.com>
On 3/23/26 9:31 PM, Konstantin Khorenko wrote:
> test_numa_migrate.c: In function 'parse_memory_numa_stat.isra':
> test_numa_migrate.c:521:34: warning: 'node' may be used uninitialized [-Wmaybe-uninitialized]
> 521 | node_stat[node] = node_bytes;
> | ^
> test_numa_migrate.c:485:16: note: 'node' was declared here
> 485 | size_t node;
> | ^~~~
>
> Initialize 'node' to 0 to silence the -Wmaybe-uninitialized warning.
> The variable is always set inside the loop before use in the else branch,
> but GCC cannot prove this statically.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-127529
> Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
>
> Feature: fix selftests
> ---
> tools/testing/selftests/cgroup/test_numa_migrate.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/selftests/cgroup/test_numa_migrate.c b/tools/testing/selftests/cgroup/test_numa_migrate.c
> index e5119da4fc01..5f4a55684f61 100644
> --- a/tools/testing/selftests/cgroup/test_numa_migrate.c
> +++ b/tools/testing/selftests/cgroup/test_numa_migrate.c
> @@ -510,6 +510,7 @@ static int parse_memory_numa_stat(struct test_context *ctx, const char *cgroup,
> token = strtok(stat_str, node_delim);
> /* skip the key itself */
> token = strtok(NULL, node_delim);
> + node = 0;
> step = 1;
> while (token != NULL) {
> if (step % 2) {
More information about the Devel
mailing list