From 22c36b7dac45e75efc373e17e08a9cd4dc7dc41c Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Tue, 11 Jun 2024 08:02:26 -0500 Subject: [PATCH] depmod: Fix warning with -D_TIME_BITS=64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Printing time_t, suseconds_t, useconds_t in 32bits with -D_TIME_BITS=64 leads to the following warning: ../tools/depmod.c:2641:61: warning: format ‘%li’ expects argument of type ‘long int’, but argument 6 has type ‘__suseconds64_t’ {aka ‘long long int’} [-Wformat=] 2641 | snprintf(tmp, sizeof(tmp), "%s.%i.%li.%li", itr->name, getpid(), | ~~^ | | | long int | %lli 2642 | tv.tv_usec, tv.tv_sec); | ~~~~~~~~~~ Paper it over by casting the argument to 64 bits and switching to long long. Signed-off-by: Lucas De Marchi --- tools/depmod.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/depmod.c b/tools/depmod.c index 06618fa..8e9e2d1 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -2638,8 +2638,8 @@ static int depmod_output(struct depmod *depmod, FILE *out) int mode = 0644; int fd; - snprintf(tmp, sizeof(tmp), "%s.%i.%li.%li", itr->name, getpid(), - tv.tv_usec, tv.tv_sec); + snprintf(tmp, sizeof(tmp), "%s.%i.%lli.%lli", itr->name, getpid(), + (long long)tv.tv_usec, (long long)tv.tv_sec); fd = openat(dfd, tmp, flags, mode); if (fd < 0) { ERR("openat(%s, %s, %o, %o): %m\n",