Cast st_dev to dev_t when printing

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"
This commit is contained in:
Luca Boccassi
2023-07-10 11:39:15 +01:00
parent f692c4a6cf
commit 5bf36ce524
+1 -1
View 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)