depmod: Fix warning with -D_TIME_BITS=64

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 <lucas.de.marchi@gmail.com>
This commit is contained in:
Lucas De Marchi 2024-06-11 08:02:26 -05:00
parent 68db675078
commit 22c36b7dac

View File

@ -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",