]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
util-lib: get rid of a helper variable 12058/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 21 Mar 2019 10:08:09 +0000 (11:08 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 21 Mar 2019 10:08:58 +0000 (11:08 +0100)
src/basic/capability-util.c
src/nspawn/nspawn-oci.c

index 45fadb9faa9a2216abeb99773b0e5bca58526e30..99628f626085b76ea668deda7a614421381b9aee 100644 (file)
@@ -367,8 +367,7 @@ bool ambient_capabilities_supported(void) {
 }
 
 int capability_quintet_enforce(const CapabilityQuintet *q) {
-        _cleanup_cap_free_ cap_t c = NULL;
-        bool need_set_proc_again = false;
+        _cleanup_cap_free_ cap_t c = NULL, modified = NULL;
         int r;
 
         if (q->ambient != (uint64_t) -1) {
@@ -493,8 +492,6 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
                 }
 
                 if (changed) {
-                        _cleanup_cap_free_ cap_t modified = NULL;
-
                         /* In order to change the bounding caps, we need to keep CAP_SETPCAP for a bit
                          * longer. Let's add it to our list hence for now. */
                         if (q->bounding != (uint64_t) -1) {
@@ -522,8 +519,6 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
                          * caps in inherited/permitted/effective anymore, but only lose them.*/
                         if (cap_set_proc(modified ?: c) < 0)
                                 return -errno;
-
-                        need_set_proc_again = !!modified;
                 }
         }
 
@@ -537,7 +532,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
          * we have already set only in the CAP_SETPCAP bit, which we needed for dropping the bounding
          * bits. This call only undoes bits and doesn't acquire any which means the bounding caps don't
          * matter. */
-        if (need_set_proc_again)
+        if (modified)
                 if (cap_set_proc(c) < 0)
                         return -errno;
 
index 2193439a35a776a487a4904419d58499c86c6c3d..60ccb1f6a28db8e4d7bef9ce8e6f76290bb4571e 100644 (file)
@@ -87,7 +87,7 @@ static int oci_terminal(const char *name, JsonVariant *v, JsonDispatchFlags flag
         Settings *s = userdata;
 
         /* If not specified, or set to true, we'll default to either an interactive or a read-only
-         * console. If specifiy as false, we'll forcibly move to "pipe" mode though. */
+         * console. If specified as false, we'll forcibly move to "pipe" mode though. */
         s->console_mode = json_variant_boolean(v) ? _CONSOLE_MODE_INVALID : CONSOLE_PIPE;
         return 0;
 }
@@ -194,8 +194,7 @@ static int oci_args(const char *name, JsonVariant *v, JsonDispatchFlags flags, v
                 return json_log(v, flags, SYNTHETIC_ERRNO(EINVAL),
                                 "Executable name is empty, refusing.");
 
-        strv_free_and_replace(*value, l);
-        return 0;
+        return strv_free_and_replace(*value, l);
 }
 
 static int oci_rlimit_type(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {