[LTP] [PATCH] syscalls/getrusage04:Fix tst_resm() format string for 64bit offset

Richard Palethorpe rpalethorpe@suse.de
Mon Feb 13 12:34:05 CET 2023


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.


More information about the ltp mailing list