]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
depmod: Fix warning with -D_TIME_BITS=64
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 11 Jun 2024 13:02:26 +0000 (08:02 -0500)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 11 Jun 2024 13:15:30 +0000 (08:15 -0500)
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>
tools/depmod.c

index 06618faf8c21805fda4a2cde1ae39efb2d23546c..8e9e2d1195e1aac4131d88ea53338b1a4aaf7353 100644 (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",