treewide: initialize properly file descriptors
[project/odhcpd.git] / src / ndp.c
index 800c61612b799a9b81f0989ae918a415f5cd0154..f9f24954fc559f6dbe2212d8ccee4ebf6c7151bd 100644 (file)
--- a/src/ndp.c
+++ b/src/ndp.c
@@ -103,7 +103,7 @@ int ndp_init(void)
        netlink_add_netevent_handler(&ndp_netevent_handler);
 
 out:
-       if (ret < 0 && ping_socket > 0) {
+       if (ret < 0 && ping_socket >= 0) {
                close(ping_socket);
                ping_socket = -1;
        }
@@ -125,7 +125,7 @@ int ndp_setup_interface(struct interface *iface, bool enable)
                goto out;
        }
 
-       if (iface->ndp_event.uloop.fd > 0) {
+       if (iface->ndp_event.uloop.fd >= 0) {
                uloop_fd_delete(&iface->ndp_event.uloop);
                close(iface->ndp_event.uloop.fd);
                iface->ndp_event.uloop.fd = -1;
@@ -203,7 +203,7 @@ int ndp_setup_interface(struct interface *iface, bool enable)
                netlink_dump_neigh_table(true);
 
  out:
-       if (ret < 0 && iface->ndp_event.uloop.fd > 0) {
+       if (ret < 0 && iface->ndp_event.uloop.fd >= 0) {
                close(iface->ndp_event.uloop.fd);
                iface->ndp_event.uloop.fd = -1;
        }