From: Jens Axboe Date: Fri, 7 Oct 2005 08:50:56 +0000 (+0200) Subject: [PATCH] blkparse_fmt: Check for repeated zeroes in pdu X-Git-Tag: blktrace-0.99~25 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=1d6376a5e39ed9d13969f4217da386e49e028906;p=blktrace.git [PATCH] blkparse_fmt: Check for repeated zeroes in pdu We can stop dumping the pdu (typically the cdb) if the rest is just zeroes, append a .. to show that is the case. Saves screen space. --- diff --git a/blkparse_fmt.c b/blkparse_fmt.c index c445d0d..8031a8e 100644 --- a/blkparse_fmt.c +++ b/blkparse_fmt.c @@ -79,6 +79,16 @@ static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t) rwbs[i] = '\0'; } +static int pdu_rest_is_zero(unsigned char *pdu, int len) +{ + int i = 0; + + while (!pdu[i] && i < len) + i++; + + return i == len; +} + static char *dump_pdu(unsigned char *pdu_buf, int pdu_len) { static char p[4096]; @@ -92,6 +102,16 @@ static char *dump_pdu(unsigned char *pdu_buf, int pdu_len) len += sprintf(p + len, " "); len += sprintf(p + len, "%02x", pdu_buf[i]); + + /* + * usually dump for cdb dumps where we can see lots of + * zeroes, stop when the rest is just zeroes and indicate + * so with a .. appended + */ + if (!pdu_buf[i] && pdu_rest_is_zero(pdu_buf + i, pdu_len - i)) { + sprintf(p + len, " .."); + break; + } } return p;