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.
This commit is contained in:
Дмитрий Левин 2016-06-28 22:25:10 +00:00
parent 17e624cf96
commit 2a897372db
2 changed files with 10 additions and 7 deletions

View File

@ -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

View File

@ -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("]");
}
}