chiark / gitweb /
systemctl: check the value from start_unit_one
[elogind.git] / src / systemctl / systemctl.c
index 5dcefd7f18590bfd56fcc6869c515fee49507f20..6b6cb3d1d86369d53c31ca967ca82acb46672711 100644 (file)
@@ -82,6 +82,7 @@ static enum dependency {
         DEPENDENCY_REVERSE,
         DEPENDENCY_AFTER,
         DEPENDENCY_BEFORE,
+        _DEPENDENCY_MAX
 } arg_dependency = DEPENDENCY_FORWARD;
 static const char *arg_job_mode = "replace";
 static UnitFileScope arg_scope = UNIT_FILE_SYSTEM;
@@ -1152,7 +1153,7 @@ static int list_dependencies_print(const char *name, int level, unsigned int bra
 
                 for (i = level - 1; i >= 0; i--) {
                         len += 2;
-                        if(len > max_len - 3 && !arg_full) {
+                        if (len > max_len - 3 && !arg_full) {
                                 printf("%s...\n",max_len % 2 ? "" : " ");
                                 return 0;
                         }
@@ -1160,7 +1161,7 @@ static int list_dependencies_print(const char *name, int level, unsigned int bra
                 }
                 len += 2;
 
-                if(len > max_len - 3 && !arg_full) {
+                if (len > max_len - 3 && !arg_full) {
                         printf("%s...\n",max_len % 2 ? "" : " ");
                         return 0;
                 }
@@ -1174,7 +1175,7 @@ static int list_dependencies_print(const char *name, int level, unsigned int bra
         }
 
         n = ellipsize(name, max_len-len, 100);
-        if(!n)
+        if (!n)
                 return log_oom();
 
         printf("%s\n", n);
@@ -1183,7 +1184,7 @@ static int list_dependencies_print(const char *name, int level, unsigned int bra
 
 static int list_dependencies_get_dependencies(sd_bus *bus, const char *name, char ***deps) {
 
-        static const char *dependencies[] = {
+        static const char *dependencies[_DEPENDENCY_MAX] = {
                 [DEPENDENCY_FORWARD] = "Requires\0"
                                        "RequiresOverridable\0"
                                        "Requisite\0"
@@ -1206,7 +1207,7 @@ static int list_dependencies_get_dependencies(sd_bus *bus, const char *name, cha
         assert(bus);
         assert(name);
         assert(deps);
-        assert(arg_dependency < ELEMENTSOF(dependencies));
+        assert_cc(ELEMENTSOF(dependencies) == _DEPENDENCY_MAX);
 
         path = unit_dbus_path_from_name(name);
         if (!path)
@@ -1334,7 +1335,7 @@ static int list_dependencies_one(
 
                 if (arg_all || unit_name_to_type(*c) == UNIT_TARGET) {
                        r = list_dependencies_one(bus, *c, level + 1, &u, (branches << 1) | (c[1] == NULL ? 0 : 1));
-                       if(r < 0)
+                       if (r < 0)
                                return r;
                 }
         }
@@ -1814,7 +1815,7 @@ static int wait_for_jobs(sd_bus *bus, Set *s) {
                 return log_oom();
 
         while (!set_isempty(s)) {
-                for(;;) {
+                for (;;) {
                         r = sd_bus_process(bus, NULL);
                         if (r < 0)
                                 return r;
@@ -2144,7 +2145,7 @@ static int start_unit(sd_bus *bus, char **args) {
 
                         q = start_unit_one(bus, method, *name, mode, &error, s);
                         if (q < 0) {
-                                r = translate_bus_error_to_exit_status(r, &error);
+                                r = translate_bus_error_to_exit_status(q, &error);
                                 sd_bus_error_free(&error);
                         }
                 }
@@ -3690,7 +3691,6 @@ static int cat(sd_bus *bus, char **args) {
                 _cleanup_free_ char *fragment_path = NULL;
                 _cleanup_strv_free_ char **dropin_paths = NULL;
                 sd_bus_error error;
-                FILE *stdout;
                 char **path;
 
                 n = unit_name_mangle(*name);
@@ -3731,8 +3731,6 @@ static int cat(sd_bus *bus, char **args) {
                         continue;
                 }
 
-                stdout = fdopen(STDOUT_FILENO, "a");
-
                 if (!isempty(fragment_path)) {
                         fprintf(stdout, "# %s\n", fragment_path);
                         fflush(stdout);
@@ -4916,7 +4914,7 @@ static int help_types(void) {
         const char *t;
 
         puts("Available unit types:");
-        for(i = 0; i < _UNIT_TYPE_MAX; i++) {
+        for (i = 0; i < _UNIT_TYPE_MAX; i++) {
                 t = unit_type_to_string(i);
                 if (t)
                         puts(t);