goto cleanup;
}
- if (value[length - 1] != '\0') {
+ if (value[length - 1] != '\0')
value[length] = '\0';
- }
cleanup:
return value;
* the actual version number is in the VersionExt key then. */
value = vboxLookupRegistryValue(key, keyName, "Version");
- if (value == NULL) {
+ if (value == NULL)
goto cleanup;
- }
if (STREQ(value, "%VER%")) {
VIR_FREE(value);
value = vboxLookupRegistryValue(key, keyName, "VersionExt");
- if (value == NULL) {
+ if (value == NULL)
goto cleanup;
- }
}
if (virParseVersionString(value, &vboxVersion, false) < 0) {
int length = WideCharToMultiByte(CP_UTF8, 0, pwszString, -1, NULL, 0,
NULL, NULL);
- if (length < 1) {
+ if (length < 1)
return -1;
- }
- if (VIR_ALLOC_N(*ppszString, length) < 0) {
+ if (VIR_ALLOC_N(*ppszString, length) < 0)
return -1;
- }
return WideCharToMultiByte(CP_UTF8, 0, pwszString, -1, *ppszString,
length, NULL, NULL);
{
int length = MultiByteToWideChar(CP_UTF8, 0, pszString, -1, NULL, 0);
- if (length < 1) {
+ if (length < 1)
return -1;
- }
*ppwszString = SysAllocStringLen(NULL, length);
- if (*ppwszString == NULL) {
+ if (*ppwszString == NULL)
return -1;
- }
return MultiByteToWideChar(CP_UTF8, 0, pszString, -1, *ppwszString, length);
}
int
VBoxCGlueInit(unsigned int *version)
{
- if (vboxLookupVersionInRegistry() < 0) {
+ if (vboxLookupVersionInRegistry() < 0)
return -1;
- }
*version = vboxGetVersion();
g_pfnGetFunctions = vboxGetFunctions;
array->count = 0;
array->handle = NULL;
- if (FAILED(hrc)) {
+ if (FAILED(hrc))
return hrc;
- }
hrc = SafeArrayAccessData(safeArray, (void **)&items);
void
vboxArrayRelease(vboxArray *array)
{
- if (array->handle == NULL) {
+ if (array->handle == NULL)
return;
- }
SafeArrayUnaccessData(array->handle);
SafeArrayDestroy(array->handle);
return -1;
if (!virFileExists(name)) {
- if (!ignoreMissing) {
+ if (!ignoreMissing)
VIR_ERROR(_("Library '%s' doesn't exist"), name);
- }
VIR_FREE(name);
return -1;
* FIXME: Don't warn in this case as it currently breaks make check
* on systems without VirtualBox.
*/
- if (dir != NULL) {
+ if (dir != NULL)
VIR_WARN("Could not dlopen '%s': %s", name, dlerror());
- }
goto cleanup;
}
/* If the user specifies the location, try only that. */
if (home != NULL) {
- if (tryLoadOne(home, false, false, version) < 0) {
+ if (tryLoadOne(home, false, false, version) < 0)
return -1;
- }
}
/* Try the additionally configured location. */
if (VBOX_XPCOMC_DIR[0] != '\0') {
- if (tryLoadOne(VBOX_XPCOMC_DIR, true, true, version) >= 0) {
+ if (tryLoadOne(VBOX_XPCOMC_DIR, true, true, version) >= 0)
return 0;
- }
}
/* Try the known locations. */
for (i = 0; i < ARRAY_CARDINALITY(knownDirs); ++i) {
- if (tryLoadOne(knownDirs[i], true, true, version) >= 0) {
+ if (tryLoadOne(knownDirs[i], true, true, version) >= 0)
return 0;
- }
}
/* Finally try the dynamic linker search path. */
- if (tryLoadOne(NULL, false, true, version) >= 0) {
+ if (tryLoadOne(NULL, false, true, version) >= 0)
return 0;
- }
/* No luck, return failure. */
return -1;
array->items = NULL;
array->count = 0;
- if (NS_FAILED(nsrc)) {
+ if (NS_FAILED(nsrc))
return nsrc;
- }
array->items = items;
array->count = count;
size_t i;
nsISupports *supports;
- if (array->items == NULL) {
+ if (array->items == NULL)
return;
- }
for (i = 0; i < array->count; ++i) {
supports = array->items[i];
- if (supports != NULL) {
+ if (supports != NULL)
supports->vtbl->Release(supports);
- }
}
pVBoxFuncs_v2_2->pfnComUnallocMem(array->items);
size_t i;
void *item;
- if (array->items == NULL) {
+ if (array->items == NULL)
return;
- }
for (i = 0; i < array->count; ++i) {
item = array->items[i];
- if (item != NULL) {
+ if (item != NULL)
pVBoxFuncs_v2_2->pfnComUnallocMem(item);
- }
}
pVBoxFuncs_v2_2->pfnComUnallocMem(array->items);
}
/* Clear the defaults first */
- for (i = 0; i < maxBootPosition; i++) {
+ for (i = 0; i < maxBootPosition; i++)
gVBoxAPI.UIMachine.SetBootOrder(machine, i+1, DeviceType_Null);
- }
for (i = 0; (i < def->os.nBootDevs) && (i < maxBootPosition); i++) {
PRUint32 device = DeviceType_Null;
}
}
- if (STREQ(valueTypeUtf8, "vrdp")) {
+ if (STREQ(valueTypeUtf8, "vrdp"))
vrdpPresent = 1;
- }
if (!vrdpPresent && !sdlPresent && !guiPresent) {
/* if nothing is selected it means either the machine xml
VBOX_UTF8_TO_UTF16("sdl", &sessionType);
}
- if (vrdpPresent) {
+ if (vrdpPresent)
VBOX_UTF8_TO_UTF16("vrdp", &sessionType);
- }
rc = gVBoxAPI.UIMachine.LaunchVMProcess(data, machine, iid,
sessionType, env,
IUSBDeviceFilter *deviceFilter = deviceFilters.items[i];
gVBoxAPI.UIUSBDeviceFilter.GetActive(deviceFilter, &active);
- if (active) {
+ if (active)
def->nhostdevs++;
- }
}
if (def->nhostdevs == 0)
/* cleanup on error */
if (error) {
- for (i = 0; i < def->ndisks; i++) {
+ for (i = 0; i < def->ndisks; i++)
VIR_FREE(def->disks[i]);
- }
VIR_FREE(def->disks);
def->ndisks = 0;
}
}
gVBoxAPI.UIVRDxServer.GetAllowMultiConnection(VRDxServer, &allowMultiConnection);
- if (allowMultiConnection) {
+ if (allowMultiConnection)
def->graphics[def->ngraphics]->data.rdp.multiUser = true;
- }
gVBoxAPI.UIVRDxServer.GetReuseSingleConnection(VRDxServer, &reuseSingleConnection);
- if (reuseSingleConnection) {
+ if (reuseSingleConnection)
def->graphics[def->ngraphics]->data.rdp.replaceUser = true;
- }
def->ngraphics++;
} else {
PRBool enabled = PR_FALSE;
gVBoxAPI.UINetworkAdapter.GetEnabled(adapter, &enabled);
- if (enabled) {
+ if (enabled)
def->nnets++;
- }
VBOX_RELEASE(adapter);
}
/* Allocate memory for the networkcards which are enabled */
if ((def->nnets > 0) && (VIR_ALLOC_N(def->nets, def->nnets) >= 0)) {
- for (i = 0; i < def->nnets; i++) {
+ for (i = 0; i < def->nnets; i++)
ignore_value(VIR_ALLOC(def->nets[i]));
- }
}
/* Now get the details about the network cards here */
PRBool enabled = PR_FALSE;
gVBoxAPI.UISerialPort.GetEnabled(serialPort, &enabled);
- if (enabled) {
+ if (enabled)
def->nserials++;
- }
VBOX_RELEASE(serialPort);
}
/* Allocate memory for the serial ports which are enabled */
if ((def->nserials > 0) && (VIR_ALLOC_N(def->serials, def->nserials) >= 0)) {
- for (i = 0; i < def->nserials; i++) {
+ for (i = 0; i < def->nserials; i++)
ignore_value(VIR_ALLOC(def->serials[i]));
- }
}
/* Now get the details about the serial ports here */
PRBool enabled = PR_FALSE;
gVBoxAPI.UIParallelPort.GetEnabled(parallelPort, &enabled);
- if (enabled) {
+ if (enabled)
def->nparallels++;
- }
VBOX_RELEASE(parallelPort);
}
/* Allocate memory for the parallel ports which are enabled */
if ((def->nparallels > 0) && (VIR_ALLOC_N(def->parallels, def->nparallels) >= 0)) {
- for (i = 0; i < def->nparallels; i++) {
+ for (i = 0; i < def->nparallels; i++)
ignore_value(VIR_ALLOC(def->parallels[i]));
- }
}
/* Now get the details about the parallel ports here */
continue;
gVBoxAPI.UIMachine.GetState(machine, &state);
- if (gVBoxAPI.machineStateChecker.Inactive(state)) {
+ if (gVBoxAPI.machineStateChecker.Inactive(state))
ret++;
- }
}
cleanup:
ret = 0;
cleanup:
if (ret < 0) {
- for (i = 0; i < def->ndisks; i++) {
+ for (i = 0; i < def->ndisks; i++)
VIR_FREE(def->disks[i].src);
- }
VIR_FREE(def->disks);
def->ndisks = 0;
}
def->dom->os.arch = virArchFromHost();
gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);
def->dom->maxvcpus = def->dom->vcpus = CPUCount;
- if (vboxSnapshotGetReadWriteDisks(def, snapshot) < 0) {
+ if (vboxSnapshotGetReadWriteDisks(def, snapshot) < 0)
VIR_DEBUG("Could not get read write disks for snapshot");
- }
- if (vboxSnapshotGetReadOnlyDisks(snapshot, def) < 0) {
+ if (vboxSnapshotGetReadOnlyDisks(snapshot, def) < 0)
VIR_DEBUG("Could not get Readonly disks for snapshot");
- }
}
rc = gVBoxAPI.UISnapshot.GetDescription(snap, &str16);
utf8 = virSocketAddrFormat(addr);
- if (utf8 == NULL) {
+ if (utf8 == NULL)
return NULL;
- }
VBOX_UTF8_TO_UTF16(utf8, &utf16);
VIR_FREE(utf8);
VBOX_UTF16_TO_UTF8(utf16, &utf8);
- if (virSocketAddrParse(addr, utf8, AF_UNSPEC) < 0) {
+ if (virSocketAddrParse(addr, utf8, AF_UNSPEC) < 0)
goto cleanup;
- }
result = 0;
VBOX_UTF16_FREE(fromIPAddressUtf16);
VBOX_UTF16_FREE(toIPAddressUtf16);
- if (errorOccurred) {
+ if (errorOccurred)
goto cleanup;
- }
} else {
ipdef->nranges = 0;
}
VBOX_UTF16_FREE(macAddressUtf16);
VBOX_UTF16_FREE(ipAddressUtf16);
- if (errorOccurred) {
+ if (errorOccurred)
goto cleanup;
- }
}
} else {
ipdef->nhosts = 0;
VBOX_UTF16_FREE(networkMaskUtf16);
VBOX_UTF16_FREE(ipAddressUtf16);
- if (errorOccurred) {
+ if (errorOccurred)
goto cleanup;
- }
}
DEBUGIID("Network UUID", &vboxnet0IID);
xPathContext->node = snapshotNode;
descriptionNode = virXPathNode("./vbox:Description", xPathContext);
- if (descriptionNode != NULL) {
+ if (descriptionNode != NULL)
snapshot->description = virXMLNodeToString(descriptionNode->doc, descriptionNode);
- }
hardwareNode = virXPathNode("./vbox:Hardware", xPathContext);
if (hardwareNode == NULL) {
for (i = 0; i < snapshot->nchildren; i++) {
xmlNodePtr child = xmlNewNode(NULL, BAD_CAST "Snapshot");
xmlAddChild(snapshotsNode, child);
- if (virVBoxSnapshotConfSerializeSnapshot(child, snapshot->children[i]) < 0) {
+ if (virVBoxSnapshotConfSerializeSnapshot(child, snapshot->children[i]) < 0)
goto cleanup;
- }
}
}
result = 0;
goto cleanup;
parentDisk->children[parentDisk->nchildren - 1] = hardDisk;
- if (hardDisk->parent == NULL) {
+ if (hardDisk->parent == NULL)
hardDisk->parent = parentDisk;
- }
ret = 0;
cleanup:
parentSnapshot = snapshot->parent;
snapshot->parent = NULL;
- while (i < parentSnapshot->nchildren && parentSnapshot->children[i] != snapshot) {
+ while (i < parentSnapshot->nchildren && parentSnapshot->children[i] != snapshot)
++i;
- }
if (VIR_DELETE_ELEMENT(parentSnapshot->children, i, parentSnapshot->nchildren) < 0)
goto cleanup;
parentHardDisk = hardDisk->parent;
i = 0;
- while (i < parentHardDisk->nchildren && parentHardDisk->children[i] != hardDisk) {
+ while (i < parentHardDisk->nchildren && parentHardDisk->children[i] != hardDisk)
++i;
- }
hardDisk->parent = NULL;
if (VIR_DELETE_ELEMENT(parentHardDisk->children, i, parentHardDisk->nchildren) < 0)
goto cleanup;
xmlNodePtr node = nodes[i];
xPathContext->node = node;
xmlNodePtr sourceNode = virXPathNode("./source", xPathContext);
- if (sourceNode) {
+ if (sourceNode)
ret[i] = virXMLPropString(sourceNode, "file");
- }
}
result = 0;
xmlNodePtr node = nodes[i];
xPathContext->node = node;
xmlNodePtr sourceNode = virXPathNode("./source", xPathContext);
- if (sourceNode) {
+ if (sourceNode)
ret[i] = virXMLPropString(sourceNode, "file");
- }
}
result = 0;
size_t i;
int ret = -1;
- if (!data->vboxObj) {
+ if (!data->vboxObj)
return ret;
- }
rc = gVBoxAPI.UArray.vboxArrayGet(&hardDisks, data->vboxObj,
gVBoxAPI.UArray.handleGetHardDisks(data->vboxObj));
size_t i;
int ret = -1;
- if (!data->vboxObj) {
+ if (!data->vboxObj)
return ret;
- }
rc = gVBoxAPI.UArray.vboxArrayGet(&hardDisks, data->vboxObj,
gVBoxAPI.UArray.handleGetHardDisks(data->vboxObj));
size_t i;
virStorageVolPtr ret = NULL;
- if (!data->vboxObj) {
+ if (!data->vboxObj)
return ret;
- }
if (!name)
return ret;
nsresult rc;
virStorageVolPtr ret = NULL;
- if (!data->vboxObj) {
+ if (!data->vboxObj)
return ret;
- }
VBOX_IID_INITIALIZE(&hddIID);
if (!key)
nsresult rc;
virStorageVolPtr ret = NULL;
- if (!data->vboxObj) {
+ if (!data->vboxObj)
return ret;
- }
VBOX_IID_INITIALIZE(&hddIID);
resultCodeUnion resultCode;
virStorageVolPtr ret = NULL;
- if (!data->vboxObj) {
+ if (!data->vboxObj)
return ret;
- }
virCheckFlags(0, NULL);
vboxIIDUnion hddIID;
int ret = -1;
- if (!data->vboxObj) {
+ if (!data->vboxObj)
return ret;
- }
VBOX_IID_INITIALIZE(&hddIID);
virCheckFlags(0, -1);
nsresult rc;
int ret = -1;
- if (!data->vboxObj) {
+ if (!data->vboxObj)
return ret;
- }
if (!info)
return ret;
nsresult rc;
char *ret = NULL;
- if (!data->vboxObj) {
+ if (!data->vboxObj)
return ret;
- }
virCheckFlags(0, NULL);
nsresult rc;
char *ret = NULL;
- if (!data->vboxObj) {
+ if (!data->vboxObj)
return ret;
- }
if (virUUIDParse(vol->key, uuid) < 0) {
virReportError(VIR_ERR_INVALID_ARG,
uuidstrdst[16] = uuidstrsrc[14];
uuidstrdst[17] = uuidstrsrc[15];
- for (i = 18; i < VIR_UUID_STRING_BUFLEN; i++) {
+ for (i = 18; i < VIR_UUID_STRING_BUFLEN; i++)
uuidstrdst[i] = uuidstrsrc[i];
- }
uuidstrdst[VIR_UUID_STRING_BUFLEN-1] = '\0';
ignore_value(virUUIDParse(uuidstrdst, uuid));
uuidstrdst[16] = uuidstrsrc[14];
uuidstrdst[17] = uuidstrsrc[15];
- for (i = 18; i < VIR_UUID_STRING_BUFLEN; i++) {
+ for (i = 18; i < VIR_UUID_STRING_BUFLEN; i++)
uuidstrdst[i] = uuidstrsrc[i];
- }
uuidstrdst[VIR_UUID_STRING_BUFLEN-1] = '\0';
ignore_value(virUUIDParse(uuidstrdst, uuidinterim));
static void
vboxIIDUnalloc_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid)
{
- if (iid->value == NULL) {
+ if (iid->value == NULL)
return;
- }
- if (iid->value != &iid->backing) {
+ if (iid->value != &iid->backing)
data->pFuncs->pfnComUnallocMem(iid->value);
- }
iid->value = NULL;
}
static void
vboxIIDUnalloc_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid)
{
- if (iid->value != NULL && iid->owner) {
+ if (iid->value != NULL && iid->owner)
data->pFuncs->pfnUtf16Free(iid->value);
- }
iid->value = NULL;
iid->owner = true;
data->vboxCallback = vboxAllocCallbackObj();
if (data->vboxCallback != NULL) {
rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, data->vboxCallback);
- if (NS_SUCCEEDED(rc)) {
+ if (NS_SUCCEEDED(rc))
vboxRet = 0;
- }
}
} else {
vboxRet = 0;
if (ret >= 0) {
return 0;
} else {
- if (data->vboxObj && data->vboxCallback) {
+ if (data->vboxObj && data->vboxCallback)
data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback);
- }
return -1;
}
}
data->vboxCallback = vboxAllocCallbackObj();
if (data->vboxCallback != NULL) {
rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, data->vboxCallback);
- if (NS_SUCCEEDED(rc)) {
+ if (NS_SUCCEEDED(rc))
vboxRet = 0;
- }
}
} else {
vboxRet = 0;
if (ret >= 0) {
return ret;
} else {
- if (data->vboxObj && data->vboxCallback) {
+ if (data->vboxObj && data->vboxCallback)
data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback);
- }
return -1;
}
}
VBOX_UTF8_TO_UTF16(src, &dvdfileUtf16);
data->vboxObj->vtbl->FindDVDImage(data->vboxObj, dvdfileUtf16, &dvdImage);
- if (!dvdImage) {
+ if (!dvdImage)
data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, dvdemptyuuid.value, &dvdImage);
- }
if (!dvdImage)
goto cleanup;