Directly pass in the pdu_len into get_pdulen() and only care about the byte swapping in get_pdulen().
This enables us to use the function for different versions of the protocol. Signed-off-by: Johannes Thumshirn <johannes.thumsh...@wdc.com> --- blkparse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blkparse.c b/blkparse.c index 0873c13..3609ca9 100644 --- a/blkparse.c +++ b/blkparse.c @@ -2412,12 +2412,12 @@ static int read_data(int fd, void *buffer, int bytes, int block, int *fdblock) return 0; } -static inline __u16 get_pdulen(struct blk_io_trace *bit) +static inline __u16 get_pdulen(__u16 pdu_len) { if (data_is_native) - return bit->pdu_len; + return pdu_len; - return __bswap_16(bit->pdu_len); + return __bswap_16(pdu_len); } static inline __u32 get_magic(__u32 magic) @@ -2439,7 +2439,7 @@ static int read_one_bit(int fd, struct blk_io_trace *bit, int block, if (ret) return ret; - pdu_len = get_pdulen(bit); + pdu_len = get_pdulen(bit->pdu_len); if (pdu_len) { void *ptr = realloc(bit, sizeof(*bit) + pdu_len); -- 2.51.0