]> granicus.if.org Git - strace/commitdiff
print_inet_addr: print nameless and named addresses using the same style
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 12 Nov 2018 13:42:11 +0000 (13:42 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 12 Nov 2018 13:42:11 +0000 (13:42 +0000)
* sockaddr.c (print_inet_addr): Handle var_name == NULL case in a more
structured way: use inet_addr("%s") form to print AF_INET addresses
in structureless contexts where no structure field name is available.
Likewise, use inet_pton(AF_INET6, "%s") that case.
* tests/nlattr_ifaddrmsg.c (main): Update expected output.
* tests/nlattr_ifla_af_spec.c (main): Likewise.

Complements: v4.19~76 "print_inet_addr: add support of invocations without field name"

sockaddr.c
tests/nlattr_ifaddrmsg.c
tests/nlattr_ifla_af_spec.c

index cf60c324c100fa57a376661d90d8c6fb9de5ea6b..3067e51418a00e9a2d2d4bc4a411619bd82e44ed 100644 (file)
@@ -98,7 +98,7 @@ print_inet_addr(const int af,
                        if (var_name)
                                tprintf("%s=inet_addr(\"%s\")", var_name, buf);
                        else
-                               tprints(buf);
+                               tprintf("inet_addr(\"%s\")", buf);
                        return true;
                }
                break;
@@ -108,7 +108,8 @@ print_inet_addr(const int af,
                                tprintf("inet_pton(%s, \"%s\", &%s)",
                                        "AF_INET6", buf, var_name);
                        else
-                               tprints(buf);
+                               tprintf("inet_pton(%s, \"%s\")",
+                                       "AF_INET6", buf);
                        return true;
                }
                break;
index c71ebb1cf8d3f0f1f8467c2becc86cace0cd418e..600a166ed5913243758be3a91ef58b01fbe80c35 100644 (file)
@@ -127,7 +127,7 @@ main(void)
        TEST_NLATTR_OBJECT(fd, nlh0, hdrlen,
                           init_ifaddrmsg, print_ifaddrmsg,
                           IFA_ADDRESS, pattern, a4,
-                          printf("%s", address4));
+                          printf("inet_addr(\"%s\")", address4));
 
        SET_IFA_FAMILY(AF_INET6);
 
@@ -137,7 +137,7 @@ main(void)
        TEST_NLATTR_OBJECT(fd, nlh0, hdrlen,
                           init_ifaddrmsg, print_ifaddrmsg,
                           IFA_ADDRESS, pattern, a6,
-                          printf("%s", address6));
+                          printf("inet_pton(AF_INET6, \"%s\")", address6));
 
        TEST_NLATTR_OBJECT(fd, nlh0, hdrlen,
                           init_ifaddrmsg, print_ifaddrmsg,
index 24f55af6a18a2598b15b13cec3d7920031f7aa77..579739a1cf490eb72b54c2985882447402c4059e 100644 (file)
@@ -292,8 +292,9 @@ main(void)
                                      init_AF_INET6_msg, print_AF_INET6_msg,
                                      7, "IFLA_INET6_TOKEN", pattern,
                                      inet6_addr, print_quoted_hex, 2,
-                                     printf("badc:ded:face:beef:deca:feed"
-                                            ":dead:feed"));
+                                     printf("inet_pton(AF_INET6"
+                                            ", \"badc:ded:face:beef"
+                                            ":deca:feed:dead:feed\")"));
 
        /* AF_INET6: IFLA_INET6_ */
        static const struct {