summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/nfs-utils/nfs-utils/0001-tools-locktest-Use-intmax_t-to-print-off_t.patch
blob: 7d903e04bc163060ee857786308c96b45d3892a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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