]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: cleanup set_config_namespace_clone()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 8 Dec 2020 15:14:59 +0000 (16:14 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 8 Dec 2020 15:49:41 +0000 (16:49 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile.c

index eee2d4d7c82528ecbd076d79a695241dd5c17318..5d186814b51d0ba946d5115951413541ef838452 100644 (file)
@@ -2642,34 +2642,28 @@ static int set_config_uts_name(const char *key, const char *value,
 static int set_config_namespace_clone(const char *key, const char *value,
                                      struct lxc_conf *lxc_conf, void *data)
 {
-       char *ns, *token;
+       __do_free char *ns = NULL;
+       char *token;
        int cloneflag = 0;
 
        if (lxc_config_value_empty(value))
                return clr_config_namespace_clone(key, lxc_conf, data);
 
-       if (lxc_conf->ns_keep != 0) {
-               errno = EINVAL;
-               SYSERROR("Cannot set both \"lxc.namespace.clone\" and "
-                        "\"lxc.namespace.keep\"");
-               return -EINVAL;
-       }
+       if (lxc_conf->ns_keep != 0)
+               return log_error_errno(-EINVAL, EINVAL, "Cannot set both \"lxc.namespace.clone\" and \"lxc.namespace.keep\"");
 
        ns = strdup(value);
        if (!ns)
-               return -1;
+               return ret_errno(ENOMEM);
 
        lxc_iterate_parts(token, ns, " \t") {
                token += lxc_char_left_gc(token, strlen(token));
                token[lxc_char_right_gc(token, strlen(token))] = '\0';
                cloneflag = lxc_namespace_2_cloneflag(token);
-               if (cloneflag < 0) {
-                       free(ns);
-                       return -EINVAL;
-               }
+               if (cloneflag < 0)
+                       return ret_errno(EINVAL);
                lxc_conf->ns_clone |= cloneflag;
        }
-       free(ns);
 
        return 0;
 }