summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-08-14 18:42:26 +0200
committerLennart Poettering <lennart@poettering.net>2012-08-14 18:42:26 +0200
commitd046b20b11e78f4f52267850097e20f8221a6279 (patch)
tree42ae89fa74160627f3d99ac1497bdc9ed3f95f09 /src/shared
parentabdf7993161a2762df6887fdb5a5f0f4f5da24cf (diff)
conf-parser: simplify a few things by using set_ensure_allocated() rather than set_new()
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/conf-parser.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 595bb51a27..f3e258a65c 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -959,7 +959,9 @@ int config_parse_set_status(
FOREACH_WORD(w, l, rvalue, state) {
int val;
- char *temp = strndup(w, l);
+ char *temp;
+
+ temp = strndup(w, l);
if (!temp)
return log_oom();
@@ -967,12 +969,12 @@ int config_parse_set_status(
if (r < 0) {
val = signal_from_string_try_harder(temp);
free(temp);
+
if (val > 0) {
- if (!status_set->signal) {
- status_set->signal = set_new(trivial_hash_func, trivial_compare_func);
- if (!status_set->signal)
- return log_oom();
- }
+ r = set_ensure_allocated(&status_set->signal, trivial_hash_func, trivial_compare_func);
+ if (r < 0)
+ return log_oom();
+
r = set_put(status_set->signal, INT_TO_PTR(val));
if (r < 0) {
log_error("[%s:%u] Unable to store: %s", filename, line, w);
@@ -984,14 +986,14 @@ int config_parse_set_status(
}
} else {
free(temp);
- if(val < 0 || val > 255)
+
+ if (val < 0 || val > 255)
log_warning("[%s:%u] Value %d is outside range 0-255, ignoring", filename, line, val);
else {
- if (!status_set->code) {
- status_set->code = set_new(trivial_hash_func, trivial_compare_func);
- if (!status_set->code)
- return log_oom();
- }
+ r = set_ensure_allocated(&status_set->code, trivial_hash_func, trivial_compare_func);
+ if (r < 0)
+ return log_oom();
+
r = set_put(status_set->code, INT_TO_PTR(val));
if (r < 0) {
log_error("[%s:%u] Unable to store: %s", filename, line, w);