]> git.proxmox.com Git - mirror_lxc.git/commitdiff
overlay: simplify logic
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 30 Jul 2017 07:18:24 +0000 (09:18 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 31 Jul 2017 21:34:19 +0000 (23:34 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/storage/overlay.c

index b8fe10bfe4473081dbdd8a5360213f7769fa18dc..1753dc1b020d5e5676805f379a0cbdd5a8f910d3 100644 (file)
@@ -338,20 +338,17 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
                        s1 = clean_new_path;
                        s2 = clean_old_path;
                        s3 = (char *)cname;
-                       name_len = strlen(cname);
-                       len = strlen(clean_new_path);
                } else if (!strncmp(s2, "/snaps", sizeof("/snaps") - 1)) {
                        s1 = clean_old_path;
                        s2 = clean_new_path;
                        s3 = (char *)oldname;
-                       name_len = strlen(oldname);
-                       len = strlen(clean_old_path);
                } else {
                        free(clean_old_path);
                        free(clean_new_path);
                        return 0;
                }
 
+               len = strlen(s1);
                if (!strncmp(s1, s2, len)) {
                        char *tmp;
 
@@ -369,18 +366,9 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
                                return 0;
                        }
 
-                       tmp += name_len + 1;
-                       if (*tmp == '\0') {
-                               free(clean_old_path);
-                               free(clean_new_path);
-                               return 0;
-                       }
-
-                       if (!strncmp(tmp, "snaps", sizeof("snaps") - 1)) {
-                               free(clean_old_path);
-                               free(clean_new_path);
-                               return LXC_CLONE_SNAPSHOT;
-                       }
+                       free(clean_old_path);
+                       free(clean_new_path);
+                       return LXC_CLONE_SNAPSHOT;
                }
 
                free(clean_old_path);