[PATCH v5 1/4] Add a enum for decoding to tprint_iov() and tprint_iov_upto().
Dmitry V. Levin
ldv at altlinux.org
Mon Jun 20 23:19:01 UTC 2016
On Mon, Jun 20, 2016 at 04:06:42PM +0000, Fabien Siron wrote:
> This commit introduces a new type iov_decode which will be used instead
> of the integer "decode" as a parameter.
>
> * defs.h (iov_decode): New enum.
> (tprint_iov, tprint_iov_upto): Change type of "decode_iov" to enum iov_decode.
> * aio.c (print_iocb): Change type of "decode_iov" to enum iov_decode in
> tprint_iov() call.
> * keyctl.c (keyctl_instantiate_key_iov): Likewise.
> * process.c (ptrace): Likewise.
> * process_vm.c (process_vm_readv, process_vm_writev): Likewise.
> * io.c (writev, do_pwritev, vmsplice): Likewise.
> (print_iovec): Replace the condition with a switch.
> (tprint_iov_upto): Change type of "decode_iov" to enum iov_decode.
> (readv, do_preadv): Change type of "decode_iov" to enum iov_decode in
> tprint_iov_upto() call.
> * scsi.c (print_sg_io_v3_req, print_sg_io_v3_res, print_sg_io_v4_req,
> print_sg_io_v4_res): Likewise.
net.c is missing
> ---
> aio.c | 4 +++-
> defs.h | 10 ++++++++--
> io.c | 42 +++++++++++++++++++++++++-----------------
> keyctl.c | 2 +-
> net.c | 3 ++-
> process.c | 4 ++--
> process_vm.c | 10 ++++++----
> scsi.c | 10 ++++++----
> 8 files changed, 53 insertions(+), 32 deletions(-)
[...]
> @@ -79,14 +79,21 @@ print_iovec(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
>
> tprints("{");
>
> - if (c->decode_iov) {
> - unsigned long len = iov[1];
> - if (len > c->data_size)
> - len = c->data_size;
> - c->data_size -= len;
> - printstr(tcp, iov[0], len);
> - } else {
> - printaddr(iov[0]);
> + switch (c->decode_iov) {
> + case IOV_DECODE_STR:
> + {
> + unsigned long len = iov[1];
> + if (len > c->data_size)
> + len = c->data_size;
> + c->data_size -= len;
> + printstr(tcp, iov[0], len);
> + break;
> + }
As there is going to be another case similar to IOV_DECODE_STR,
let's move initialization of "unsigned long len" out of the switch
statement.
> + default:
> + {
> + printaddr(iov[0]);
> + break;
> + }
These braces are redundant.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160621/fbd91cd9/attachment.bin>
More information about the Strace-devel
mailing list