* [PATCH 1/1] aiodio: Fix format string for 32bit
@ 2022-08-03 17:32 ` Petr Vorel
0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2022-08-03 17:32 UTC (permalink / raw)
To: ltp; +Cc: Petr Vorel, linux-nfs, Cyril Hrubis, Andrea Cervesato
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH 1/1] aiodio: Fix format string for 32bit
@ 2022-08-03 17:32 ` Petr Vorel
0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2022-08-03 17:32 UTC (permalink / raw)
To: ltp; +Cc: linux-nfs
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] aiodio: Fix format string for 32bit
2022-08-03 17:32 ` [LTP] " Petr Vorel
@ 2022-08-05 9:34 ` Cyril Hrubis
-1 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2022-08-05 9:34 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp, linux-nfs, Andrea Cervesato
Hi!
> On 32bit char pointer is int and size_t is unsigned int,
> Cast to long / unsigned long.
Actually char pointer is char pointer, that is not an integer type at
all. If you do a pointer difference you end up with an signed integer
value of ptrdiff_t type, because unlike the result of sizeof(foo)
pointer difference can be negative as well. In C99 ptrdiff_t can be
printed as %td see the "Length modifier" part of man 3 printf.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH 1/1] aiodio: Fix format string for 32bit
@ 2022-08-05 9:34 ` Cyril Hrubis
0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2022-08-05 9:34 UTC (permalink / raw)
To: Petr Vorel; +Cc: linux-nfs, ltp
Hi!
> On 32bit char pointer is int and size_t is unsigned int,
> Cast to long / unsigned long.
Actually char pointer is char pointer, that is not an integer type at
all. If you do a pointer difference you end up with an signed integer
value of ptrdiff_t type, because unlike the result of sizeof(foo)
pointer difference can be negative as well. In C99 ptrdiff_t can be
printed as %td see the "Length modifier" part of man 3 printf.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-05 9:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-03 17:32 [PATCH 1/1] aiodio: Fix format string for 32bit Petr Vorel
2022-08-03 17:32 ` [LTP] " Petr Vorel
2022-08-05 9:34 ` Cyril Hrubis
2022-08-05 9:34 ` [LTP] " Cyril Hrubis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.