]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Print ssize_t as %zd
authorLuca Boccassi <bluca@debian.org>
Sat, 8 Jul 2023 15:21:37 +0000 (16:21 +0100)
committerLuca Boccassi <bluca@debian.org>
Mon, 10 Jul 2023 09:57:16 +0000 (10:57 +0100)
On some architectures (x32) ssize_t is int, not long int.

../src/basic/confidential-virt.c: In function ‘msr’:
../src/basic/confidential-virt.c:133:27: error: format ‘%ld’ expects argument of type ‘long int’, but argument 7 has type ‘ssize_t’ {aka ‘int’} [-Werror=format=]
  133 |                 log_debug("Short read %ld bytes from MSR device %s (index %" PRIu64 "), ignoring",
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  134 |                           rv,
      |                           ~~
      |                           |
      |                           ssize_t {aka int}
../src/basic/log.h:214:86: note: in definition of macro ‘log_full_errno_zerook’
  214 |                         ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
      |                                                                                      ^~~~~~~~~~~
../src/basic/log.h:242:28: note: in expansion of macro ‘log_full’
  242 | #define log_debug(...)     log_full(LOG_DEBUG,   __VA_ARGS__)
      |                            ^~~~~~~~
../src/basic/confidential-virt.c:133:17: note: in expansion of macro ‘log_debug’
  133 |                 log_debug("Short read %ld bytes from MSR device %s (index %" PRIu64 "), ignoring",
      |                 ^~~~~~~~~
../src/basic/confidential-virt.c:133:41: note: format string is defined here
  133 |                 log_debug("Short read %ld bytes from MSR device %s (index %" PRIu64 "), ignoring",
      |                                       ~~^
      |                                         |
      |                                         long int
      |                                       %d

src/basic/confidential-virt.c

index 3d4e9eac3311eaeb26ba629364269f86fa9a3906..e00576a7134358797018289fff3d7f562874c047 100644 (file)
@@ -130,7 +130,7 @@ static uint64_t msr(uint64_t index) {
                                 index);
                 return 0;
         } else if (rv != sizeof(ret)) {
-                log_debug("Short read %ld bytes from MSR device %s (index %" PRIu64 "), ignoring",
+                log_debug("Short read %zd bytes from MSR device %s (index %" PRIu64 "), ignoring",
                           rv,
                           MSR_DEVICE,
                           index);