mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
Adapt to VIR_STRDUP and VIR_STRNDUP in src/util/vircgroup.c
This commit is separate due to unusual paradigm compared to the most source files.
This commit is contained in:
parent
b43bb98a31
commit
eb8e5e8774
@ -116,20 +116,14 @@ static int virCgroupCopyMounts(virCgroupPtr group,
|
|||||||
if (!parent->controllers[i].mountPoint)
|
if (!parent->controllers[i].mountPoint)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
group->controllers[i].mountPoint =
|
if (VIR_STRDUP_QUIET(group->controllers[i].mountPoint,
|
||||||
strdup(parent->controllers[i].mountPoint);
|
parent->controllers[i].mountPoint) < 0)
|
||||||
|
|
||||||
if (!group->controllers[i].mountPoint)
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (parent->controllers[i].linkPoint) {
|
if (VIR_STRDUP_QUIET(group->controllers[i].linkPoint,
|
||||||
group->controllers[i].linkPoint =
|
parent->controllers[i].linkPoint) < 0)
|
||||||
strdup(parent->controllers[i].linkPoint);
|
|
||||||
|
|
||||||
if (!group->controllers[i].linkPoint)
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,8 +171,9 @@ static int virCgroupDetectMounts(virCgroupPtr group)
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
char *tmp2;
|
char *tmp2;
|
||||||
|
|
||||||
if (!(group->controllers[i].mountPoint = strdup(entry.mnt_dir)))
|
if (VIR_STRDUP_QUIET(group->controllers[i].mountPoint,
|
||||||
goto no_memory;
|
entry.mnt_dir) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
tmp2 = strrchr(entry.mnt_dir, '/');
|
tmp2 = strrchr(entry.mnt_dir, '/');
|
||||||
if (!tmp2) {
|
if (!tmp2) {
|
||||||
@ -191,7 +186,7 @@ static int virCgroupDetectMounts(virCgroupPtr group)
|
|||||||
if (strchr(tmp2 + 1, ',')) {
|
if (strchr(tmp2 + 1, ',')) {
|
||||||
if (virAsprintf(&linksrc, "%s/%s",
|
if (virAsprintf(&linksrc, "%s/%s",
|
||||||
entry.mnt_dir, typestr) < 0)
|
entry.mnt_dir, typestr) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
*tmp2 = '/';
|
*tmp2 = '/';
|
||||||
|
|
||||||
if (lstat(linksrc, &sb) < 0) {
|
if (lstat(linksrc, &sb) < 0) {
|
||||||
@ -221,8 +216,6 @@ static int virCgroupDetectMounts(virCgroupPtr group)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
no_memory:
|
|
||||||
errno = ENOMEM;
|
|
||||||
error:
|
error:
|
||||||
VIR_FORCE_FCLOSE(mounts);
|
VIR_FORCE_FCLOSE(mounts);
|
||||||
return -errno;
|
return -errno;
|
||||||
@ -239,7 +232,7 @@ static int virCgroupCopyPlacement(virCgroupPtr group,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (path[0] == '/') {
|
if (path[0] == '/') {
|
||||||
if (!(group->controllers[i].placement = strdup(path)))
|
if (VIR_STRDUP_QUIET(group->controllers[i].placement, path) < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -821,7 +814,7 @@ static int virCgroupNew(const char *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (path[0] == '/' || !parent) {
|
if (path[0] == '/' || !parent) {
|
||||||
if (!((*group)->path = strdup(path))) {
|
if (VIR_STRDUP_QUIET((*group)->path, path) < 0) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@ -1027,7 +1020,7 @@ static int virCgroupAddTaskStrController(virCgroupPtr group,
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
char *endp;
|
char *endp;
|
||||||
|
|
||||||
if (!(str = strdup(pidstr)))
|
if (VIR_STRDUP_QUIET(str, pidstr) < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
cur = str;
|
cur = str;
|
||||||
@ -1278,7 +1271,7 @@ int virCgroupNewPartition(const char *path,
|
|||||||
|
|
||||||
if (STRNEQ(newpath, "/")) {
|
if (STRNEQ(newpath, "/")) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
if (!(parentPath = strdup(newpath))) {
|
if (VIR_STRDUP_QUIET(parentPath, newpath) < 0) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -2567,13 +2560,8 @@ static char *virCgroupIdentifyRoot(virCgroupPtr group)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp[0] = '\0';
|
ignore_value(VIR_STRNDUP_QUIET(ret, group->controllers[i].mountPoint,
|
||||||
ret = strdup(group->controllers[i].mountPoint);
|
tmp - group->controllers[i].mountPoint));
|
||||||
tmp[0] = '/';
|
|
||||||
if (!ret) {
|
|
||||||
virReportOOMError();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user