goto cleanup;
}
- if (!(res->partition = strdup("/machine"))) {
- virReportOOMError();
+ if (VIR_STRDUP(res->partition, "/machine") < 0) {
VIR_FREE(res);
goto cleanup;
}
#include "configmake.h"
#include "lxc_container.h"
#include "virnodesuspend.h"
-
+#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_LXC
if (VIR_ALLOC(caps->host.secModels) < 0)
goto no_memory;
caps->host.nsecModels = 1;
- if (!(caps->host.secModels[0].model = strdup(model)))
- goto no_memory;
- if (!(caps->host.secModels[0].doi = strdup(doi)))
- goto no_memory;
+ if (VIR_STRDUP(caps->host.secModels[0].model, model) < 0)
+ goto error;
+ if (VIR_STRDUP(caps->host.secModels[0].doi, doi) < 0)
+ goto error;
}
VIR_DEBUG("Initialized caps for security driver \"%s\" with "
driver->securityRequireConfined = false;
/* Set the container configuration directory */
- if ((driver->configDir = strdup(LXC_CONFIG_DIR)) == NULL)
- goto no_memory;
- if ((driver->stateDir = strdup(LXC_STATE_DIR)) == NULL)
- goto no_memory;
- if ((driver->logDir = strdup(LXC_LOG_DIR)) == NULL)
- goto no_memory;
- if ((driver->autostartDir = strdup(LXC_AUTOSTART_DIR)) == NULL)
- goto no_memory;
+ if (VIR_STRDUP(driver->configDir, LXC_CONFIG_DIR) < 0)
+ goto error;
+ if (VIR_STRDUP(driver->stateDir, LXC_STATE_DIR) < 0)
+ goto error;
+ if (VIR_STRDUP(driver->logDir, LXC_LOG_DIR) < 0)
+ goto error;
+ if (VIR_STRDUP(driver->autostartDir, LXC_AUTOSTART_DIR) < 0)
+ goto error;
- if ((filename = strdup(SYSCONFDIR "/libvirt/lxc.conf")) == NULL)
- goto no_memory;
+ if (VIR_STRDUP(filename, SYSCONFDIR "/libvirt/lxc.conf") < 0)
+ goto error;
/* Avoid error from non-existant or unreadable file. */
if (access(filename, R_OK) == -1)
p = virConfGetValue(conf, "security_driver");
CHECK_TYPE("security_driver", VIR_CONF_STRING);
if (p && p->str) {
- if (!(driver->securityDriverName = strdup(p->str))) {
- virReportOOMError();
+ if (VIR_STRDUP(driver->securityDriverName, p->str) < 0) {
virConfFree(conf);
return -1;
}
VIR_FREE(filename);
return 0;
-no_memory:
- virReportOOMError();
+error:
return -1;
}
virReportOOMError();
goto cleanup;
}
- if (!(mounts[nmounts] = strdup(mntent.mnt_dir))) {
- virReportOOMError();
+ if (VIR_STRDUP(mounts[nmounts], mntent.mnt_dir) < 0)
goto cleanup;
- }
nmounts++;
VIR_DEBUG("Grabbed %s", mntent.mnt_dir);
}
goto cleanup;
}
- if (!(*type = strdup(data))) {
- virReportOOMError();
+ if (VIR_STRDUP(*type, data) < 0)
goto cleanup;
- }
done:
ret = 0;
virReportOOMError();
goto cleanup;
}
- } else {
- if (!(ttyPath = strdup(argv->ttyPaths[0]))) {
- virReportOOMError();
+ } else if (VIR_STRDUP(ttyPath, argv->ttyPaths[0]) < 0) {
goto cleanup;
- }
}
- } else {
- if (!(ttyPath = strdup("/dev/null"))) {
- virReportOOMError();
+ } else if (VIR_STRDUP(ttyPath, "/dev/null") < 0) {
goto cleanup;
- }
}
VIR_DEBUG("Container TTY path: %s", ttyPath);
virDomainXMLOptionPtr xmlopt = NULL;
char *configFile = NULL;
- if (VIR_ALLOC(ctrl) < 0)
- goto no_memory;
+ if (VIR_ALLOC(ctrl) < 0) {
+ virReportOOMError();
+ goto error;
+ }
ctrl->timerShutdown = -1;
ctrl->firstClient = true;
- if (!(ctrl->name = strdup(name)))
- goto no_memory;
+ if (VIR_STRDUP(ctrl->name, name) < 0)
+ goto error;
if ((caps = lxcCapsInit(NULL)) == NULL)
goto error;
virObjectUnref(xmlopt);
return ctrl;
-no_memory:
- virReportOOMError();
error:
virLXCControllerFree(ctrl);
ctrl = NULL;
break;
case 'n':
- if ((name = strdup(optarg)) == NULL) {
- virReportOOMError();
+ if (VIR_STRDUP(name, optarg) < 0)
goto cleanup;
- }
break;
case 'v':
virReportOOMError();
goto cleanup;
}
- if ((veths[nveths++] = strdup(optarg)) == NULL) {
- virReportOOMError();
+ if (VIR_STRDUP(veths[nveths++], optarg) < 0)
goto cleanup;
- }
break;
case 'c':
goto cleanup;
}
- ret = strdup(vm->def->os.type);
-
- if (ret == NULL)
- virReportOOMError();
+ ignore_value(VIR_STRDUP(ret, vm->def->os.type));
cleanup:
if (vm)
*nparams = 3;
}
- ret = strdup("posix");
- if (!ret)
- virReportOOMError();
+ ignore_value(VIR_STRDUP(ret, "posix"));
cleanup:
if (vm)
root->type = VIR_DOMAIN_FS_TYPE_MOUNT;
- if (!(root->src = strdup("/")) ||
- !(root->dst = strdup("/")))
- goto no_memory;
+ if (VIR_STRDUP(root->src, "/") < 0 ||
+ VIR_STRDUP(root->dst, "/") < 0)
+ goto error;
if (VIR_INSERT_ELEMENT(vm->def->fss,
0,
no_memory:
virReportOOMError();
+error:
virDomainFSDefFree(root);
return -1;
}