handle xlat styles ioprio

Dmitry V. Levin ldv at altlinux.org
Sat Feb 9 01:37:00 UTC 2019


Hi,

On Fri, Jan 11, 2019 at 09:02:50PM -0800, shankarapailoor wrote:
> Hi,
> 
> I noticed that strace doesn't properly handle xlat_styles when
> decoding the ioprio_who field in ioprio_set. This patch fixes that.
> 
> Regards,
> Shankara Pailoor

> From 842f09d4f91b6b9fae82f9e6eb81d4b241f9e546 Mon Sep 17 00:00:00 2001
> From: Shankara Pailoor <shankarapailoor at gmail.com>
> Date: Fri, 11 Jan 2019 20:59:00 -0800
> Subject: [PATCH v1] handle xlat_styles when decoding ioprio_get and set
> 
> * ioprio.c (ioprio_get, SYS_FUNC(ioprio_set)): Only print auxstring in abbrev.
> Handle xlat_styles.
> * tests/ioprio.c: Add xlat macros.
> * tests/ioprio-Xabbrev.c: New test.
> * tests/ioprio-Xraw.c: Likewise.
> * tests/ioprio-Xverbose.c: Likewise.
> * tests/pure_executables.list: Add new tests ioprio-Xabbrev, ioprio-Xraw,
> ioprio-Xverbose.
> * tests/gen_tests.in: Likewise.
> * tests/.gitignore: Likewise.
> ---
>  ioprio.c                    | 16 ++++++++++---
>  tests/.gitignore            |  3 +++
>  tests/gen_tests.in          |  3 +++
>  tests/ioprio-Xabbrev.c      |  1 +
>  tests/ioprio-Xraw.c         |  2 ++
>  tests/ioprio-Xverbose.c     |  2 ++
>  tests/ioprio.c              | 47 +++++++++++++++++++++++++++++++++----
>  tests/pure_executables.list |  3 +++
>  8 files changed, 69 insertions(+), 8 deletions(-)
>  create mode 100644 tests/ioprio-Xabbrev.c
>  create mode 100644 tests/ioprio-Xraw.c
>  create mode 100644 tests/ioprio-Xverbose.c
> 
> diff --git a/ioprio.c b/ioprio.c
> index 2d7c4f6a..9b378450 100644
> --- a/ioprio.c
> +++ b/ioprio.c
> @@ -45,8 +45,11 @@ SYS_FUNC(ioprio_get)
>  	} else {
>  		if (syserror(tcp))
>  			return 0;
> -
> -		tcp->auxstr = sprint_ioprio(tcp->u_rval);
> +		if ((xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW) ||
> +		    (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE))
> +			tcp->auxstr = NULL;
> +		else
> +			tcp->auxstr = sprint_ioprio(tcp->u_rval);
>  		return RVAL_STR;

Why do you handle XLAT_STYLE_VERBOSE as XLAT_STYLE_RAW here?

>  	}
>  }
> @@ -58,7 +61,14 @@ SYS_FUNC(ioprio_set)
>  	/* int who */
>  	tprintf(", %d, ", (int) tcp->u_arg[1]);
>  	/* int ioprio */
> -	tprints(sprint_ioprio(tcp->u_arg[2]));
> +	if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
> +		tprintf("%d", (int) tcp->u_arg[2]);
> +
> +	if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
> +		return RVAL_DECODED;
> +
> +	(xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE
> +		? tprints_comment : tprints)(sprint_ioprio(tcp->u_arg[2]));
>  
>  	return RVAL_DECODED;

The check for XLAT_STYLE_RAW seems to be redundant here.


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


More information about the Strace-devel mailing list