[LTP] [PATCH 1/1] aiodio: Fix format string for 32bit

Petr Vorel pvorel@suse.cz
Wed Aug 3 19:32:11 CEST 2022


On 32bit char pointer is int and size_t is unsigned int,
Cast to long / unsigned long.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi,

IMHO %zu is C99, we don't define -std and my gcc 12 uses by default -std=gnu17.
Therefore I'm surprised that %zu does not work.

Based on Andrea patch:
https://patchwork.ozlabs.org/project/ltp/patch/20220803120905.3107-1-andrea.cervesato@suse.com/

Kind regards,
Petr

 testcases/kernel/io/ltp-aiodio/common.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/io/ltp-aiodio/common.h b/testcases/kernel/io/ltp-aiodio/common.h
index d9cbd8611..283f7f5db 100644
--- a/testcases/kernel/io/ltp-aiodio/common.h
+++ b/testcases/kernel/io/ltp-aiodio/common.h
@@ -19,7 +19,7 @@ static inline char *check_zero(char *buf, int size)
 		if (*buf != 0) {
 			tst_res(TINFO,
 				"non zero buffer at buf[%lu] => 0x%02x,%02x,%02x,%02x",
-				buf - p, (unsigned int)buf[0],
+				(long)(buf - p), (unsigned int)buf[0],
 				size > 1 ? (unsigned int)buf[1] : 0,
 				size > 2 ? (unsigned int)buf[2] : 0,
 				size > 3 ? (unsigned int)buf[3] : 0);
@@ -78,8 +78,8 @@ static inline void io_read(const char *filename, int filesize, volatile int *run
 			if (r > 0) {
 				bufoff = check_zero(buff, r);
 				if (bufoff) {
-					tst_res(TINFO, "non-zero read at offset %zu",
-						offset + (bufoff - buff));
+					tst_res(TINFO, "non-zero read at offset %lu",
+						(long int)offset + (bufoff - buff));
 					break;
 				}
 				offset += r;
-- 
2.37.1



More information about the ltp mailing list