From: Bart Van Assche Date: Fri, 6 Feb 2015 12:36:26 +0000 (+0100) Subject: scsi: on exit, print only initialized part of the buffer X-Git-Tag: v4.10~125 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0014bb1b9dbb6c255b40ceb7b71c60bd198b41b2;p=strace scsi: on exit, print only initialized part of the buffer * scsi.c (print_sg_io_res): Only print that part of the data in buffer that has been initialized by the SCSI LLD driver. Signed-off-by: Bart Van Assche Signed-off-by: Dmitry V. Levin --- diff --git a/scsi.c b/scsi.c index 1ca74b8b..5a6838f6 100644 --- a/scsi.c +++ b/scsi.c @@ -88,9 +88,13 @@ print_sg_io_res(struct tcb *tcp, struct sg_io_hdr *sg_io) { if (sg_io->dxfer_direction == SG_DXFER_FROM_DEV || sg_io->dxfer_direction == SG_DXFER_TO_FROM_DEV) { - tprintf(", data[%u]=[", sg_io->dxfer_len); - printstr(tcp, (unsigned long) sg_io->dxferp, - sg_io->dxfer_len); + uint32_t din_len = sg_io->dxfer_len; + + if (sg_io->resid > 0) + din_len -= sg_io->resid; + + tprintf(", data[%u]=[", din_len); + printstr(tcp, (unsigned long) sg_io->dxferp, din_len); tprints("]"); } tprintf(", status=%02x, ", sg_io->status);