service: use free_and_replace() where we can
authorLennart Poettering <lennart@poettering.net>
Wed, 17 Oct 2018 18:18:27 +0000 (20:18 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 17 Oct 2018 19:24:04 +0000 (21:24 +0200)
src/core/service.c

index fa2c699..5f98a50 100644 (file)
@@ -2601,10 +2601,10 @@ static int service_deserialize_exec_command(Unit *u, const char *key, const char
                 _cleanup_free_ char *arg = NULL;
 
                 r = extract_first_word(&value, &arg, NULL, EXTRACT_CUNESCAPE);
+                if (r < 0)
+                        return r;
                 if (r == 0)
                         break;
-                else if (r < 0)
-                        return r;
 
                 switch (state) {
                 case STATE_EXEC_COMMAND_TYPE:
@@ -2744,10 +2744,8 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
                 r = cunescape(value, 0, &t);
                 if (r < 0)
                         log_unit_debug_errno(u, r, "Failed to unescape status text: %s", value);
-                else {
-                        free(s->status_text);
-                        s->status_text = t;
-                }
+                else
+                        free_and_replace(s->status_text, t);
 
         } else if (streq(key, "accept-socket")) {
                 Unit *socket;