]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iproute2: fix build failure on sparc due to -Wformat and tv_usec
authorAndreas Henriksson <andreas@fatal.se>
Sat, 18 May 2013 06:18:51 +0000 (06:18 +0000)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 4 Jun 2013 02:56:25 +0000 (19:56 -0700)
tv_usec is "suseconds_t" which is apparently usually
a signed long, but sometimes not....
Change the printf modifier to use signed and
cast the tv_usec to long in case it's not already long.

gcc -Wall -Wstrict-prototypes -Werror -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -fPIC   -c -o utils.o utils.c
utils.c: In function 'print_timestamp':
utils.c:802:2: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type '__suseconds_t' [-Werror=format]
cc1: all warnings being treated as errors

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
lib/utils.c

index bcd6002333df85f773021883fb2bed705e3c5173..dae1b51812e0b9b03fc5d58337c838d45f91b8f1 100644 (file)
@@ -799,7 +799,7 @@ int print_timestamp(FILE *fp)
 
        tstr = asctime(localtime(&tv.tv_sec));
        tstr[strlen(tstr)-1] = 0;
-       fprintf(fp, "Timestamp: %s %lu usec\n", tstr, tv.tv_usec);
+       fprintf(fp, "Timestamp: %s %ld usec\n", tstr, (long)tv.tv_usec);
        return 0;
 }