interface: fix value stored to 'fd' is never read
authorPetr Štetiar <ynezz@true.cz>
Tue, 13 Oct 2020 13:18:44 +0000 (15:18 +0200)
committerPetr Štetiar <ynezz@true.cz>
Tue, 13 Oct 2020 13:27:49 +0000 (15:27 +0200)
Fixes following issue reported by clang-12 static analyzer:

 mdnsd/interface.c:360:3: warning: Value stored to 'fd' is never read
                 fd = -1;
                 ^    ~~
 mdnsd/interface.c:394:3: warning: Value stored to 'fd' is never read
                 fd = -1;
                 ^    ~~

Original author most likely wanted to assing -1 to the original
interface filedescriptor.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
interface.c

index d3f2ad34220105a190b26cd3d559785b1f23fc9e..690e8579a44c62ade3b962258b5d3468b966f0a3 100644 (file)
@@ -357,7 +357,7 @@ interface_mcast_setup4(struct interface *iface)
        if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
                fprintf(stderr, "failed to join multicast group: %m\n");
                close(fd);
-               fd = -1;
+               iface->fd.fd = -1;
                return -1;
        }
 
@@ -391,7 +391,7 @@ interface_socket_setup6(struct interface *iface)
        if (setsockopt(fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
                fprintf(stderr, "failed to join multicast group: %m\n");
                close(fd);
-               fd = -1;
+               iface->fd.fd = -1;
                return -1;
        }