From: Dmitry V. Levin Date: Tue, 28 Jun 2016 22:25:10 +0000 (+0000) Subject: msghdr.c: fix representation of struct cmsghdr.cmsg_data integer arrays X-Git-Tag: v4.13~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a897372dbedbb318295e0e64febe422052f32d4;p=strace msghdr.c: fix representation of struct cmsghdr.cmsg_data integer arrays * msghdr.c (print_cmsg_ip_opts): Print struct cmsghdr.cmsg_data as an array of hexadecimal integers. * tests/inet-cmsg.c (print_opts): Update expected output. --- diff --git a/msghdr.c b/msghdr.c index bad3357e..b602b29c 100644 --- a/msghdr.c +++ b/msghdr.c @@ -161,10 +161,13 @@ print_cmsg_ip_opts(struct tcb *tcp, const void *cmsg_data, if (!data_len) return; - tprints(", cmsg_data={opts=0x"); - for (i = 0; i < data_len; ++i) - tprintf("%02x", opts[i]); - tprints("}"); + tprints(", cmsg_data=["); + for (i = 0; i < data_len; ++i) { + if (i) + tprints(", "); + tprintf("0x%02x", opts[i]); + } + tprints("]"); } static void diff --git a/tests/inet-cmsg.c b/tests/inet-cmsg.c index 5b020417..b4d08e2e 100644 --- a/tests/inet-cmsg.c +++ b/tests/inet-cmsg.c @@ -67,11 +67,11 @@ print_opts(const char *name, const struct cmsghdr *c) printf("%s", name); if (len) { - printf(", cmsg_data={opts=0x"); + printf(", cmsg_data=["); size_t i; for (i = 0; i < len; ++i) - printf("%02x", opts[i]); - printf("}"); + printf("%s0x%02x", i ? ", " : "", opts[i]); + printf("]"); } }