chiark / gitweb /
systemctl: don't show cgroup field for a unit if cgroup is empty
[elogind.git] / src / shared / conf-parser.c
index 595bb51a27151c8a7e5380a6260c1a5ddc4426d5..9f5c07c761e2670ab75ca92676a8badcc6682cf8 100644 (file)
@@ -593,7 +593,7 @@ int config_parse_string(
         assert(rvalue);
         assert(data);
 
-        n = cunescape(rvalue);
+        n = strdup(rvalue);
         if (!n)
                 return -ENOMEM;
 
@@ -865,7 +865,7 @@ int config_parse_mode(
 
         errno = 0;
         l = strtol(rvalue, &x, 8);
-        if (!x || *x || errno) {
+        if (!x || x == rvalue || *x || errno) {
                 log_error("[%s:%u] Failed to parse mode value, ignoring: %s", filename, line, rvalue);
                 return 0;
         }
@@ -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,31 +969,31 @@ 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);
                                         return r;
                                 }
                         } else {
-                                log_error("[%s:%u] Failed to parse value: %s", filename, line, w);
-                                return r;
+                                log_error("[%s:%u] Failed to parse value, ignoring: %s", filename, line, w);
+                                return 0;
                         }
                 } 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);
@@ -999,7 +1001,7 @@ int config_parse_set_status(
                                 }
                         }
                 }
-
         }
+
         return 0;
 }