From: Stéphane Graber Date: Fri, 16 Aug 2013 09:53:11 +0000 (+0200) Subject: Replace all calls to rindex by strrchr X-Git-Tag: lxc-1.0.0.alpha1~1^2~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c32981c3fb1bf5191052fb1c348bdc8b9e7c1b15;p=thirdparty%2Flxc.git Replace all calls to rindex by strrchr The two functions are identical but strrchr also works on Bionic. Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c index 60d929033..a297cce9b 100644 --- a/src/lxc/bdev.c +++ b/src/lxc/bdev.c @@ -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; diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c index d2737eaec..ab47a645a 100644 --- a/src/lxc/cgroup.c +++ b/src/lxc/cgroup.c @@ -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; } diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 6cf3da63b..a64babe2c 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -1645,7 +1645,7 @@ static int copyhooks(struct lxc_container *oldc, struct lxc_container *c) for (i=0; ilxc_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)