[PATCH] tools/locktest: Use intmax_t to print off_t

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

 



off_t could be 64bit on 32bit architectures which means using %z printf
modifier is not enough to print it and compiler will complain about
format mismatch

Fixes
| testlk.c:84:66: error: format '%zd' expects argument of type 'signed size_t', but argument 4 has type '__off64_t' {aka 'long long int'} [-Werror=format=]
|    84 |                         printf("%s: conflicting lock by %d on (%zd;%zd)\n",
|       |                                                                ~~^
|       |                                                                  |
|       |                                                                  int
|       |                                                                %lld
|    85 |                                 fname, fl.l_pid, fl.l_start, fl.l_len);
|       |                                                  ~~~~~~~~~~
|       |                                                    |
|       |                                                    __off64_t {aka long long int}

Signed-off-by: Khem Raj <raj.khem@xxxxxxxxx>
---
 tools/locktest/testlk.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/locktest/testlk.c b/tools/locktest/testlk.c
index ea51f788..9d4c88c4 100644
--- a/tools/locktest/testlk.c
+++ b/tools/locktest/testlk.c
@@ -2,6 +2,7 @@
 #include <config.h>
 #endif
 
+#include <stdint.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -81,8 +82,8 @@ main(int argc, char **argv)
 		if (fl.l_type == F_UNLCK) {
 			printf("%s: no conflicting lock\n", fname);
 		} else {
-			printf("%s: conflicting lock by %d on (%zd;%zd)\n",
-				fname, fl.l_pid, fl.l_start, fl.l_len);
+			printf("%s: conflicting lock by %d on (%jd;%jd)\n",
+				fname, fl.l_pid, (intmax_t)fl.l_start, (intmax_t)fl.l_len);
 		}
 		return 0;
 	}
-- 
2.41.0




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux