]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Clean up stuff
authorRoy Marples <roy@marples.name>
Fri, 4 May 2007 14:47:09 +0000 (14:47 +0000)
committerRoy Marples <roy@marples.name>
Fri, 4 May 2007 14:47:09 +0000 (14:47 +0000)
client.c
dhcp.c
interface.c

index d6ff2a2d28deb4f10b3bd547ef4c6b39717d1149..9d603c91a6b45101e3d2200c5bc8825b3d6258b4 100644 (file)
--- a/client.c
+++ b/client.c
@@ -73,7 +73,7 @@
        if (iface->fd >= 0) close (iface->fd); \
        iface->fd = -1; \
        if (_mode == SOCKET_OPEN) \
-       if (open_socket (iface, false) < 0) { retval = -1; goto eexit; } \
+       if (open_socket (iface, false) < 0) { retval = EXIT_FAILURE; goto eexit; } \
        mode = _mode; \
 }
 
@@ -304,7 +304,7 @@ int dhcp_run (const options_t *options)
                                        else {
                                                logger (LOG_ERR, "timed out");
                                                if (! daemonised) {
-                                                       retval = -1;
+                                                       retval = EXIT_FAILURE;
                                                        goto eexit;
                                                }
                                        }
@@ -534,13 +534,13 @@ int dhcp_run (const options_t *options)
                                                xid = 0;
 
                                                if (configure (options, iface, dhcp) < 0 && ! daemonised) {
-                                                       retval = -1;
+                                                       retval = EXIT_FAILURE;
                                                        goto eexit;
                                                }
 
                                                if (! daemonised && options->daemonise) {
                                                        if ((daemonise (options->pidfile)) < 0 ) {
-                                                               retval = -1;
+                                                               retval = EXIT_FAILURE;
                                                                goto eexit;
                                                        }
                                                        daemonised = true;
@@ -559,7 +559,7 @@ int dhcp_run (const options_t *options)
                } else {
                        /* An error occured. As we heavily depend on select, we abort. */
                        logger (LOG_ERR, "error on select: %s", strerror (errno));
-                       retval = -1;
+                       retval = EXIT_FAILURE;
                        goto eexit;
                }
        }
diff --git a/dhcp.c b/dhcp.c
index 56525606c5fdca6eb3022e1f442f8a1696c7aff9..4b9bc0d0fe2f15ddf8785c04feb2073c7711eeff 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -245,15 +245,14 @@ size_t send_message (const interface_t *iface, const dhcp_t *dhcp,
                p += iface->hwlen;
        }
 
-       *p++ = DHCP_END;
-
 #ifdef BOOTP_MESSAGE_LENTH_MIN
        /* Some crappy DHCP servers think they have to obey the BOOTP minimum
         * messag length. They are wrong, but we should still cater for them */
-       while (p - m < BOOTP_MESSAGE_LENTH_MIN)
+       while (p - m < BOOTP_MESSAGE_LENTH_MIN - 1)
                *p++ = DHCP_PAD;
 #endif
 
+       *p++ = DHCP_END;
        message_length = p - m;
 
        memset (&packet, 0, sizeof (struct udp_dhcp_packet));
index ffee74448bacd44491e6368cca71f760cf4f94c7..cc3b48a1ebaf690437e736fef1f4e26d2db6c414 100644 (file)
@@ -423,7 +423,7 @@ static int do_route (const char *ifname,
        if (dstd)
                free (dstd);
 
-       if ((s = socket(PF_ROUTE, SOCK_RAW, 0)) < 0) {
+       if ((s = socket (PF_ROUTE, SOCK_RAW, 0)) < 0) {
                logger (LOG_ERR, "socket: %s", strerror (errno));
                return -1;
        }
@@ -458,6 +458,7 @@ static int do_route (const char *ifname,
 
                if (getifaddrs (&ifap)) {
                        logger (LOG_ERR, "getifaddrs: %s", strerror (errno));
+                       close (s);
                        return -1;
                }