wget: add TODO
[oweals/busybox.git] / networking / ifupdown.c
index c1dc1d35d32c20bd6cd263099a425f23bf6093fd..f72e653b310b49ac581c4739d69c491cfab05167 100644 (file)
@@ -572,10 +572,7 @@ static char *next_word(char **buf)
        }
 
        /* Skip over leading whitespace */
-       word = *buf;
-       while (isspace(*word)) {
-               ++word;
-       }
+       word = skip_whitespace(*buf);
 
        /* Skip over comments */
        if (*word == '#') {
@@ -601,6 +598,9 @@ static const struct address_family_t *get_address_family(const struct address_fa
 {
        int i;
 
+       if (!name)
+               return NULL;
+
        for (i = 0; af[i]; i++) {
                if (strcmp(af[i]->name, name) == 0) {
                        return af[i];
@@ -613,6 +613,9 @@ static const struct method_t *get_method(const struct address_family_t *af, char
 {
        int i;
 
+       if (!name)
+               return NULL;
+
        for (i = 0; i < af->n_methods; i++) {
                if (strcmp(af->method[i].name, name) == 0) {
                        return &af->method[i];
@@ -623,6 +626,9 @@ static const struct method_t *get_method(const struct address_family_t *af, char
 
 static const llist_t *find_list_string(const llist_t *list, const char *string)
 {
+       if (string == NULL)
+               return NULL;
+
        while (list) {
                if (strcmp(list->data, string) == 0) {
                        return list;
@@ -649,7 +655,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename)
 
        f = xfopen(filename, "r");
 
-       while ((buf = bb_get_chomped_line_from_file(f)) != NULL) {
+       while ((buf = xmalloc_getline(f)) != NULL) {
                char *buf_ptr = buf;
 
                firstword = next_word(&buf_ptr);
@@ -712,9 +718,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename)
                        }
 
                        /* ship any trailing whitespace */
-                       while (isspace(*buf_ptr)) {
-                               ++buf_ptr;
-                       }
+                       buf_ptr = skip_whitespace(buf_ptr);
 
                        if (buf_ptr[0] != '\0') {
                                bb_error_msg("too many parameters \"%s\"", buf);
@@ -1099,7 +1103,6 @@ int ifupdown_main(int argc, char **argv)
        llist_t *target_list = NULL;
        const char *interfaces = "/etc/network/interfaces";
        int any_failures = 0;
-       int i;
 
        if (applet_name[2] == 'u') {
                /* ifup command */
@@ -1188,6 +1191,7 @@ int ifupdown_main(int argc, char **argv)
                        struct mapping_defn_t *currmap;
 
                        for (currmap = defn->mappings; currmap; currmap = currmap->next) {
+                               int i;
                                for (i = 0; i < currmap->n_matches; i++) {
                                        if (fnmatch(currmap->match[i], liface, 0) != 0)
                                                continue;