]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: lxc.sysctl coding style fixes
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 11 Dec 2017 10:27:24 +0000 (11:27 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 11 Dec 2017 10:27:24 +0000 (11:27 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
doc/lxc.container.conf.sgml.in
src/lxc/conf.c
src/lxc/confile.c

index 8c14d1507e147361f03f83467f29679aef9f9a8e..7a6dd484106ddade8a9d2f21e05c4b3156f8640a 100644 (file)
@@ -1403,7 +1403,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
             <para>
               Specify the kernel parameters to be set. The parameters available 
               are those listed under /proc/sys/.
-              Note that not all sysctls are namespaced.Changing Non-namespaced
+              Note that not all sysctls are namespaced. Changing Non-namespaced
               sysctls will cause the system-wide setting to be modified.
               <citerefentry>
                 <refentrytitle><command>sysctl</command></refentrytitle>
index c59f287069d2464a7a2722890814fa385895ca63..6a452064b74799ac32298f3ff8a0d52e6627b920 100644 (file)
@@ -3311,8 +3311,8 @@ int lxc_clear_cgroups(struct lxc_conf *c, const char *key)
 
        if (strcmp(key, "lxc.cgroup") == 0)
                all = true;
-       else if (strncmp(key, "lxc.cgroup.", sizeof("lxc.cgroup.")-1) == 0)
-               k = key + sizeof("lxc.cgroup.")-1;
+       else if (strncmp(key, "lxc.cgroup.", sizeof("lxc.cgroup.") - 1) == 0)
+               k = key + sizeof("lxc.cgroup.") - 1;
        else
                return -1;
 
@@ -3326,6 +3326,7 @@ int lxc_clear_cgroups(struct lxc_conf *c, const char *key)
                free(cg);
                free(it);
        }
+
        return 0;
 }
 
index dba13d5ef677b289ee8a6803e51ce8bd5b23bedf..584f93630c5f633ab7f858337357c81e185ba2b5 100644 (file)
@@ -1500,12 +1500,12 @@ static int set_config_sysctl(const char *key, const char *value,
                            struct lxc_conf *lxc_conf, void *data)
 {
        struct lxc_list *iter;
+       char *replace_value = NULL;
        struct lxc_list *sysctl_list = NULL;
        struct lxc_sysctl *sysctl_elem = NULL;
-       char *replace_value = NULL;
 
        if (lxc_config_value_empty(value))
-               return lxc_clear_sysctls(lxc_conf, key);
+               return clr_config_sysctl(key, lxc_conf, NULL);
 
        if (strncmp(key, "lxc.sysctl.", sizeof("lxc.sysctl.") - 1) != 0)
                return -1;
@@ -1515,14 +1515,17 @@ static int set_config_sysctl(const char *key, const char *value,
        /* find existing list element */
        lxc_list_for_each(iter, &lxc_conf->sysctls) {
                sysctl_elem = iter->elem;
-               if (strcmp(key, sysctl_elem->key) == 0) {
-                       replace_value = strdup(value);
-                       if (!replace_value)
-                               return -1;
-                       free(sysctl_elem->value);
-                       sysctl_elem->value = replace_value;
-                       return 0;
-               }
+
+               if (strcmp(key, sysctl_elem->key) != 0)
+                       continue;
+
+               replace_value = strdup(value);
+               if (!replace_value)
+                       return -1;
+
+               free(sysctl_elem->value);
+               sysctl_elem->value = replace_value;
+               return 0;
        }
 
        /* allocate list element */
@@ -1557,8 +1560,6 @@ on_error:
                free(sysctl_elem);
        }
        return -1;
-
-
 }
 
 static int set_config_idmaps(const char *key, const char *value,
@@ -3376,9 +3377,9 @@ static int get_config_prlimit(const char *key, char *retv, int inlen,
        return fulllen;
 }
 
-/* If you ask for a specific value, i.e. lxc.sysctl.net.ipv4.ip_forward, then just the value
- * will be printed. If you ask for 'lxc.sysctl', then all sysctl entries will be
- * printed, in 'lxc.sysctl.key = value' format.
+/* If you ask for a specific value, i.e. lxc.sysctl.net.ipv4.ip_forward, then
+ * just the value will be printed. If you ask for 'lxc.sysctl', then all sysctl
+ * entries will be printed, in 'lxc.sysctl.key = value' format.
  */
 static int get_config_sysctl(const char *key, char *retv, int inlen,
                            struct lxc_conf *c, void *data)