Skip to contentSkip to conversation

selftests/vDSO: fix -Wformat warning in vdso_test_correctness

PATCH In review Tobias Klauser 2 participants 2 messages Dec 17, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/vDSO: fix -Wformat warning in vdso_test_correctness

Fix the following -Wformat warnings in vdso_test_correctness.c:

vdso_test_correctness.c: In function ‘test_one_clock_gettime64’:
vdso_test_correctness.c:352:21: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘long long int’ [-Wformat=]

  352 |  printf("\t%llu.%09ld %llu.%09ld %llu.%09ld\n",
      |                 ~~~~^
      |                     |
      |                     long int
      |                 %09lld
  353 |         (unsigned long long)start.tv_sec, start.tv_nsec,
      |                                           ~~~~~~~~~~~~~
      |                                                |
      |                                                long long int
vdso_test_correctness.c:352:32: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘long long int’ [-Wformat=]
  352 |  printf("\t%llu.%09ld %llu.%09ld %llu.%09ld\n",
      |                            ~~~~^
      |                                |
      |                                long int
      |                            %09lld
  353 |         (unsigned long long)start.tv_sec, start.tv_nsec,
  354 |         (unsigned long long)vdso.tv_sec, vdso.tv_nsec,
      |                                          ~~~~~~~~~~~~
      |                                              |
      |                                              long long int

vdso_test_correctness.c:352:43: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 7 has type ‘long long int’ [-Wformat=]

The tv_sec member of __kernel_timespec is long long, both in uapi/linux/time_types.h and locally in vdso_test_correctness.c.

---
 tools/testing/selftests/vDSO/vdso_test_correctness.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vDSO/vdso_test_correctness.c +1 -1
index 5029ef9b228c..c4aea794725a 100644
@@ -349,7 +349,7 @@ static void test_one_clock_gettime64(int clock, const char *name)
 		return;
 	}
 
-	printf("\t%llu.%09ld %llu.%09ld %llu.%09ld\n",
+	printf("\t%llu.%09lld %llu.%09lld %llu.%09lld\n",
 	       (unsigned long long)start.tv_sec, start.tv_nsec,
 	       (unsigned long long)vdso.tv_sec, vdso.tv_nsec,
 	       (unsigned long long)end.tv_sec, end.tv_nsec);
Signature · 1 line
2.29.0
maintainer
#1 lore raw
Quoted 39 lines · Tobias Klauser

Fix the following -Wformat warnings in vdso_test_correctness.c:

vdso_test_correctness.c: In function ‘test_one_clock_gettime64’:
vdso_test_correctness.c:352:21: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘long long int’ [-Wformat=]

   352 |  printf("\t%llu.%09ld %llu.%09ld %llu.%09ld\n",
       |                 ~~~~^
       |                     |
       |                     long int
       |                 %09lld
   353 |         (unsigned long long)start.tv_sec, start.tv_nsec,
       |                                           ~~~~~~~~~~~~~
       |                                                |
       |                                                long long int
vdso_test_correctness.c:352:32: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘long long int’ [-Wformat=]
   352 |  printf("\t%llu.%09ld %llu.%09ld %llu.%09ld\n",
       |                            ~~~~^
       |                                |
       |                                long int
       |                            %09lld
   353 |         (unsigned long long)start.tv_sec, start.tv_nsec,
   354 |         (unsigned long long)vdso.tv_sec, vdso.tv_nsec,
       |                                          ~~~~~~~~~~~~
       |                                              |
       |                                              long long int

vdso_test_correctness.c:352:43: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 7 has type ‘long long int’ [-Wformat=]

The tv_sec member of __kernel_timespec is long long, both in uapi/linux/time_types.h and locally in vdso_test_correctness.c.

---
  tools/testing/selftests/vDSO/vdso_test_correctness.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vDSO/vdso_test_correctness.c +0 -0
index 5029ef9b228c..c4aea794725a 100644

tools/testing/selftests/vDSO/vdso_test_correctness.c static void test_one_clock_gettime64(int clock, const char *name) · line 353

Quoted 6 lines
tools/testing/selftests/vDSO/vdso_test_correctness.c +1 -1
@@ -349,7 +349,7 @@ static void test_one_clock_gettime64(int clock, const char *name)
  		return;
  	}
 
-	printf("\t%llu.%09ld %llu.%09ld %llu.%09ld\n",
+	printf("\t%llu.%09lld %llu.%09lld %llu.%09lld\n",
  	Thanks for the patch.

Thanks for the patch.

Applied to linux-kselftest next

thanks,
-- Shuah