[PATCH v7 03/14] tests/getrusage: Correctly use the long types from the rusage struct
Dmitry V. Levin
ldv at altlinux.org
Sun Apr 19 22:02:24 UTC 2020
On Fri, Apr 17, 2020 at 09:47:13AM -0700, Alistair Francis wrote:
> The kernel's rusage struct uses the kernel's __kernel_old_timeval which
> means that even for 32-bit archs with 64-bit time_t (like RV32) the time
> values are 32-bit.
>
> We can fix this by making sure we don't use libc's rusage struct and
> instead use our own with the kernel's old timeval.
>
> Signed-off-by: Alistair Francis <alistair.francis at wdc.com>
> ---
> tests/getrusage.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tests/getrusage.c b/tests/getrusage.c
> index b046fde2..a71f1174 100644
> --- a/tests/getrusage.c
> +++ b/tests/getrusage.c
> @@ -20,9 +20,10 @@
>
> # include "xlat.h"
> # include "xlat/usagewho.h"
> +# include "kernel_rusage.h"
>
> int
> -invoke_print(int who, const char *who_str, struct rusage *usage)
> +invoke_print(int who, const char *who_str, kernel_rusage_t *usage)
This caused build errors on x32:
../../tests-mx32/getrusage.c: In function 'invoke_print':
../../tests-mx32/getrusage.c:30:9: error: format '%lu' expects argument of type 'long unsigned int', but argument 7 has type 'kernel_long_t' {aka 'long long int'} [-Werror=format=]
30 | printf("getrusage(%s, {ru_utime={tv_sec=%lld, tv_usec=%llu}"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
41 | usage->ru_maxrss, usage->ru_ixrss, usage->ru_idrss,
| ~~~~~~~~~~~~~~~~
| |
| kernel_long_t {aka long long int}
../../tests-mx32/getrusage.c:31:62: note: format string is defined here
31 | ", ru_stime={tv_sec=%lld, tv_usec=%llu}, ru_maxrss=%lu"
| ~~^
| |
| long unsigned int
| %llu
I've applied a fixed edition of this patch.
--
ldv
More information about the Strace-devel
mailing list