]> granicus.if.org Git - strace/commitdiff
msghdr.c: fix representation of struct cmsghdr.cmsg_data integer arrays
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 28 Jun 2016 22:25:10 +0000 (22:25 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 30 Jun 2016 22:10:31 +0000 (22:10 +0000)
* 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.

msghdr.c
tests/inet-cmsg.c

index bad3357ee01e8adfb1cb5b50f3a5883fba9842d3..b602b29c0ed75bb8156816303b4c8fc5d1fd6898 100644 (file)
--- 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
index 5b020417c225cf7ed0d9439ce799e06eca722de2..b4d08e2ee5e74fce71f4b27394d779039a8e7c61 100644 (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("]");
        }
 }