[PATCH] selftests: net: fix warning when compiling selftest/net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When I compile tools/testing/selftests/net/ by
`make -C tools/testing/selftests/net` with gcc (Debian 8.3.0-6) 8.3.0,
it reports the following warnings:

txtimestamp.c: In function 'validate_timestamp':
txtimestamp.c:164:29: warning: format '%lu' expects argument of type
'long unsigned int', but argument 3 has type 'int64_t'
{aka 'long long int'} [-Wformat=]
   fprintf(stderr, "ERROR: %lu us expected between %d and %d\n",
                           ~~^
                           %llu
     cur64 - start64, min_delay, max_delay);
     ~~~~~~~~~~~~~~~
txtimestamp.c: In function '__print_ts_delta_formatted':
txtimestamp.c:173:22: warning: format '%lu' expects argument of type
'long unsigned int', but argument 3 has type 'int64_t'
{aka 'long long int'} [-Wformat=]
   fprintf(stderr, "%lu ns", ts_delta);
                    ~~^      ~~~~~~~~
                    %llu
txtimestamp.c:175:22: warning: format '%lu' expects argument of type
'long unsigned int', but argument 3 has type 'int64_t'
{aka 'long long int'} [-Wformat=]
   fprintf(stderr, "%lu us", ts_delta / NSEC_PER_USEC);
                    ~~^
                    %llu

`int64_t` is the alias for `long long int`. '%lld' is more suitable.

Signed-off-by: Guo Zhengkui <guozhengkui@xxxxxxxx>
---
 tools/testing/selftests/net/txtimestamp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c
index fabb1d555ee5..ab8d0181218f 100644
--- a/tools/testing/selftests/net/txtimestamp.c
+++ b/tools/testing/selftests/net/txtimestamp.c
@@ -161,7 +161,7 @@ static void validate_timestamp(struct timespec *cur, int min_delay)
 	max_delay = min_delay + cfg_delay_tolerance_usec;
 
 	if (cur64 < start64 + min_delay || cur64 > start64 + max_delay) {
-		fprintf(stderr, "ERROR: %lu us expected between %d and %d\n",
+		fprintf(stderr, "ERROR: %lld us expected between %d and %d\n",
 				cur64 - start64, min_delay, max_delay);
 		test_failed = true;
 	}
@@ -170,9 +170,9 @@ static void validate_timestamp(struct timespec *cur, int min_delay)
 static void __print_ts_delta_formatted(int64_t ts_delta)
 {
 	if (cfg_print_nsec)
-		fprintf(stderr, "%lu ns", ts_delta);
+		fprintf(stderr, "%lld ns", ts_delta);
 	else
-		fprintf(stderr, "%lu us", ts_delta / NSEC_PER_USEC);
+		fprintf(stderr, "%lld us", ts_delta / NSEC_PER_USEC);
 }
 
 static void __print_timestamp(const char *name, struct timespec *cur,
-- 
2.20.1




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux