core: rework variable initialization to avoid gcc warning
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 2 Jun 2022 15:30:35 +0000 (17:30 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 2 Jun 2022 15:31:55 +0000 (17:31 +0200)
commit4c989f89b6d9d6f45072df10f7d42b658d783058
treef5ed191adbef929da8a6ab621688f3f7af780d52
parent1a4e392760cb582c6d18f1cf58c7ca234e5b815c
core: rework variable initialization to avoid gcc warning

In file included from ../src/basic/siphash24.h:11,
                 from ../src/basic/hash-funcs.h:6,
                 from ../src/basic/hashmap.h:8,
                 from ../src/shared/fdset.h:6,
                 from ../src/shared/bpf-program.h:9,
                 from ../src/core/unit.h:11,
                 from ../src/core/all-units.h:4,
                 from ../src/core/manager.c:23:
../src/basic/time-util.h: In function 'manager_dispatch_jobs_in_progress':
../src/basic/time-util.h:140:38: error: 'x' may be used uninitialized [-Werror=maybe-uninitialized]
  140 | #define FORMAT_TIMESPAN(t, accuracy) format_timespan((char[FORMAT_TIMESPAN_MAX]){}, FORMAT_TIMESPAN_MAX, t, accuracy)
      |                                      ^~~~~~~~~~~~~~~
In function 'manager_print_jobs_in_progress',
    inlined from 'manager_dispatch_jobs_in_progress' at ../src/core/manager.c:3007:9:
../src/core/manager.c:219:18: note: 'x' was declared here
  219 |         uint64_t x;
      |                  ^
cc1: all warnings being treated as errors

For some reason this (false positive) warning starts appearing after
-ftrivial-auto-var-init is used.
src/core/manager.c