dryang / rpms / systemd

Forked from rpms/systemd a year ago
Clone
84b277
From 50720580bc5333e594032b124a9a1114e66dc7ae Mon Sep 17 00:00:00 2001
84b277
From: Lennart Poettering <lennart@poettering.net>
84b277
Date: Thu, 12 Jun 2014 23:07:17 +0200
84b277
Subject: [PATCH] tmpfiles: minor modernizations
84b277
84b277
(cherry-picked from 753615e85d990077c303ae4a42a53e792ffb12ca)
84b277
84b277
Resolves: #1147524
84b277
---
84b277
 src/tmpfiles/tmpfiles.c | 12 ++++++++----
84b277
 1 file changed, 8 insertions(+), 4 deletions(-)
84b277
84b277
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
84b277
index ff51062..df6c99a 100644
84b277
--- a/src/tmpfiles/tmpfiles.c
84b277
+++ b/src/tmpfiles/tmpfiles.c
84b277
@@ -990,7 +990,9 @@ static int process_item(Item *i) {
84b277
 }
84b277
 
84b277
 static void item_free(Item *i) {
84b277
-        assert(i);
84b277
+
84b277
+        if (!i)
84b277
+                return;
84b277
 
84b277
         free(i->path);
84b277
         free(i->argument);
84b277
@@ -1122,7 +1124,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
84b277
                 }
84b277
         }
84b277
 
84b277
-        switch(type) {
84b277
+        switch (type) {
84b277
 
84b277
         case CREATE_FILE:
84b277
         case TRUNCATE_FILE:
84b277
@@ -1171,7 +1173,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
84b277
         }
84b277
 
84b277
         default:
84b277
-                log_error("[%s:%u] Unknown file type '%c'.", fname, line, type);
84b277
+                log_error("[%s:%u] Unknown command type '%c'.", fname, line, type);
84b277
                 return -EBADMSG;
84b277
         }
84b277
 
84b277
@@ -1355,9 +1357,11 @@ static int parse_argv(int argc, char *argv[]) {
84b277
                         break;
84b277
 
84b277
                 case ARG_ROOT:
84b277
+                        free(arg_root);
84b277
                         arg_root = path_make_absolute_cwd(optarg);
84b277
                         if (!arg_root)
84b277
                                 return log_oom();
84b277
+
84b277
                         path_kill_slashes(arg_root);
84b277
                         break;
84b277
 
84b277
@@ -1456,7 +1460,7 @@ int main(int argc, char *argv[]) {
84b277
 
84b277
         r = parse_argv(argc, argv);
84b277
         if (r <= 0)
84b277
-                return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
84b277
+                goto finish;
84b277
 
84b277
         log_set_target(LOG_TARGET_AUTO);
84b277
         log_parse_environment();