Make sure we have a show_usage function prototype
[oweals/busybox.git] / networking / udhcp / dhcpc.c
index ae40ec9c240744596d8c7f06b64bf084be3ae9c9..c55ebbb09a65c32ff5e9fdf431bbddb3921814d2 100644 (file)
@@ -77,7 +77,7 @@ struct client_config_t client_config = {
 };
 
 #ifndef BB_VER
-static void show_usage(void)
+static void __attribute__ ((noreturn)) show_usage(void)
 {
        printf(
 "Usage: udhcpc [OPTIONS]\n\n"
@@ -99,6 +99,8 @@ static void show_usage(void)
        );
        exit(0);
 }
+#else
+extern void show_usage(void) __attribute__ ((noreturn));
 #endif
 
 
@@ -118,14 +120,14 @@ static void perform_renew(void)
 {
        LOG(LOG_INFO, "Performing a DHCP renew");
        switch (state) {
-       case RENEWING:
-               run_script(NULL, "deconfig");
        case BOUND:
-       case REBINDING:
                change_mode(LISTEN_KERNEL);
+       case RENEWING:
+       case REBINDING:
                state = RENEW_REQUESTED;
                break;
-       case RENEW_REQUESTED:
+       case RENEW_REQUESTED: /* impatient are we? fine, square 1 */
+               run_script(NULL, "deconfig");
        case REQUESTING:
        case RELEASED:
                change_mode(LISTEN_RAW);
@@ -246,7 +248,7 @@ int main(int argc, char *argv[])
                switch (c) {
                case 'c':
                        len = strlen(optarg) > 255 ? 255 : strlen(optarg);
-                       if (client_config.clientid) free(client_config.clientid);
+                       free(client_config.clientid);
                        client_config.clientid = xmalloc(len + 2);
                        client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
                        client_config.clientid[OPT_LEN] = len;
@@ -262,7 +264,7 @@ int main(int argc, char *argv[])
                case 'h':
                case 'H':
                        len = strlen(optarg) > 255 ? 255 : strlen(optarg);
-                       if (client_config.hostname) free(client_config.hostname);
+                       free(client_config.hostname);
                        client_config.hostname = xmalloc(len + 2);
                        client_config.hostname[OPT_CODE] = DHCP_HOST_NAME;
                        client_config.hostname[OPT_LEN] = len;
@@ -387,6 +389,7 @@ int main(int argc, char *argv[])
                                        packet_num++;
                                } else {
                                        /* timed out, go back to init state */
+                                       if (state == RENEW_REQUESTED) run_script(NULL, "deconfig");
                                        state = INIT_SELECTING;
                                        timeout = now;
                                        packet_num = 0;