[PATCH v6 02/13] tests/getrusage: Correctly use the long types from the rusage struct
Dmitry V. Levin
ldv at altlinux.org
Tue Mar 31 23:41:12 UTC 2020
On Fri, Mar 20, 2020 at 03:09:28PM -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..e8e04275 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, rusage_t *usage)
> {
> int rc = syscall(__NR_getrusage, who, usage);
> int saved_errno = errno;
> @@ -49,7 +50,7 @@ invoke_print(int who, const char *who_str, struct rusage *usage)
> int
> main(void)
> {
> - TAIL_ALLOC_OBJECT_CONST_PTR(struct rusage, usage);
> + TAIL_ALLOC_OBJECT_CONST_PTR(rusage_t, usage);
> if (invoke_print(ARG_STR(RUSAGE_SELF), usage)) {
> perror_msg_and_fail("RUSAGE_SELF");
> }
> --
> 2.25.1
This looks OK, but in line with my previous comment please rename
rusage_t to kernel_rusage_t.
--
ldv
More information about the Strace-devel
mailing list