tools/locktest: Use intmax_t to print off_t
Subsystems (2)
PATCH 1/1 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}Signed-off-by Khem Raj <[email protected]>
--- tools/locktest/testlk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/locktest/testlk.c +3 -2
@@ -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 ; }
Signature · 1 line
2.41.0