treewide: give file descriptors safe initial value
authorDainis Jonitis <dainis.jonitis@ubnt.com>
Mon, 26 Nov 2018 12:45:53 +0000 (14:45 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Fri, 3 May 2019 12:51:21 +0000 (14:51 +0200)
Since main problem of assuming that fd==0 is invalid value
was fixed in upstream odhcpd by e7b1d4bf3a2297192638b9c84208b3dcb306ecd8
then what is left are minor problems of static initialization
of some global fd variables.

Signed-off-by: Dainis Jonitis <dainis.jonitis@ubnt.com>
src/config.c
src/odhcpd.c

index 47eb65f68b02b69af4bd116215621cd2b7846b07..399922b0ce7b77d29d2616a88f32462256297b28 100644 (file)
@@ -20,7 +20,7 @@
 #include "odhcpd.h"
 
 static struct blob_buf b;
 #include "odhcpd.h"
 
 static struct blob_buf b;
-static int reload_pipe[2];
+static int reload_pipe[2] = { -1, -1 };
 
 static int lease_cmp(const void *k1, const void *k2, void *ptr);
 static void lease_update(struct vlist_tree *tree, struct vlist_node *node_new,
 
 static int lease_cmp(const void *k1, const void *k2, void *ptr);
 static void lease_update(struct vlist_tree *tree, struct vlist_node *node_new,
@@ -1087,7 +1087,7 @@ static void reload_cb(struct uloop_fd *u, _unused unsigned int events)
        odhcpd_reload();
 }
 
        odhcpd_reload();
 }
 
-static struct uloop_fd reload_fd = { .cb = reload_cb };
+static struct uloop_fd reload_fd = { .fd = -1, .cb = reload_cb };
 
 void odhcpd_run(void)
 {
 
 void odhcpd_run(void)
 {
index 91b5db4abf2135326f14ca9623b52af7cf51c2c3..4b8e5898d450bc661e0f4d29b48dfff1f35a101c 100644 (file)
@@ -45,7 +45,7 @@
 
 
 
 
 
 
-static int ioctl_sock;
+static int ioctl_sock = -1;
 static int urandom_fd = -1;
 
 static void sighandler(_unused int signal)
 static int urandom_fd = -1;
 
 static void sighandler(_unused int signal)