]> git.proxmox.com Git - mirror_lxc.git/commitdiff
utils: add remove_trailing_newlines()
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 24 May 2018 11:38:08 +0000 (13:38 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 24 May 2018 11:38:08 +0000 (13:38 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/lxccontainer.c
src/lxc/seccomp.c
src/lxc/utils.c
src/lxc/utils.h

index 16182332ce9d81ab9ae78d2dd38c39ae7c00d515..fa66060db7fa31f7de004164c6997eb167f7e6b8 100644 (file)
@@ -2685,15 +2685,6 @@ out:
        return bret;
 }
 
-static void strip_newline(char *p)
-{
-       size_t len = strlen(p);
-       if (len < 1)
-               return;
-       if (p[len-1] == '\n')
-               p[len-1] = '\0';
-}
-
 void mod_all_rdeps(struct lxc_container *c, bool inc)
 {
        struct lxc_container *p;
@@ -2716,8 +2707,10 @@ void mod_all_rdeps(struct lxc_container *c, bool inc)
                        ERROR("badly formatted file %s", path);
                        goto out;
                }
-               strip_newline(lxcpath);
-               strip_newline(lxcname);
+
+               remove_trailing_newlines(lxcpath);
+               remove_trailing_newlines(lxcname);
+
                if ((p = lxc_container_new(lxcname, lxcpath)) == NULL) {
                        ERROR("Unable to find dependent container %s:%s",
                                lxcpath, lxcname);
index 817b53633efa3e67e0b7ced9c5f6aeb3ebea29db..1e754db221e5f43359dd1154f24c0cc2ec69f360 100644 (file)
@@ -65,16 +65,6 @@ static int parse_config_v1(FILE *f, struct lxc_conf *conf)
 }
 
 #if HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH
-static void remove_trailing_newlines(char *l)
-{
-       char *p = l;
-
-       while (*p)
-               p++;
-       while (--p >= l && *p == '\n')
-               *p = '\0';
-}
-
 static uint32_t get_v2_default_action(char *line)
 {
        uint32_t ret_action = -1;
index 2669a4d4beff218a4e02d3e15f980f3b00fdedd9..7525346e906dc83ce5788a9cf145dbe6b8676101 100644 (file)
@@ -2533,3 +2533,14 @@ int lxc_set_death_signal(int signal)
 
        return 0;
 }
+
+void remove_trailing_newlines(char *l)
+{
+       char *p = l;
+
+       while (*p)
+               p++;
+
+       while (--p >= l && *p == '\n')
+               *p = '\0';
+}
index dd451064407699f762c1a6ac0088f5e4547ebe22..93e2a3ee44ab2f3b873665bdf48f20108dd2af8c 100644 (file)
@@ -453,6 +453,7 @@ extern void lxc_free_array(void **array, lxc_free_fn element_free_fn);
 extern size_t lxc_array_len(void **array);
 
 extern void **lxc_append_null_to_array(void **array, size_t count);
+extern void remove_trailing_newlines(char *l);
 
 /* initialize rand with urandom */
 extern int randseed(bool);