]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Cast st_dev to dev_t when printing
authorLuca Boccassi <bluca@debian.org>
Sat, 8 Jul 2023 15:35:00 +0000 (16:35 +0100)
committerLuca Boccassi <bluca@debian.org>
Mon, 10 Jul 2023 10:39:15 +0000 (11:39 +0100)
st_dev is not the same as dev_t, and on O32 architectures like
mipsel it's an unsigned long, but dev_t is still unsigned long long,
so they don't match and compilation fails:

../src/journal/cat.c: In function ‘run’:
../src/basic/format-util.h:46:19: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘long unsigned int’ [-Werror=format=]
   46 | #  define DEV_FMT "%" PRIu64
      |                   ^~~
../src/journal/cat.c:168:34: note: in expansion of macro ‘DEV_FMT’
  168 |                 if (asprintf(&s, DEV_FMT ":" INO_FMT, st.st_dev, st.st_ino) < 0)
      |                                  ^~~~~~~
In file included from ../src/systemd/sd-journal.h:20,
                 from ../src/journal/cat.c:11:
/usr/include/inttypes.h:105:41: note: format string is defined here
  105 | # define PRIu64         __PRI64_PREFIX "u"

src/journal/cat.c

index d3f7785ad3409fbe9ef0e4b62683c5878f5b3a69..609ddbaf6b4c37c5bb81755668fe8610dd50c5da 100644 (file)
@@ -165,7 +165,7 @@ static int run(int argc, char *argv[]) {
                                                "Failed to fstat(%s): %m",
                                                FORMAT_PROC_FD_PATH(STDERR_FILENO));
 
-                if (asprintf(&s, DEV_FMT ":" INO_FMT, st.st_dev, st.st_ino) < 0)
+                if (asprintf(&s, DEV_FMT ":" INO_FMT, (dev_t)st.st_dev, st.st_ino) < 0)
                         return log_oom();
 
                 if (setenv("JOURNAL_STREAM", s, /* overwrite = */ true) < 0)