mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-14 17:12:14 +00:00
Replace all calls to rindex by strrchr
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>
This commit is contained in:
parent
4ba0d9af63
commit
c32981c3fb
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user