Move initialization out of if/else block, unruly space, and memset struct beforehand.

Index: dispatch.c
===================================================================
RCS file: /cvs/src/usr.sbin/dhcpd/dispatch.c,v
retrieving revision 1.43
diff -u -p -u -r1.43 dispatch.c
--- dispatch.c    12 Apr 2017 19:17:30 -0000    1.43
+++ dispatch.c    26 Jun 2017 00:49:04 -0000
@@ -549,18 +549,16 @@ add_timeout(time_t when, void (*where)(v
         if (free_timeouts) {
             q = free_timeouts;
             free_timeouts = q->next;
-            q->func = where;
-            q->what = what;
         } else {
-            q = malloc(sizeof (struct dhcpd_timeout));
+            q = malloc(sizeof(struct dhcpd_timeout));
             if (!q)
                 fatalx("Can't allocate timeout structure!");
-            q->func = where;
-            q->what = what;
         }
     }
-
+    memset(q, 0, sizeof *q);
+    q->func = where;
     q->when = when;
+    q->what = what;

     /* Now sort this timeout into the timeout list. */


Reply via email to