From: Roy Marples Date: Fri, 4 May 2007 14:47:09 +0000 (+0000) Subject: Clean up stuff X-Git-Tag: v3.2.3~267 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=233ad2c3cee34e1dd2e0f0e9ecf8e24034b1f739;p=thirdparty%2Fdhcpcd.git Clean up stuff --- diff --git a/client.c b/client.c index d6ff2a2d..9d603c91 100644 --- 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 56525606..4b9bc0d0 100644 --- 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)); diff --git a/interface.c b/interface.c index ffee7444..cc3b48a1 100644 --- a/interface.c +++ b/interface.c @@ -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; }