]> granicus.if.org Git - strace/commitdiff
tests/group_req: use ifindex_lo and IFINDEX_LO_STR
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 10 Aug 2017 18:47:28 +0000 (18:47 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 15 Aug 2017 20:08:39 +0000 (20:08 +0000)
* tests/group_req.c: Do not check for HAVE_IF_INDEXTONAME.
(main): Use ifindex_lo instead of if_nametoindex, use IFINDEX_LO_STR
instead of hardcoded string.

tests/group_req.c

index 41b4ea384971c235278bafcdb128968d4887c6fa..946fe5c0c3aa100c1f63f8400cf56f717b9c0c1a 100644 (file)
@@ -31,8 +31,7 @@
 #include <net/if.h>
 #include <netinet/in.h>
 
-#if defined HAVE_IF_INDEXTONAME \
- && defined MCAST_JOIN_GROUP && defined MCAST_LEAVE_GROUP
+#if defined MCAST_JOIN_GROUP && defined MCAST_LEAVE_GROUP
 
 # include <stdio.h>
 # include <unistd.h>
@@ -61,7 +60,7 @@ main(void)
        TAIL_ALLOC_OBJECT_CONST_PTR(struct group_req, greq6);
        unsigned int i;
 
-       greq6->gr_interface = greq4->gr_interface = if_nametoindex("lo");
+       greq6->gr_interface = greq4->gr_interface = ifindex_lo();
        if (!greq4->gr_interface)
                perror_msg_and_skip("lo");
 
@@ -136,18 +135,18 @@ main(void)
                set_opt(0, opts[i].level, opts[i].name,
                        opts[i].val, sizeof(*opts[i].val));
                printf("setsockopt(0, %s, %s"
-                      ", {gr_interface=if_nametoindex(\"lo\")"
-                      ", %s}, %u) = %s\n",
-                      opts[i].str_level, opts[i].str_name, opts[i].addr,
+                      ", {gr_interface=%s, %s}, %u) = %s\n",
+                      opts[i].str_level, opts[i].str_name,
+                      IFINDEX_LO_STR, opts[i].addr,
                       (unsigned int) sizeof(*opts[i].val), errstr);
 
                /* optlen > sizeof(struct group_req), shortened */
                set_opt(0, opts[i].level, opts[i].name, opts[i].val, INT_MAX);
                printf("setsockopt(0, %s, %s"
-                      ", {gr_interface=if_nametoindex(\"lo\")"
-                      ", %s}, %u) = %s\n",
+                      ", {gr_interface=%s, %s}, %u) = %s\n",
                       opts[i].str_level, opts[i].str_name,
-                      opts[i].addr, INT_MAX, errstr);
+                      IFINDEX_LO_STR, opts[i].addr,
+                      INT_MAX, errstr);
        }
 
        puts("+++ exited with 0 +++");
@@ -156,6 +155,6 @@ main(void)
 
 #else
 
-SKIP_MAIN_UNDEFINED("HAVE_IF_INDEXTONAME && MCAST_JOIN_GROUP && MCAST_LEAVE_GROUP")
+SKIP_MAIN_UNDEFINED("MCAST_JOIN_GROUP && MCAST_LEAVE_GROUP")
 
 #endif