]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared: use -EINVAL for _EXEC_COMMAND_FLAGS_INVALID
authorBenjamin Robin <dev@benjarobin.fr>
Tue, 16 Feb 2021 22:19:37 +0000 (23:19 +0100)
committerBenjamin Robin <dev@benjarobin.fr>
Tue, 16 Feb 2021 22:34:58 +0000 (23:34 +0100)
Follow-up of #11484

src/shared/exec-util.c
src/shared/exec-util.h

index 6355ce8ce42a6982a3e4914477cbbc9fb9e9baa3..e4769530a361664faec04ee4a2465e67829a2c58 100644 (file)
@@ -381,10 +381,9 @@ int exec_command_flags_from_strv(char **ex_opts, ExecCommandFlags *flags) {
 
         STRV_FOREACH(opt, ex_opts) {
                 ex_flag = exec_command_flags_from_string(*opt);
-                if (ex_flag >= 0)
-                        ret_flags |= ex_flag;
-                else
-                        return -EINVAL;
+                if (ex_flag < 0)
+                        return ex_flag;
+                ret_flags |= ex_flag;
         }
 
         *flags = ret_flags;
@@ -400,6 +399,9 @@ int exec_command_flags_to_strv(ExecCommandFlags flags, char ***ex_opts) {
 
         assert(ex_opts);
 
+        if (flags < 0)
+                return flags;
+
         for (i = 0; it != 0; it &= ~(1 << i), i++) {
                 if (FLAGS_SET(flags, (1 << i))) {
                         str = exec_command_flags_to_string(1 << i);
index 5bd4a3785f85bc176a3d093cb28d327842af2563..9ce5324de93ad3b6da0b1e5be30df65f3d3b0392 100644 (file)
@@ -27,7 +27,7 @@ typedef enum ExecCommandFlags {
         EXEC_COMMAND_NO_SETUID        = 1 << 2,
         EXEC_COMMAND_AMBIENT_MAGIC    = 1 << 3,
         EXEC_COMMAND_NO_ENV_EXPAND    = 1 << 4,
-        _EXEC_COMMAND_FLAGS_INVALID   = -1,
+        _EXEC_COMMAND_FLAGS_INVALID   = -EINVAL,
 } ExecCommandFlags;
 
 int execute_directories(