* [LTP] [PATCH] syscalls/getrusage04:Fix tst_resm() format string for 64bit offset
@ 2023-02-07 8:20 Hui Min Mina Chou
2023-02-13 11:34 ` Richard Palethorpe
0 siblings, 1 reply; 2+ messages in thread
From: Hui Min Mina Chou @ 2023-02-07 8:20 UTC (permalink / raw)
To: ltp, pvorel, chrubis; +Cc: tim609, az70021
This patch fixes the incorrect output on 32bit platform.
The correct way to print tv_usec is cast it to (long long) type and
change the format string to %lld.
Signed-off-by: Hui Min Mina Chou <minachou@andestech.com>
---
testcases/kernel/syscalls/getrusage/getrusage04.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/syscalls/getrusage/getrusage04.c b/testcases/kernel/syscalls/getrusage/getrusage04.c
index 06b576d79..b03bc549b 100644
--- a/testcases/kernel/syscalls/getrusage/getrusage04.c
+++ b/testcases/kernel/syscalls/getrusage/getrusage04.c
@@ -104,8 +104,9 @@ int main(int argc, char *argv[])
tst_count = 0;
i = 0;
SAFE_GETRUSAGE(cleanup, RUSAGE_THREAD, &usage);
- tst_resm(TINFO, "utime:%12luus; stime:%12luus",
- usage.ru_utime.tv_usec, usage.ru_stime.tv_usec);
+ tst_resm(TINFO, "utime:%12lldus; stime:%12lldus",
+ (long long)usage.ru_utime.tv_usec,
+ (long long)usage.ru_stime.tv_usec);
ulast = usage.ru_utime.tv_usec;
slast = usage.ru_stime.tv_usec;
@@ -115,9 +116,9 @@ int main(int argc, char *argv[])
sdelta = usage.ru_stime.tv_usec - slast;
if (udelta > 0 || sdelta > 0) {
i++;
- tst_resm(TINFO, "utime:%12luus; stime:%12luus",
- usage.ru_utime.tv_usec,
- usage.ru_stime.tv_usec);
+ tst_resm(TINFO, "utime:%12lldus; stime:%12lldus",
+ (long long)usage.ru_utime.tv_usec,
+ (long long)usage.ru_stime.tv_usec);
if ((long)udelta > 1000 + (BIAS_MAX * factor_nr)) {
sprintf(msg_string,
"utime increased > %ldus:",
--
2.34.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH] syscalls/getrusage04:Fix tst_resm() format string for 64bit offset
2023-02-07 8:20 [LTP] [PATCH] syscalls/getrusage04:Fix tst_resm() format string for 64bit offset Hui Min Mina Chou
@ 2023-02-13 11:34 ` Richard Palethorpe
0 siblings, 0 replies; 2+ messages in thread
From: Richard Palethorpe @ 2023-02-13 11:34 UTC (permalink / raw)
To: Hui Min Mina Chou; +Cc: tim609, ltp, az70021
Hello,
Hui Min Mina Chou <minachou@andestech.com> writes:
> This patch fixes the incorrect output on 32bit platform.
> The correct way to print tv_usec is cast it to (long long) type and
> change the format string to %lld.
Merged, thanks!
>
> Signed-off-by: Hui Min Mina Chou <minachou@andestech.com>
> ---
> testcases/kernel/syscalls/getrusage/getrusage04.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/getrusage/getrusage04.c b/testcases/kernel/syscalls/getrusage/getrusage04.c
> index 06b576d79..b03bc549b 100644
> --- a/testcases/kernel/syscalls/getrusage/getrusage04.c
> +++ b/testcases/kernel/syscalls/getrusage/getrusage04.c
> @@ -104,8 +104,9 @@ int main(int argc, char *argv[])
> tst_count = 0;
> i = 0;
> SAFE_GETRUSAGE(cleanup, RUSAGE_THREAD, &usage);
> - tst_resm(TINFO, "utime:%12luus; stime:%12luus",
> - usage.ru_utime.tv_usec, usage.ru_stime.tv_usec);
> + tst_resm(TINFO, "utime:%12lldus; stime:%12lldus",
> + (long long)usage.ru_utime.tv_usec,
> + (long long)usage.ru_stime.tv_usec);
> ulast = usage.ru_utime.tv_usec;
> slast = usage.ru_stime.tv_usec;
>
> @@ -115,9 +116,9 @@ int main(int argc, char *argv[])
> sdelta = usage.ru_stime.tv_usec - slast;
> if (udelta > 0 || sdelta > 0) {
> i++;
> - tst_resm(TINFO, "utime:%12luus; stime:%12luus",
> - usage.ru_utime.tv_usec,
> - usage.ru_stime.tv_usec);
> + tst_resm(TINFO, "utime:%12lldus; stime:%12lldus",
> + (long long)usage.ru_utime.tv_usec,
> + (long long)usage.ru_stime.tv_usec);
> if ((long)udelta > 1000 + (BIAS_MAX * factor_nr)) {
> sprintf(msg_string,
> "utime increased > %ldus:",
> --
> 2.34.1
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-13 11:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07 8:20 [LTP] [PATCH] syscalls/getrusage04:Fix tst_resm() format string for 64bit offset Hui Min Mina Chou
2023-02-13 11:34 ` Richard Palethorpe
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.