[systemd-commits] 2 commits - src/systemctl

Lennart Poettering lennart at kemper.freedesktop.org
Thu Sep 13 13:42:31 PDT 2012


 src/systemctl/systemctl.c |   34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

New commits:
commit a33fdebb30cac102db7037a5bcdc85d6c49d4aad
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Sep 13 22:42:22 2012 +0200

    systemctl: minor coding style fixes

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index dd835aa..efb9ae2 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3552,23 +3552,25 @@ finish:
 }
 
 static int mangle_names(char **original_names, char ***mangled_names) {
-        char **names_it = NULL;
-        char **name = NULL;
+        char **i, **l, **name;
 
-        (*mangled_names) = new(char*, strv_length(original_names)+1);
-        if(!(*mangled_names))
+        l = new(char*, strv_length(original_names) + 1);
+        if (!l)
                 return log_oom();
 
-        names_it = *mangled_names;
-
+        i = l;
         STRV_FOREACH(name, original_names) {
-                char *n = unit_name_mangle(*name);
-                (*names_it) = n ? n : strdup(*name);
-                if(!(*names_it))
+                *i = unit_name_mangle(*name);
+                if (!*i) {
+                        strv_free(l);
                         return log_oom();
-                names_it++;
+                }
+
+                i++;
         }
-        *names_it = NULL;
+
+        *i = NULL;
+        *mangled_names = l;
 
         return 0;
 }

commit 37370d0cbe7c79d3f5b44a9ddbfac87c59dc09dd
Author: Václav Pavlín <vpavlin at redhat.com>
Date:   Thu Sep 13 22:35:18 2012 +0200

    install: append .service when enable/disable... is called
    
    https://bugzilla.redhat.com/show_bug.cgi?id=856975

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 55202c7..dd835aa 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3551,6 +3551,28 @@ finish:
         return r;
 }
 
+static int mangle_names(char **original_names, char ***mangled_names) {
+        char **names_it = NULL;
+        char **name = NULL;
+
+        (*mangled_names) = new(char*, strv_length(original_names)+1);
+        if(!(*mangled_names))
+                return log_oom();
+
+        names_it = *mangled_names;
+
+        STRV_FOREACH(name, original_names) {
+                char *n = unit_name_mangle(*name);
+                (*names_it) = n ? n : strdup(*name);
+                if(!(*names_it))
+                        return log_oom();
+                names_it++;
+        }
+        *names_it = NULL;
+
+        return 0;
+}
+
 static int enable_unit(DBusConnection *bus, char **args) {
         const char *verb = args[0];
         UnitFileChange *changes = NULL;
@@ -3559,6 +3581,7 @@ static int enable_unit(DBusConnection *bus, char **args) {
         DBusMessage *m = NULL, *reply = NULL;
         int r;
         DBusError error;
+        char **mangled_names = NULL;
 
         r = enable_sysv_units(args);
         if (r < 0)
@@ -3644,7 +3667,11 @@ static int enable_unit(DBusConnection *bus, char **args) {
 
                 dbus_message_iter_init_append(m, &iter);
 
-                r = bus_append_strv_iter(&iter, args+1);
+                r = mangle_names(args+1, &mangled_names);
+                if(r < 0)
+                        goto finish;
+
+                r = bus_append_strv_iter(&iter, mangled_names);
                 if (r < 0) {
                         log_error("Failed to append unit files.");
                         goto finish;
@@ -3744,6 +3771,9 @@ finish:
         unit_file_changes_free(changes, n_changes);
 
         dbus_error_free(&error);
+
+        strv_free(mangled_names);
+
         return r;
 }
 



More information about the systemd-commits mailing list