if ((def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP) &&
(guiPresent == 0)) {
guiPresent = 1;
- if (VIR_STRDUP(guiDisplay, def->graphics[i]->data.desktop.display) < 0) {
- /* just don't go to cleanup yet as it is ok to have
- * guiDisplay as NULL and we check it below if it
- * exist and then only use it there
- */
- }
+ guiDisplay = g_strdup(def->graphics[i]->data.desktop.display);
}
if ((def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) &&
(sdlPresent == 0)) {
sdlPresent = 1;
- if (VIR_STRDUP(sdlDisplay, def->graphics[i]->data.sdl.display) < 0) {
- /* just don't go to cleanup yet as it is ok to have
- * sdlDisplay as NULL and we check it below if it
- * exist and then only use it there
- */
- }
+ sdlDisplay = g_strdup(def->graphics[i]->data.sdl.display);
}
}
if (STREQ(valueTypeUtf8, "sdl")) {
sdlPresent = 1;
- if (VIR_STRDUP(sdlDisplay, valueDisplayUtf8) < 0) {
- /* just don't go to cleanup yet as it is ok to have
- * sdlDisplay as NULL and we check it below if it
- * exist and then only use it there
- */
- }
+ sdlDisplay = g_strdup(valueDisplayUtf8);
}
if (STREQ(valueTypeUtf8, "gui")) {
guiPresent = 1;
- if (VIR_STRDUP(guiDisplay, valueDisplayUtf8) < 0) {
- /* just don't go to cleanup yet as it is ok to have
- * guiDisplay as NULL and we check it below if it
- * exist and then only use it there
- */
- }
+ guiDisplay = g_strdup(valueDisplayUtf8);
}
}
goto cleanup;
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;
- if (VIR_STRDUP(graphics->data.desktop.display,
- getenv("DISPLAY")) < 0)
- goto cleanup;
+ graphics->data.desktop.display = g_strdup(getenv("DISPLAY"));
}
if (graphics &&
gVBoxAPI.UISharedFolder.GetHostPath(sharedFolder, &hostPathUtf16);
VBOX_UTF16_TO_UTF8(hostPathUtf16, &hostPath);
- if (VIR_STRDUP(def->fss[i]->src->path, hostPath) < 0) {
- VBOX_UTF8_FREE(hostPath);
- VBOX_UTF16_FREE(hostPathUtf16);
- goto cleanup;
- }
+ def->fss[i]->src->path = g_strdup(hostPath);
VBOX_UTF8_FREE(hostPath);
VBOX_UTF16_FREE(hostPathUtf16);
gVBoxAPI.UISharedFolder.GetName(sharedFolder, &nameUtf16);
VBOX_UTF16_TO_UTF8(nameUtf16, &name);
- if (VIR_STRDUP(def->fss[i]->dst, name) < 0) {
- VBOX_UTF8_FREE(name);
- VBOX_UTF16_FREE(nameUtf16);
- goto cleanup;
- }
+ def->fss[i]->dst = g_strdup(name);
VBOX_UTF8_FREE(name);
VBOX_UTF16_FREE(nameUtf16);
if (pathUtf16) {
VBOX_UTF16_TO_UTF8(pathUtf16, &path);
- if (VIR_STRDUP(def->serials[serialPortIncCount]->source->data.file.path, path) < 0)
- return -1;
+ def->serials[serialPortIncCount]->source->data.file.path = g_strdup(path);
}
serialPortIncCount++;
gVBoxAPI.UIParallelPort.GetPath(parallelPort, &pathUtf16);
VBOX_UTF16_TO_UTF8(pathUtf16, &path);
- if (VIR_STRDUP(def->parallels[parallelPortIncCount]->source->data.file.path, path) < 0)
- return -1;
+ def->parallels[parallelPortIncCount]->source->data.file.path = g_strdup(path);
parallelPortIncCount++;
def->virtType = VIR_DOMAIN_VIRT_VBOX;
def->id = dom->id;
memcpy(def->uuid, dom->uuid, VIR_UUID_BUFLEN);
- if (VIR_STRDUP(def->name, dom->name) < 0)
- goto cleanup;
+ def->name = g_strdup(dom->name);
gVBoxAPI.UIMachine.GetMemorySize(machine, &memorySize);
def->mem.cur_balloon = memorySize * 1024;
gVBoxAPI.UIMachine.GetName(machine, &machineNameUtf16);
VBOX_UTF16_TO_UTF8(machineNameUtf16, &machineName);
- if (VIR_STRDUP(names[j], machineName) < 0) {
- VBOX_UTF16_FREE(machineNameUtf16);
- VBOX_UTF8_FREE(machineName);
- for (j = 0; j < maxnames; j++)
- VIR_FREE(names[j]);
- ret = -1;
- goto cleanup;
- }
+ names[j] = g_strdup(machineName);
VBOX_UTF16_FREE(machineNameUtf16);
VBOX_UTF8_FREE(machineName);
j++;
readOnlyDisk->format = format;
readOnlyDisk->uuid = uuid;
- if (VIR_STRDUP(readOnlyDisk->location, def->parent.dom->disks[it]->src->path) < 0) {
- VIR_FREE(readOnlyDisk);
- goto cleanup;
- }
+ readOnlyDisk->location = g_strdup(def->parent.dom->disks[it]->src->path);
if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(readOnlyDisk, snapshotMachineDesc->mediaRegistry,
parentUuid) < 0) {
char uuidtmp[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(snapshotUuid, uuidtmp);
- if (VIR_STRDUP(newSnapshotPtr->uuid, uuidtmp) < 0)
- goto cleanup;
+ newSnapshotPtr->uuid = g_strdup(uuidtmp);
VIR_DEBUG("New snapshot UUID: %s", newSnapshotPtr->uuid);
- if (VIR_STRDUP(newSnapshotPtr->name, def->parent.name) < 0)
- goto cleanup;
+ newSnapshotPtr->name = g_strdup(def->parent.name);
newSnapshotPtr->timeStamp = virTimeStringThen(def->parent.creationTime * 1000);
- if (VIR_STRDUP(newSnapshotPtr->description, def->parent.description) < 0)
- goto cleanup;
+ newSnapshotPtr->description = g_strdup(def->parent.description);
- if (VIR_STRDUP(newSnapshotPtr->hardware, snapshotMachineDesc->hardware) < 0)
- goto cleanup;
+ newSnapshotPtr->hardware = g_strdup(snapshotMachineDesc->hardware);
- if (VIR_STRDUP(newSnapshotPtr->storageController, snapshotMachineDesc->storageController) < 0)
- goto cleanup;
+ newSnapshotPtr->storageController = g_strdup(snapshotMachineDesc->storageController);
/*We get the parent disk uuid from the parent disk location to correctly fill the storage controller.*/
for (it = 0; it < def->parent.dom->ndisks; it++) {
VIR_FREE(newSnapshotPtr->storageController);
if (!tmp)
goto cleanup;
- if (VIR_STRDUP(newSnapshotPtr->storageController, tmp) < 0)
- goto cleanup;
+ newSnapshotPtr->storageController = g_strdup(tmp);
VIR_FREE(tmp);
}
disk->format = format;
VBOX_UTF16_FREE(formatUtf16);
- if (VIR_STRDUP(disk->location, def->disks[it].src->path) < 0) {
- VIR_FREE(disk);
- goto cleanup;
- }
+ disk->location = g_strdup(def->disks[it].src->path);
rc = gVBoxAPI.UIMedium.GetId(medium, &iid);
if (NS_FAILED(rc)) {
VIR_FREE(snapshotMachineDesc->storageController);
if (!tmp)
goto cleanup;
- if (VIR_STRDUP(snapshotMachineDesc->storageController, tmp) < 0)
- goto cleanup;
+ snapshotMachineDesc->storageController = g_strdup(tmp);
VIR_FREE(tmp);
}
newHardDisk->uuid = uuid;
vboxIIDUnalloc(&iid);
- if (VIR_STRDUP(newHardDisk->location, newLocationUtf8) < 0)
- goto cleanup;
+ newHardDisk->location = g_strdup(newLocationUtf8);
rc = gVBoxAPI.UIMedium.GetFormat(newMedium, &formatUtf16);
VBOX_UTF16_TO_UTF8(formatUtf16, &format);
VIR_FREE(snapshotMachineDesc->storageController);
if (!tmp)
goto cleanup;
- if (VIR_STRDUP(snapshotMachineDesc->storageController, tmp) < 0)
- goto cleanup;
+ snapshotMachineDesc->storageController = g_strdup(tmp);
VIR_FREE(tmp);
/*Closing the "fake" disk*/
}
VBOX_UTF16_TO_UTF8(childLocUtf16, &childLocUtf8);
VBOX_UTF16_FREE(childLocUtf16);
- if (VIR_STRDUP(def->disks[diskCount].src->path, childLocUtf8) < 0) {
- VBOX_RELEASE(storageController);
- VBOX_RELEASE(disk);
- VBOX_RELEASE(child);
- goto cleanup;
- }
+ def->disks[diskCount].src->path = g_strdup(childLocUtf8);
VBOX_UTF8_FREE(childLocUtf8);
def->disks[diskCount].src->type = VIR_STORAGE_TYPE_FILE;
}
VBOX_UTF16_TO_UTF8(mediumLocUtf16, &mediumLocUtf8);
VBOX_UTF16_FREE(mediumLocUtf16);
- if (VIR_STRDUP(defdom->disks[diskCount]->src->path, mediumLocUtf8) < 0)
- goto cleanup;
+ defdom->disks[diskCount]->src->path = g_strdup(mediumLocUtf8);
VBOX_UTF8_FREE(mediumLocUtf8);
rc = gVBoxAPI.UIMedium.GetReadOnly(disk, &readOnly);
!(def->parent.dom = virDomainDefNew()))
goto cleanup;
defdom = def->parent.dom;
- if (VIR_STRDUP(def->parent.name, snapshot->name) < 0)
- goto cleanup;
+ def->parent.name = g_strdup(snapshot->name);
if (gVBoxAPI.vboxSnapshotRedefine) {
/* Register def->dom properties for them to be saved inside the snapshot XMl
defdom->virtType = VIR_DOMAIN_VIRT_VBOX;
defdom->id = dom->id;
memcpy(defdom->uuid, dom->uuid, VIR_UUID_BUFLEN);
- if (VIR_STRDUP(defdom->name, dom->name) < 0)
- goto cleanup;
+ defdom->name = g_strdup(dom->name);
gVBoxAPI.UIMachine.GetMemorySize(machine, &memorySize);
defdom->mem.cur_balloon = memorySize * 1024;
/* Currently setting memory and maxMemory as same, cause
if (str16) {
VBOX_UTF16_TO_UTF8(str16, &str8);
VBOX_UTF16_FREE(str16);
- if (VIR_STRDUP(def->parent.description, str8) < 0) {
- VBOX_UTF8_FREE(str8);
- goto cleanup;
- }
+ def->parent.description = g_strdup(str8);
VBOX_UTF8_FREE(str8);
}
}
VBOX_UTF16_TO_UTF8(str16, &str8);
VBOX_UTF16_FREE(str16);
- if (VIR_STRDUP(def->parent.parent_name, str8) < 0) {
- VBOX_UTF8_FREE(str8);
- goto cleanup;
- }
+ def->parent.parent_name = g_strdup(str8);
VBOX_UTF8_FREE(str8);
}
}
VBOX_UTF16_TO_UTF8(nameUtf16, &name);
VBOX_UTF16_FREE(nameUtf16);
- if (VIR_STRDUP(names[i], name) < 0) {
- VBOX_UTF8_FREE(name);
- goto cleanup;
- }
+ names[i] = g_strdup(name);
VBOX_UTF8_FREE(name);
}
disk->uuid = uuid;
vboxIIDUnalloc(&iid);
- if (VIR_STRDUP(disk->location, newLocationUtf8) < 0) {
- VIR_FREE(disk);
- goto cleanup;
- }
+ disk->location = g_strdup(newLocationUtf8);
rc = gVBoxAPI.UIMedium.GetFormat(newMedium, &formatUtf16);
VBOX_UTF16_TO_UTF8(formatUtf16, &format);
VIR_FREE(snapshotMachineDesc->storageController);
if (!tmp)
goto cleanup;
- if (VIR_STRDUP(snapshotMachineDesc->storageController, tmp) < 0)
- goto cleanup;
+ snapshotMachineDesc->storageController = g_strdup(tmp);
VIR_FREE(tmp);
/*Closing the "fake" disk*/
VIR_FREE(snapshotMachineDesc->storageController);
if (!tmp)
goto cleanup;
- if (VIR_STRDUP(snapshotMachineDesc->storageController, tmp) < 0)
- goto cleanup;
+ snapshotMachineDesc->storageController = g_strdup(tmp);
VIR_FREE(tmp);
}
_("Unable to get the snapshot to remove"));
goto cleanup;
}
- if (VIR_STRDUP(snapshotMachineDesc->currentSnapshot, snap->uuid) < 0)
- goto cleanup;
+ snapshotMachineDesc->currentSnapshot = g_strdup(snap->uuid);
}
}
goto endjob;
}
- if (VIR_STRDUP(ret, "image/png") < 0)
- goto endjob;
+ ret = g_strdup("image/png");
if (virFDStreamOpenFile(st, tmp, 0, 0, O_RDONLY) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
VBOX_UTF16_TO_UTF8(nameUtf16, &nameUtf8);
VIR_DEBUG("nnames[%d]: %s", ret, nameUtf8);
- if (VIR_STRDUP(names[ret], nameUtf8) >= 0)
- ret++;
+ names[ret] = g_strdup(nameUtf8);
+ ret++;
VBOX_UTF8_FREE(nameUtf8);
VBOX_UTF16_FREE(nameUtf16);
VBOX_UTF16_TO_UTF8(nameUtf16, &nameUtf8);
VIR_DEBUG("nnames[%d]: %s", ret, nameUtf8);
- if (VIR_STRDUP(names[ret], nameUtf8) >= 0)
- ret++;
+ names[ret] = g_strdup(nameUtf8);
+ ret++;
VBOX_UTF8_FREE(nameUtf8);
VBOX_UTF16_FREE(nameUtf16);
if (interfaceType != HostNetworkInterfaceType_HostOnly)
goto cleanup;
- if (VIR_STRDUP(def->name, network->name) < 0)
- goto cleanup;
+ def->name = g_strdup(network->name);
rc = gVBoxAPI.UIHNInterface.GetId(networkInterface, &vboxnet0IID);
if (NS_FAILED(rc))
ipdef->nhosts = 1;
if (VIR_ALLOC_N(ipdef->hosts, ipdef->nhosts) >= 0) {
- if (VIR_STRDUP(ipdef->hosts[0].name, network->name) < 0) {
- VIR_FREE(ipdef->hosts);
- ipdef->nhosts = 0;
- } else {
- PRUnichar *macAddressUtf16 = NULL;
- PRUnichar *ipAddressUtf16 = NULL;
- bool errorOccurred = false;
+ PRUnichar *macAddressUtf16 = NULL;
+ PRUnichar *ipAddressUtf16 = NULL;
+ bool errorOccurred = false;
- gVBoxAPI.UIHNInterface.GetHardwareAddress(networkInterface, &macAddressUtf16);
- gVBoxAPI.UIHNInterface.GetIPAddress(networkInterface, &ipAddressUtf16);
+ ipdef->hosts[0].name = g_strdup(network->name);
+ gVBoxAPI.UIHNInterface.GetHardwareAddress(networkInterface, &macAddressUtf16);
+ gVBoxAPI.UIHNInterface.GetIPAddress(networkInterface, &ipAddressUtf16);
- VBOX_UTF16_TO_UTF8(macAddressUtf16, &ipdef->hosts[0].mac);
+ VBOX_UTF16_TO_UTF8(macAddressUtf16, &ipdef->hosts[0].mac);
- if (vboxSocketParseAddrUtf16(data, ipAddressUtf16,
- &ipdef->hosts[0].ip) < 0) {
- errorOccurred = true;
- }
+ if (vboxSocketParseAddrUtf16(data, ipAddressUtf16,
+ &ipdef->hosts[0].ip) < 0) {
+ errorOccurred = true;
+ }
- VBOX_UTF16_FREE(macAddressUtf16);
- VBOX_UTF16_FREE(ipAddressUtf16);
+ VBOX_UTF16_FREE(macAddressUtf16);
+ VBOX_UTF16_FREE(ipAddressUtf16);
- if (errorOccurred)
- goto cleanup;
- }
+ if (errorOccurred)
+ goto cleanup;
} else {
ipdef->nhosts = 0;
}