[PATCH v2] Decode RUSAGE_THREAD

Dmitry V. Levin ldv at altlinux.org
Thu Mar 16 01:38:27 UTC 2017


On Thu, Mar 16, 2017 at 01:01:40AM +0300, Victor Krapivensky wrote:
> * xlat/usagewho.in: Add values for existing values, add RUSAGE_THREAD.
> * tests/getrusage.c: Test decoding of RUSAGE_THREAD.
> ---
>  tests/getrusage.c | 31 +++++++++++++++++++++++++------
>  xlat/usagewho.in  |  7 ++++---
>  2 files changed, 29 insertions(+), 9 deletions(-)
[...]
> +int
> +main(void)
> +{
> +	struct rusage *const usage = tail_alloc(sizeof(struct rusage));

The idiom is
	struct rusage *const usage = tail_alloc(sizeof(*usage));

> +	if (invoke_print(ARG_STR(RUSAGE_SELF), usage)) {
> +		return 1;
> +	}

Let's follow the current practice and use perror_msg_and_fail if something
fails when it shouldn't, e.g. perror_msg_and_fail("RUSAGE_SELF");

> +	if (invoke_print(ARG_STR(RUSAGE_THREAD), usage) && errno != EINVAL) {
> +		return 1;
> +	}

Likewise.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170316/09ecfae7/attachment.bin>


More information about the Strace-devel mailing list