From e2e9251dbeb452f5382179023d8ae18b511167a1 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 25 Jul 2023 23:47:08 -0700
Subject: [PATCH] tools/locktest: Use intmax_t to print off_t

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}

Upstream-Status: Submitted [https://marc.info/?l=linux-nfs&m=169035457128067&w=2]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 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

