]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
report-cgroup: use errno_or_else in one more place 41988/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Tue, 12 May 2026 10:38:22 +0000 (12:38 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Tue, 12 May 2026 20:56:06 +0000 (22:56 +0200)
Old gcc is confused about initialization:
In function ‘io_read_send’,
    inlined from ‘walk_cgroups’ at ../src/report/report-cgroup.c:288:24:
../src/report/report-cgroup.c:167:21: error: ‘values[0]’ may be used uninitialized [-Werror=maybe-uninitialized]
  167 |                 r = metric_build_send_unsigned(mf + i, link, unit, values[i], /* fields= */ NULL);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Maybe this helps.

src/report/report-cgroup.c

index 48fcbb5a647beff365febc0998de75ec6ae69c49..240f09f9f2a4f02c11b3c6a62ce0138abfcf8070 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "alloc-util.h"
 #include "cgroup-util.h"
+#include "errno-util.h"
 #include "extract-word.h"
 #include "fd-util.h"
 #include "fileio.h"
@@ -97,7 +98,7 @@ static int io_stat_parse(const char *cgroup_path, uint64_t ret[static 2]) {
 
         _cleanup_fclose_ FILE *f = fopen(path, "re");
         if (!f)
-                return -errno;
+                return errno_or_else(EIO);
 
         for (;;) {
                 _cleanup_free_ char *line = NULL;