diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-01-17 02:27:06 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-01-17 02:50:05 +0100 |
commit | 74051b9b5865586bf4d30b9075649af838fb92bd (patch) | |
tree | 1dd547147c395f7e3fec22285da4a83f54644d89 /src/shared/conf-parser.c | |
parent | 4b20075e2fbd99caee8b6a782050969a087a1a21 (diff) |
units: for all unit settings that take lists, allow the empty string for resetting the lists
https://bugzilla.redhat.com/show_bug.cgi?id=756787
Diffstat (limited to 'src/shared/conf-parser.c')
-rw-r--r-- | src/shared/conf-parser.c | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 9f5c07c761..7f286096d2 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -377,7 +377,8 @@ int config_parse_int( assert(rvalue); assert(data); - if ((r = safe_atoi(rvalue, i)) < 0) { + r = safe_atoi(rvalue, i); + if (r < 0) { log_error("[%s:%u] Failed to parse numeric value, ingoring: %s", filename, line, rvalue); return 0; } @@ -403,7 +404,8 @@ int config_parse_long( assert(rvalue); assert(data); - if ((r = safe_atoli(rvalue, i)) < 0) { + r = safe_atoli(rvalue, i); + if (r < 0) { log_error("[%s:%u] Failed to parse numeric value, ignoring: %s", filename, line, rvalue); return 0; } @@ -429,7 +431,8 @@ int config_parse_uint64( assert(rvalue); assert(data); - if ((r = safe_atou64(rvalue, u)) < 0) { + r = safe_atou64(rvalue, u); + if (r < 0) { log_error("[%s:%u] Failed to parse numeric value, ignoring: %s", filename, line, rvalue); return 0; } @@ -455,7 +458,8 @@ int config_parse_unsigned( assert(rvalue); assert(data); - if ((r = safe_atou(rvalue, u)) < 0) { + r = safe_atou(rvalue, u); + if (r < 0) { log_error("[%s:%u] Failed to parse numeric value: %s", filename, line, rvalue); return r; } @@ -595,7 +599,7 @@ int config_parse_string( n = strdup(rvalue); if (!n) - return -ENOMEM; + return log_oom(); if (!utf8_is_valid(n)) { log_error("[%s:%u] String is not UTF-8 clean, ignoring assignment: %s", filename, line, rvalue); @@ -644,7 +648,7 @@ int config_parse_path( n = strdup(rvalue); if (!n) - return -ENOMEM; + return log_oom(); path_kill_slashes(n); @@ -677,13 +681,19 @@ int config_parse_strv( assert(rvalue); assert(data); + if (isempty(rvalue)) { + /* Empty assignment resets the list */ + strv_free(*sv); + *sv = NULL; + } + k = strv_length(*sv); FOREACH_WORD_QUOTED(w, l, rvalue, state) k++; n = new(char*, k+1); if (!n) - return -ENOMEM; + return log_oom(); if (*sv) for (k = 0; (*sv)[k]; k++) @@ -694,7 +704,7 @@ int config_parse_strv( FOREACH_WORD_QUOTED(w, l, rvalue, state) { n[k] = cunescape_length(w, l); if (!n[k]) { - r = -ENOMEM; + r = log_oom(); goto fail; } @@ -744,13 +754,19 @@ int config_parse_path_strv( assert(rvalue); assert(data); + if (isempty(rvalue)) { + /* Empty assignment resets the list */ + strv_free(*sv); + *sv = NULL; + } + k = strv_length(*sv); FOREACH_WORD_QUOTED(w, l, rvalue, state) k++; n = new(char*, k+1); if (!n) - return -ENOMEM; + return log_oom(); k = 0; if (*sv) @@ -760,7 +776,7 @@ int config_parse_path_strv( FOREACH_WORD_QUOTED(w, l, rvalue, state) { n[k] = strndup(w, l); if (!n[k]) { - r = -ENOMEM; + r = log_oom(); goto fail; } @@ -957,6 +973,16 @@ int config_parse_set_status( assert(rvalue); assert(data); + if (isempty(rvalue)) { + /* Empty assignment resets the list */ + + set_free(status_set->signal); + set_free(status_set->code); + + status_set->signal = status_set->code = NULL; + return 0; + } + FOREACH_WORD(w, l, rvalue, state) { int val; char *temp; |