VIR_DEBUG("Detecting placement for pid %lld path %s",
(long long) pid, path);
if (pid == -1) {
- if (VIR_STRDUP(procfile, "/proc/self/cgroup") < 0)
- goto cleanup;
+ procfile = g_strdup("/proc/self/cgroup");
} else {
if (virAsprintf(&procfile, "/proc/%lld/cgroup",
(long long) pid) < 0)
if (!(lines = virStringSplit(str, "\n", -1)))
goto error;
- if (VIR_STRDUP(*value, virStringListGetFirstWithPrefix(lines, prefix)) < 0)
- goto error;
+ *value = g_strdup(virStringListGetFirstWithPrefix(lines, prefix));
ret = 0;
error:
goto error;
if (path[0] == '/' || !parent) {
- if (VIR_STRDUP((*group)->path, path) < 0)
- goto error;
+ (*group)->path = g_strdup(path);
} else {
if (virAsprintf(&(*group)->path, "%s%s%s",
parent->path,
if (STRNEQ(newPath, "/")) {
char *tmp;
- if (VIR_STRDUP(parentPath, newPath) < 0)
- goto cleanup;
+ parentPath = g_strdup(newPath);
tmp = strrchr(parentPath, '/');
tmp++;
return -1;
break;
case VIR_CGROUP_THREAD_EMULATOR:
- if (VIR_STRDUP(name, "emulator") < 0)
- return -1;
+ name = g_strdup("emulator");
break;
case VIR_CGROUP_THREAD_IOTHREAD:
if (virAsprintf(&name, "iothread%d", id) < 0)
if (!parent->legacy[i].mountPoint)
continue;
- if (VIR_STRDUP(group->legacy[i].mountPoint,
- parent->legacy[i].mountPoint) < 0)
- return -1;
+ group->legacy[i].mountPoint = g_strdup(parent->legacy[i].mountPoint);
- if (VIR_STRDUP(group->legacy[i].linkPoint,
- parent->legacy[i].linkPoint) < 0)
- return -1;
+ group->legacy[i].linkPoint = g_strdup(parent->legacy[i].linkPoint);
}
return 0;
}
continue;
if (path[0] == '/') {
- if (VIR_STRDUP(group->legacy[i].placement, path) < 0)
- return -1;
+ group->legacy[i].placement = g_strdup(path);
} else {
/*
* parent == "/" + path="" => "/"
char *dirName;
struct stat sb;
- if (VIR_STRDUP(tmp, mntDir) < 0)
- return -1;
+ tmp = g_strdup(mntDir);
dirName = strrchr(tmp, '/');
if (!dirName) {
VIR_FREE(controller->mountPoint);
VIR_FREE(controller->linkPoint);
- if (VIR_STRDUP(controller->mountPoint, mntDir) < 0)
- return -1;
+ controller->mountPoint = g_strdup(mntDir);
/* If it is a co-mount it has a filename like "cpu,cpuacct"
* and we must identify the symlink path */
* selfpath == "/libvirt.service" + path == "foo" -> "/libvirt.service/foo"
*/
if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) {
- if (VIR_STRDUP(group->legacy[i].placement,
- selfpath) < 0)
- return -1;
+ group->legacy[i].placement = g_strdup(selfpath);
} else {
if (virAsprintf(&group->legacy[i].placement,
"%s%s%s", selfpath,
g_autofree char *majorstr = NULL;
g_autofree char *minorstr = NULL;
- if ((major < 0 && VIR_STRDUP(majorstr, "*") < 0) ||
- (major >= 0 && virAsprintf(&majorstr, "%i", major) < 0))
+ if (major < 0)
+ majorstr = g_strdup("*");
+ if (major >= 0 && virAsprintf(&majorstr, "%i", major) < 0)
return -1;
- if ((minor < 0 && VIR_STRDUP(minorstr, "*") < 0) ||
- (minor >= 0 && virAsprintf(&minorstr, "%i", minor) < 0))
+ if (minor < 0)
+ minorstr = g_strdup("*");
+ if (minor >= 0 && virAsprintf(&minorstr, "%i", minor) < 0)
return -1;
if (virAsprintf(&devstr, "%c %s:%s %s", type, majorstr, minorstr,
g_autofree char *majorstr = NULL;
g_autofree char *minorstr = NULL;
- if ((major < 0 && VIR_STRDUP(majorstr, "*") < 0) ||
- (major >= 0 && virAsprintf(&majorstr, "%i", major) < 0))
+ if (major < 0)
+ majorstr = g_strdup("*");
+ if (major >= 0 && virAsprintf(&majorstr, "%i", major) < 0)
return -1;
- if ((minor < 0 && VIR_STRDUP(minorstr, "*") < 0) ||
- (minor >= 0 && virAsprintf(&minorstr, "%i", minor) < 0))
+ if (minor < 0)
+ minorstr = g_strdup("*");
+ if (minor >= 0 && virAsprintf(&minorstr, "%i", minor) < 0)
return -1;
if (virAsprintf(&devstr, "%c %s:%s %s", type, majorstr, minorstr,