[PATCH mdnsd 03/10] interface: fix value stored to 'fd' is never read

Petr Štetiar ynezz at true.cz
Tue Oct 13 09:36:14 EDT 2020


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 at true.cz>
---
 interface.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/interface.c b/interface.c
index d3f2ad342201..690e8579a44c 100644
--- a/interface.c
+++ b/interface.c
@@ -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;
 	}
 



More information about the openwrt-devel mailing list