]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Replace all calls to rindex by strrchr
authorStéphane Graber <stgraber@ubuntu.com>
Fri, 16 Aug 2013 09:53:11 +0000 (11:53 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 19 Aug 2013 12:32:55 +0000 (14:32 +0200)
The two functions are identical but strrchr also works on Bionic.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/bdev.c
src/lxc/cgroup.c
src/lxc/lxccontainer.c

index 60d929033420f0222b76e97547b197e46a06d303..a297cce9ba174a1942b8631760684fed541bbfe5 100644 (file)
@@ -540,7 +540,7 @@ static int zfs_clone(const char *opath, const char *npath, const char *oname,
                if ((p = index(output, ' ')) == NULL)
                        return -1;
                *p = '\0';
-               if ((p = rindex(output, '/')) == NULL)
+               if ((p = strrchr(output, '/')) == NULL)
                        return -1;
                *p = '\0';
        } else
@@ -796,14 +796,14 @@ static int do_lvm_create(const char *path, unsigned long size)
        pathdup = strdup(path);
        if (!pathdup)
                exit(1);
-       lv = rindex(pathdup, '/');
+       lv = strrchr(pathdup, '/');
        if (!lv) {
                free(pathdup);
                exit(1);
        }
        *lv = '\0';
        lv++;
-       vg = rindex(pathdup, '/');
+       vg = strrchr(pathdup, '/');
        if (!vg)
                exit(1);
        vg++;
@@ -831,7 +831,7 @@ static int lvm_snapshot(const char *orig, const char *path, unsigned long size)
        pathdup = strdup(path);
        if (!pathdup)
                exit(1);
-       lv = rindex(pathdup, '/');
+       lv = strrchr(pathdup, '/');
        if (!lv) {
                free(pathdup);
                exit(1);
@@ -1139,7 +1139,7 @@ static int btrfs_subvolume_create(const char *path)
                return -1;
        }
 
-       p = rindex(newfull, '/');
+       p = strrchr(newfull, '/');
        if (!p) {
                ERROR("bad path: %s", path);
                return -1;
@@ -1266,7 +1266,7 @@ static int btrfs_destroy(struct bdev *orig)
                return -1;
        }
 
-       p = rindex(newfull, '/');
+       p = strrchr(newfull, '/');
        if (!p) {
                ERROR("bad path: %s", path);
                return -1;
index d2737eaec47c2766d4770ccc6c6476951d0a185d..ab47a645a0af85b85b5073b93e4af160e8124f89 100644 (file)
@@ -246,7 +246,7 @@ char *lxc_cgroup_path_get(const char *subsystem, const char *name,
                return strdup("/");
        }
        // path still has 'tasks' on the end, drop it
-       if ((p = rindex(path, '/')) != NULL)
+       if ((p = strrchr(path, '/')) != NULL)
                *p = '\0';
        return strdup(path);
 }
@@ -841,7 +841,7 @@ static char *find_free_cgroup(struct cgroup_desc *d, const char *lxc_name)
        }
        // found it
        // path has '/tasks' at end, drop that
-       if (!(cgp = rindex(path, '/'))) {
+       if (!(cgp = strrchr(path, '/'))) {
                ERROR("Got nonsensical path name %s\n", path);
                return NULL;
        }
index 6cf3da63b80a00553fdd3299834c165cb7f4f5d7..a64babe2c41a69949257253abc740a20aa645f11 100644 (file)
@@ -1645,7 +1645,7 @@ static int copyhooks(struct lxc_container *oldc, struct lxc_container *c)
        for (i=0; i<NUM_LXC_HOOKS; i++) {
                lxc_list_for_each(it, &c->lxc_conf->hooks[i]) {
                        char *hookname = it->elem;
-                       char *fname = rindex(hookname, '/');
+                       char *fname = strrchr(hookname, '/');
                        char tmppath[MAXPATHLEN];
                        if (!fname) // relative path - we don't support, but maybe we should
                                return 0;
@@ -1706,7 +1706,7 @@ static int copy_fstab(struct lxc_container *oldc, struct lxc_container *c)
        if (!oldpath)
                return 0;
 
-       char *p = rindex(oldpath, '/');
+       char *p = strrchr(oldpath, '/');
        if (!p)
                return -1;
        ret = snprintf(newpath, MAXPATHLEN, "%s/%s%s",
@@ -1845,7 +1845,7 @@ only rootfs gets converted (copied/snapshotted) on clone.
 
 static int create_file_dirname(char *path)
 {
-       char *p = rindex(path, '/');
+       char *p = strrchr(path, '/');
        int ret;
 
        if (!p)