提交 677ddc82 编写于 作者: M Martin Kletzander

Remove unnecessary curly brackets in src/vbox/

Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
上级 1b7f8ca6
...@@ -385,9 +385,8 @@ vboxLookupRegistryValue(HKEY key, const char *keyName, const char *valueName) ...@@ -385,9 +385,8 @@ vboxLookupRegistryValue(HKEY key, const char *keyName, const char *valueName)
goto cleanup; goto cleanup;
} }
if (value[length - 1] != '\0') { if (value[length - 1] != '\0')
value[length] = '\0'; value[length] = '\0';
}
cleanup: cleanup:
return value; return value;
...@@ -421,18 +420,16 @@ vboxLookupVersionInRegistry(void) ...@@ -421,18 +420,16 @@ vboxLookupVersionInRegistry(void)
* the actual version number is in the VersionExt key then. */ * the actual version number is in the VersionExt key then. */
value = vboxLookupRegistryValue(key, keyName, "Version"); value = vboxLookupRegistryValue(key, keyName, "Version");
if (value == NULL) { if (value == NULL)
goto cleanup; goto cleanup;
}
if (STREQ(value, "%VER%")) { if (STREQ(value, "%VER%")) {
VIR_FREE(value); VIR_FREE(value);
value = vboxLookupRegistryValue(key, keyName, "VersionExt"); value = vboxLookupRegistryValue(key, keyName, "VersionExt");
if (value == NULL) { if (value == NULL)
goto cleanup; goto cleanup;
} }
}
if (virParseVersionString(value, &vboxVersion, false) < 0) { if (virParseVersionString(value, &vboxVersion, false) < 0) {
VIR_ERROR(_("Could not parse version number from '%s'"), value); VIR_ERROR(_("Could not parse version number from '%s'"), value);
...@@ -478,13 +475,11 @@ vboxUtf16ToUtf8(const PRUnichar *pwszString, char **ppszString) ...@@ -478,13 +475,11 @@ vboxUtf16ToUtf8(const PRUnichar *pwszString, char **ppszString)
int length = WideCharToMultiByte(CP_UTF8, 0, pwszString, -1, NULL, 0, int length = WideCharToMultiByte(CP_UTF8, 0, pwszString, -1, NULL, 0,
NULL, NULL); NULL, NULL);
if (length < 1) { if (length < 1)
return -1; return -1;
}
if (VIR_ALLOC_N(*ppszString, length) < 0) { if (VIR_ALLOC_N(*ppszString, length) < 0)
return -1; return -1;
}
return WideCharToMultiByte(CP_UTF8, 0, pwszString, -1, *ppszString, return WideCharToMultiByte(CP_UTF8, 0, pwszString, -1, *ppszString,
length, NULL, NULL); length, NULL, NULL);
...@@ -495,15 +490,13 @@ vboxUtf8ToUtf16(const char *pszString, PRUnichar **ppwszString) ...@@ -495,15 +490,13 @@ vboxUtf8ToUtf16(const char *pszString, PRUnichar **ppwszString)
{ {
int length = MultiByteToWideChar(CP_UTF8, 0, pszString, -1, NULL, 0); int length = MultiByteToWideChar(CP_UTF8, 0, pszString, -1, NULL, 0);
if (length < 1) { if (length < 1)
return -1; return -1;
}
*ppwszString = SysAllocStringLen(NULL, length); *ppwszString = SysAllocStringLen(NULL, length);
if (*ppwszString == NULL) { if (*ppwszString == NULL)
return -1; return -1;
}
return MultiByteToWideChar(CP_UTF8, 0, pszString, -1, *ppwszString, length); return MultiByteToWideChar(CP_UTF8, 0, pszString, -1, *ppwszString, length);
} }
...@@ -668,9 +661,8 @@ vboxGetFunctions(unsigned int version) ...@@ -668,9 +661,8 @@ vboxGetFunctions(unsigned int version)
int int
VBoxCGlueInit(unsigned int *version) VBoxCGlueInit(unsigned int *version)
{ {
if (vboxLookupVersionInRegistry() < 0) { if (vboxLookupVersionInRegistry() < 0)
return -1; return -1;
}
*version = vboxGetVersion(); *version = vboxGetVersion();
g_pfnGetFunctions = vboxGetFunctions; g_pfnGetFunctions = vboxGetFunctions;
...@@ -708,9 +700,8 @@ vboxArrayGetHelper(vboxArray *array, HRESULT hrc, SAFEARRAY *safeArray) ...@@ -708,9 +700,8 @@ vboxArrayGetHelper(vboxArray *array, HRESULT hrc, SAFEARRAY *safeArray)
array->count = 0; array->count = 0;
array->handle = NULL; array->handle = NULL;
if (FAILED(hrc)) { if (FAILED(hrc))
return hrc; return hrc;
}
hrc = SafeArrayAccessData(safeArray, (void **)&items); hrc = SafeArrayAccessData(safeArray, (void **)&items);
...@@ -781,9 +772,8 @@ vboxArrayGetWithUintArg(vboxArray *array, void *self, void *getter, PRUint32 arg ...@@ -781,9 +772,8 @@ vboxArrayGetWithUintArg(vboxArray *array, void *self, void *getter, PRUint32 arg
void void
vboxArrayRelease(vboxArray *array) vboxArrayRelease(vboxArray *array)
{ {
if (array->handle == NULL) { if (array->handle == NULL)
return; return;
}
SafeArrayUnaccessData(array->handle); SafeArrayUnaccessData(array->handle);
SafeArrayDestroy(array->handle); SafeArrayDestroy(array->handle);
......
...@@ -99,9 +99,8 @@ tryLoadOne(const char *dir, bool setAppHome, bool ignoreMissing, ...@@ -99,9 +99,8 @@ tryLoadOne(const char *dir, bool setAppHome, bool ignoreMissing,
return -1; return -1;
if (!virFileExists(name)) { if (!virFileExists(name)) {
if (!ignoreMissing) { if (!ignoreMissing)
VIR_ERROR(_("Library '%s' doesn't exist"), name); VIR_ERROR(_("Library '%s' doesn't exist"), name);
}
VIR_FREE(name); VIR_FREE(name);
return -1; return -1;
...@@ -130,9 +129,8 @@ tryLoadOne(const char *dir, bool setAppHome, bool ignoreMissing, ...@@ -130,9 +129,8 @@ tryLoadOne(const char *dir, bool setAppHome, bool ignoreMissing,
* FIXME: Don't warn in this case as it currently breaks make check * FIXME: Don't warn in this case as it currently breaks make check
* on systems without VirtualBox. * on systems without VirtualBox.
*/ */
if (dir != NULL) { if (dir != NULL)
VIR_WARN("Could not dlopen '%s': %s", name, dlerror()); VIR_WARN("Could not dlopen '%s': %s", name, dlerror());
}
goto cleanup; goto cleanup;
} }
...@@ -206,29 +204,25 @@ VBoxCGlueInit(unsigned int *version) ...@@ -206,29 +204,25 @@ VBoxCGlueInit(unsigned int *version)
/* If the user specifies the location, try only that. */ /* If the user specifies the location, try only that. */
if (home != NULL) { if (home != NULL) {
if (tryLoadOne(home, false, false, version) < 0) { if (tryLoadOne(home, false, false, version) < 0)
return -1; return -1;
} }
}
/* Try the additionally configured location. */ /* Try the additionally configured location. */
if (VBOX_XPCOMC_DIR[0] != '\0') { 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; return 0;
} }
}
/* Try the known locations. */ /* Try the known locations. */
for (i = 0; i < ARRAY_CARDINALITY(knownDirs); ++i) { 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; return 0;
} }
}
/* Finally try the dynamic linker search path. */ /* Finally try the dynamic linker search path. */
if (tryLoadOne(NULL, false, true, version) >= 0) { if (tryLoadOne(NULL, false, true, version) >= 0)
return 0; return 0;
}
/* No luck, return failure. */ /* No luck, return failure. */
return -1; return -1;
...@@ -271,9 +265,8 @@ vboxArrayGetHelper(vboxArray *array, nsresult nsrc, void **items, PRUint32 count ...@@ -271,9 +265,8 @@ vboxArrayGetHelper(vboxArray *array, nsresult nsrc, void **items, PRUint32 count
array->items = NULL; array->items = NULL;
array->count = 0; array->count = 0;
if (NS_FAILED(nsrc)) { if (NS_FAILED(nsrc))
return nsrc; return nsrc;
}
array->items = items; array->items = items;
array->count = count; array->count = count;
...@@ -338,17 +331,15 @@ vboxArrayRelease(vboxArray *array) ...@@ -338,17 +331,15 @@ vboxArrayRelease(vboxArray *array)
size_t i; size_t i;
nsISupports *supports; nsISupports *supports;
if (array->items == NULL) { if (array->items == NULL)
return; return;
}
for (i = 0; i < array->count; ++i) { for (i = 0; i < array->count; ++i) {
supports = array->items[i]; supports = array->items[i];
if (supports != NULL) { if (supports != NULL)
supports->vtbl->Release(supports); supports->vtbl->Release(supports);
} }
}
pVBoxFuncs_v2_2->pfnComUnallocMem(array->items); pVBoxFuncs_v2_2->pfnComUnallocMem(array->items);
...@@ -365,17 +356,15 @@ vboxArrayUnalloc(vboxArray *array) ...@@ -365,17 +356,15 @@ vboxArrayUnalloc(vboxArray *array)
size_t i; size_t i;
void *item; void *item;
if (array->items == NULL) { if (array->items == NULL)
return; return;
}
for (i = 0; i < array->count; ++i) { for (i = 0; i < array->count; ++i) {
item = array->items[i]; item = array->items[i];
if (item != NULL) { if (item != NULL)
pVBoxFuncs_v2_2->pfnComUnallocMem(item); pVBoxFuncs_v2_2->pfnComUnallocMem(item);
} }
}
pVBoxFuncs_v2_2->pfnComUnallocMem(array->items); pVBoxFuncs_v2_2->pfnComUnallocMem(array->items);
......
...@@ -955,9 +955,8 @@ vboxSetBootDeviceOrder(virDomainDefPtr def, vboxGlobalData *data, ...@@ -955,9 +955,8 @@ vboxSetBootDeviceOrder(virDomainDefPtr def, vboxGlobalData *data,
} }
/* Clear the defaults first */ /* Clear the defaults first */
for (i = 0; i < maxBootPosition; i++) { for (i = 0; i < maxBootPosition; i++)
gVBoxAPI.UIMachine.SetBootOrder(machine, i+1, DeviceType_Null); gVBoxAPI.UIMachine.SetBootOrder(machine, i+1, DeviceType_Null);
}
for (i = 0; (i < def->os.nBootDevs) && (i < maxBootPosition); i++) { for (i = 0; (i < def->os.nBootDevs) && (i < maxBootPosition); i++) {
PRUint32 device = DeviceType_Null; PRUint32 device = DeviceType_Null;
...@@ -2115,9 +2114,8 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIIDUnion ...@@ -2115,9 +2114,8 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIIDUnion
} }
} }
if (STREQ(valueTypeUtf8, "vrdp")) { if (STREQ(valueTypeUtf8, "vrdp"))
vrdpPresent = 1; vrdpPresent = 1;
}
if (!vrdpPresent && !sdlPresent && !guiPresent) { if (!vrdpPresent && !sdlPresent && !guiPresent) {
/* if nothing is selected it means either the machine xml /* if nothing is selected it means either the machine xml
...@@ -2159,9 +2157,8 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIIDUnion ...@@ -2159,9 +2157,8 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIIDUnion
VBOX_UTF8_TO_UTF16("sdl", &sessionType); VBOX_UTF8_TO_UTF16("sdl", &sessionType);
} }
if (vrdpPresent) { if (vrdpPresent)
VBOX_UTF8_TO_UTF16("vrdp", &sessionType); VBOX_UTF8_TO_UTF16("vrdp", &sessionType);
}
rc = gVBoxAPI.UIMachine.LaunchVMProcess(data, machine, iid, rc = gVBoxAPI.UIMachine.LaunchVMProcess(data, machine, iid,
sessionType, env, sessionType, env,
...@@ -2995,10 +2992,9 @@ vboxHostDeviceGetXMLDesc(vboxGlobalData *data, virDomainDefPtr def, IMachine *ma ...@@ -2995,10 +2992,9 @@ vboxHostDeviceGetXMLDesc(vboxGlobalData *data, virDomainDefPtr def, IMachine *ma
IUSBDeviceFilter *deviceFilter = deviceFilters.items[i]; IUSBDeviceFilter *deviceFilter = deviceFilters.items[i];
gVBoxAPI.UIUSBDeviceFilter.GetActive(deviceFilter, &active); gVBoxAPI.UIUSBDeviceFilter.GetActive(deviceFilter, &active);
if (active) { if (active)
def->nhostdevs++; def->nhostdevs++;
} }
}
if (def->nhostdevs == 0) if (def->nhostdevs == 0)
goto release_filters; goto release_filters;
...@@ -3222,9 +3218,8 @@ vboxDumpIDEHDDsNew(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) ...@@ -3222,9 +3218,8 @@ vboxDumpIDEHDDsNew(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
/* cleanup on error */ /* cleanup on error */
if (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[i]);
}
VIR_FREE(def->disks); VIR_FREE(def->disks);
def->ndisks = 0; def->ndisks = 0;
} }
...@@ -3393,14 +3388,12 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) ...@@ -3393,14 +3388,12 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
} }
gVBoxAPI.UIVRDxServer.GetAllowMultiConnection(VRDxServer, &allowMultiConnection); gVBoxAPI.UIVRDxServer.GetAllowMultiConnection(VRDxServer, &allowMultiConnection);
if (allowMultiConnection) { if (allowMultiConnection)
def->graphics[def->ngraphics]->data.rdp.multiUser = true; def->graphics[def->ngraphics]->data.rdp.multiUser = true;
}
gVBoxAPI.UIVRDxServer.GetReuseSingleConnection(VRDxServer, &reuseSingleConnection); gVBoxAPI.UIVRDxServer.GetReuseSingleConnection(VRDxServer, &reuseSingleConnection);
if (reuseSingleConnection) { if (reuseSingleConnection)
def->graphics[def->ngraphics]->data.rdp.replaceUser = true; def->graphics[def->ngraphics]->data.rdp.replaceUser = true;
}
def->ngraphics++; def->ngraphics++;
} else { } else {
...@@ -3488,9 +3481,8 @@ vboxDumpNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PR ...@@ -3488,9 +3481,8 @@ vboxDumpNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PR
PRBool enabled = PR_FALSE; PRBool enabled = PR_FALSE;
gVBoxAPI.UINetworkAdapter.GetEnabled(adapter, &enabled); gVBoxAPI.UINetworkAdapter.GetEnabled(adapter, &enabled);
if (enabled) { if (enabled)
def->nnets++; def->nnets++;
}
VBOX_RELEASE(adapter); VBOX_RELEASE(adapter);
} }
...@@ -3498,10 +3490,9 @@ vboxDumpNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PR ...@@ -3498,10 +3490,9 @@ vboxDumpNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PR
/* Allocate memory for the networkcards which are enabled */ /* Allocate memory for the networkcards which are enabled */
if ((def->nnets > 0) && (VIR_ALLOC_N(def->nets, def->nnets) >= 0)) { 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])); ignore_value(VIR_ALLOC(def->nets[i]));
} }
}
/* Now get the details about the network cards here */ /* Now get the details about the network cards here */
for (i = 0; netAdpIncCnt < def->nnets && i < networkAdapterCount; i++) { for (i = 0; netAdpIncCnt < def->nnets && i < networkAdapterCount; i++) {
...@@ -3669,9 +3660,8 @@ vboxDumpSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PRU ...@@ -3669,9 +3660,8 @@ vboxDumpSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PRU
PRBool enabled = PR_FALSE; PRBool enabled = PR_FALSE;
gVBoxAPI.UISerialPort.GetEnabled(serialPort, &enabled); gVBoxAPI.UISerialPort.GetEnabled(serialPort, &enabled);
if (enabled) { if (enabled)
def->nserials++; def->nserials++;
}
VBOX_RELEASE(serialPort); VBOX_RELEASE(serialPort);
} }
...@@ -3679,10 +3669,9 @@ vboxDumpSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PRU ...@@ -3679,10 +3669,9 @@ vboxDumpSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PRU
/* Allocate memory for the serial ports which are enabled */ /* Allocate memory for the serial ports which are enabled */
if ((def->nserials > 0) && (VIR_ALLOC_N(def->serials, def->nserials) >= 0)) { 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])); ignore_value(VIR_ALLOC(def->serials[i]));
} }
}
/* Now get the details about the serial ports here */ /* Now get the details about the serial ports here */
for (i = 0; for (i = 0;
...@@ -3759,9 +3748,8 @@ vboxDumpParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, P ...@@ -3759,9 +3748,8 @@ vboxDumpParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, P
PRBool enabled = PR_FALSE; PRBool enabled = PR_FALSE;
gVBoxAPI.UIParallelPort.GetEnabled(parallelPort, &enabled); gVBoxAPI.UIParallelPort.GetEnabled(parallelPort, &enabled);
if (enabled) { if (enabled)
def->nparallels++; def->nparallels++;
}
VBOX_RELEASE(parallelPort); VBOX_RELEASE(parallelPort);
} }
...@@ -3769,10 +3757,9 @@ vboxDumpParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, P ...@@ -3769,10 +3757,9 @@ vboxDumpParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, P
/* Allocate memory for the parallel ports which are enabled */ /* Allocate memory for the parallel ports which are enabled */
if ((def->nparallels > 0) && (VIR_ALLOC_N(def->parallels, def->nparallels) >= 0)) { 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])); ignore_value(VIR_ALLOC(def->parallels[i]));
} }
}
/* Now get the details about the parallel ports here */ /* Now get the details about the parallel ports here */
for (i = 0; for (i = 0;
...@@ -4078,10 +4065,9 @@ static int vboxConnectNumOfDefinedDomains(virConnectPtr conn) ...@@ -4078,10 +4065,9 @@ static int vboxConnectNumOfDefinedDomains(virConnectPtr conn)
continue; continue;
gVBoxAPI.UIMachine.GetState(machine, &state); gVBoxAPI.UIMachine.GetState(machine, &state);
if (gVBoxAPI.machineStateChecker.Inactive(state)) { if (gVBoxAPI.machineStateChecker.Inactive(state))
ret++; ret++;
} }
}
cleanup: cleanup:
gVBoxAPI.UArray.vboxArrayRelease(&machines); gVBoxAPI.UArray.vboxArrayRelease(&machines);
...@@ -5765,9 +5751,8 @@ static int vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPtr def, ...@@ -5765,9 +5751,8 @@ static int vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPtr def,
ret = 0; ret = 0;
cleanup: cleanup:
if (ret < 0) { 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[i].src);
}
VIR_FREE(def->disks); VIR_FREE(def->disks);
def->ndisks = 0; def->ndisks = 0;
} }
...@@ -6053,14 +6038,12 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, ...@@ -6053,14 +6038,12 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
def->dom->os.arch = virArchFromHost(); def->dom->os.arch = virArchFromHost();
gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount); gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);
def->dom->maxvcpus = def->dom->vcpus = 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"); 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"); VIR_DEBUG("Could not get Readonly disks for snapshot");
} }
}
rc = gVBoxAPI.UISnapshot.GetDescription(snap, &str16); rc = gVBoxAPI.UISnapshot.GetDescription(snap, &str16);
if (NS_FAILED(rc)) { if (NS_FAILED(rc)) {
......
...@@ -429,9 +429,8 @@ vboxSocketFormatAddrUtf16(vboxGlobalData *data, virSocketAddrPtr addr) ...@@ -429,9 +429,8 @@ vboxSocketFormatAddrUtf16(vboxGlobalData *data, virSocketAddrPtr addr)
utf8 = virSocketAddrFormat(addr); utf8 = virSocketAddrFormat(addr);
if (utf8 == NULL) { if (utf8 == NULL)
return NULL; return NULL;
}
VBOX_UTF8_TO_UTF16(utf8, &utf16); VBOX_UTF8_TO_UTF16(utf8, &utf16);
VIR_FREE(utf8); VIR_FREE(utf8);
...@@ -820,9 +819,8 @@ vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16, ...@@ -820,9 +819,8 @@ vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16,
VBOX_UTF16_TO_UTF8(utf16, &utf8); VBOX_UTF16_TO_UTF8(utf16, &utf8);
if (virSocketAddrParse(addr, utf8, AF_UNSPEC) < 0) { if (virSocketAddrParse(addr, utf8, AF_UNSPEC) < 0)
goto cleanup; goto cleanup;
}
result = 0; result = 0;
...@@ -927,9 +925,8 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) ...@@ -927,9 +925,8 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags)
VBOX_UTF16_FREE(fromIPAddressUtf16); VBOX_UTF16_FREE(fromIPAddressUtf16);
VBOX_UTF16_FREE(toIPAddressUtf16); VBOX_UTF16_FREE(toIPAddressUtf16);
if (errorOccurred) { if (errorOccurred)
goto cleanup; goto cleanup;
}
} else { } else {
ipdef->nranges = 0; ipdef->nranges = 0;
} }
...@@ -957,10 +954,9 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) ...@@ -957,10 +954,9 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags)
VBOX_UTF16_FREE(macAddressUtf16); VBOX_UTF16_FREE(macAddressUtf16);
VBOX_UTF16_FREE(ipAddressUtf16); VBOX_UTF16_FREE(ipAddressUtf16);
if (errorOccurred) { if (errorOccurred)
goto cleanup; goto cleanup;
} }
}
} else { } else {
ipdef->nhosts = 0; ipdef->nhosts = 0;
} }
...@@ -982,10 +978,9 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) ...@@ -982,10 +978,9 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags)
VBOX_UTF16_FREE(networkMaskUtf16); VBOX_UTF16_FREE(networkMaskUtf16);
VBOX_UTF16_FREE(ipAddressUtf16); VBOX_UTF16_FREE(ipAddressUtf16);
if (errorOccurred) { if (errorOccurred)
goto cleanup; goto cleanup;
} }
}
DEBUGIID("Network UUID", &vboxnet0IID); DEBUGIID("Network UUID", &vboxnet0IID);
ret = virNetworkDefFormat(def, 0); ret = virNetworkDefFormat(def, 0);
......
...@@ -226,9 +226,8 @@ virVBoxSnapshotConfRetrieveSnapshot(xmlNodePtr snapshotNode, ...@@ -226,9 +226,8 @@ virVBoxSnapshotConfRetrieveSnapshot(xmlNodePtr snapshotNode,
xPathContext->node = snapshotNode; xPathContext->node = snapshotNode;
descriptionNode = virXPathNode("./vbox:Description", xPathContext); descriptionNode = virXPathNode("./vbox:Description", xPathContext);
if (descriptionNode != NULL) { if (descriptionNode != NULL)
snapshot->description = virXMLNodeToString(descriptionNode->doc, descriptionNode); snapshot->description = virXMLNodeToString(descriptionNode->doc, descriptionNode);
}
hardwareNode = virXPathNode("./vbox:Hardware", xPathContext); hardwareNode = virXPathNode("./vbox:Hardware", xPathContext);
if (hardwareNode == NULL) { if (hardwareNode == NULL) {
...@@ -447,11 +446,10 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node, ...@@ -447,11 +446,10 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node,
for (i = 0; i < snapshot->nchildren; i++) { for (i = 0; i < snapshot->nchildren; i++) {
xmlNodePtr child = xmlNewNode(NULL, BAD_CAST "Snapshot"); xmlNodePtr child = xmlNewNode(NULL, BAD_CAST "Snapshot");
xmlAddChild(snapshotsNode, child); xmlAddChild(snapshotsNode, child);
if (virVBoxSnapshotConfSerializeSnapshot(child, snapshot->children[i]) < 0) { if (virVBoxSnapshotConfSerializeSnapshot(child, snapshot->children[i]) < 0)
goto cleanup; goto cleanup;
} }
} }
}
result = 0; result = 0;
cleanup: cleanup:
...@@ -850,9 +848,8 @@ virVBoxSnapshotConfAddHardDiskToMediaRegistry(virVBoxSnapshotConfHardDiskPtr har ...@@ -850,9 +848,8 @@ virVBoxSnapshotConfAddHardDiskToMediaRegistry(virVBoxSnapshotConfHardDiskPtr har
goto cleanup; goto cleanup;
parentDisk->children[parentDisk->nchildren - 1] = hardDisk; parentDisk->children[parentDisk->nchildren - 1] = hardDisk;
if (hardDisk->parent == NULL) { if (hardDisk->parent == NULL)
hardDisk->parent = parentDisk; hardDisk->parent = parentDisk;
}
ret = 0; ret = 0;
cleanup: cleanup:
...@@ -915,9 +912,8 @@ virVBoxSnapshotConfRemoveSnapshot(virVBoxSnapshotConfMachinePtr machine, ...@@ -915,9 +912,8 @@ virVBoxSnapshotConfRemoveSnapshot(virVBoxSnapshotConfMachinePtr machine,
parentSnapshot = snapshot->parent; parentSnapshot = snapshot->parent;
snapshot->parent = NULL; snapshot->parent = NULL;
while (i < parentSnapshot->nchildren && parentSnapshot->children[i] != snapshot) { while (i < parentSnapshot->nchildren && parentSnapshot->children[i] != snapshot)
++i; ++i;
}
if (VIR_DELETE_ELEMENT(parentSnapshot->children, i, parentSnapshot->nchildren) < 0) if (VIR_DELETE_ELEMENT(parentSnapshot->children, i, parentSnapshot->nchildren) < 0)
goto cleanup; goto cleanup;
...@@ -975,9 +971,8 @@ virVBoxSnapshotConfRemoveHardDisk(virVBoxSnapshotConfMediaRegistryPtr mediaRegis ...@@ -975,9 +971,8 @@ virVBoxSnapshotConfRemoveHardDisk(virVBoxSnapshotConfMediaRegistryPtr mediaRegis
parentHardDisk = hardDisk->parent; parentHardDisk = hardDisk->parent;
i = 0; i = 0;
while (i < parentHardDisk->nchildren && parentHardDisk->children[i] != hardDisk) { while (i < parentHardDisk->nchildren && parentHardDisk->children[i] != hardDisk)
++i; ++i;
}
hardDisk->parent = NULL; hardDisk->parent = NULL;
if (VIR_DELETE_ELEMENT(parentHardDisk->children, i, parentHardDisk->nchildren) < 0) if (VIR_DELETE_ELEMENT(parentHardDisk->children, i, parentHardDisk->nchildren) < 0)
goto cleanup; goto cleanup;
...@@ -1320,10 +1315,9 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char *filePath, ...@@ -1320,10 +1315,9 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char *filePath,
xmlNodePtr node = nodes[i]; xmlNodePtr node = nodes[i];
xPathContext->node = node; xPathContext->node = node;
xmlNodePtr sourceNode = virXPathNode("./source", xPathContext); xmlNodePtr sourceNode = virXPathNode("./source", xPathContext);
if (sourceNode) { if (sourceNode)
ret[i] = virXMLPropString(sourceNode, "file"); ret[i] = virXMLPropString(sourceNode, "file");
} }
}
result = 0; result = 0;
cleanup: cleanup:
...@@ -1382,10 +1376,9 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char *filePath, ...@@ -1382,10 +1376,9 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char *filePath,
xmlNodePtr node = nodes[i]; xmlNodePtr node = nodes[i];
xPathContext->node = node; xPathContext->node = node;
xmlNodePtr sourceNode = virXPathNode("./source", xPathContext); xmlNodePtr sourceNode = virXPathNode("./source", xPathContext);
if (sourceNode) { if (sourceNode)
ret[i] = virXMLPropString(sourceNode, "file"); ret[i] = virXMLPropString(sourceNode, "file");
} }
}
result = 0; result = 0;
cleanup: cleanup:
......
...@@ -120,9 +120,8 @@ static int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool) ...@@ -120,9 +120,8 @@ static int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
size_t i; size_t i;
int ret = -1; int ret = -1;
if (!data->vboxObj) { if (!data->vboxObj)
return ret; return ret;
}
rc = gVBoxAPI.UArray.vboxArrayGet(&hardDisks, data->vboxObj, rc = gVBoxAPI.UArray.vboxArrayGet(&hardDisks, data->vboxObj,
gVBoxAPI.UArray.handleGetHardDisks(data->vboxObj)); gVBoxAPI.UArray.handleGetHardDisks(data->vboxObj));
...@@ -162,9 +161,8 @@ vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, int nname ...@@ -162,9 +161,8 @@ vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, int nname
size_t i; size_t i;
int ret = -1; int ret = -1;
if (!data->vboxObj) { if (!data->vboxObj)
return ret; return ret;
}
rc = gVBoxAPI.UArray.vboxArrayGet(&hardDisks, data->vboxObj, rc = gVBoxAPI.UArray.vboxArrayGet(&hardDisks, data->vboxObj,
gVBoxAPI.UArray.handleGetHardDisks(data->vboxObj)); gVBoxAPI.UArray.handleGetHardDisks(data->vboxObj));
...@@ -218,9 +216,8 @@ vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *name) ...@@ -218,9 +216,8 @@ vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *name)
size_t i; size_t i;
virStorageVolPtr ret = NULL; virStorageVolPtr ret = NULL;
if (!data->vboxObj) { if (!data->vboxObj)
return ret; return ret;
}
if (!name) if (!name)
return ret; return ret;
...@@ -296,9 +293,8 @@ vboxStorageVolLookupByKey(virConnectPtr conn, const char *key) ...@@ -296,9 +293,8 @@ vboxStorageVolLookupByKey(virConnectPtr conn, const char *key)
nsresult rc; nsresult rc;
virStorageVolPtr ret = NULL; virStorageVolPtr ret = NULL;
if (!data->vboxObj) { if (!data->vboxObj)
return ret; return ret;
}
VBOX_IID_INITIALIZE(&hddIID); VBOX_IID_INITIALIZE(&hddIID);
if (!key) if (!key)
...@@ -366,9 +362,8 @@ vboxStorageVolLookupByPath(virConnectPtr conn, const char *path) ...@@ -366,9 +362,8 @@ vboxStorageVolLookupByPath(virConnectPtr conn, const char *path)
nsresult rc; nsresult rc;
virStorageVolPtr ret = NULL; virStorageVolPtr ret = NULL;
if (!data->vboxObj) { if (!data->vboxObj)
return ret; return ret;
}
VBOX_IID_INITIALIZE(&hddIID); VBOX_IID_INITIALIZE(&hddIID);
...@@ -449,9 +444,8 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, ...@@ -449,9 +444,8 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
resultCodeUnion resultCode; resultCodeUnion resultCode;
virStorageVolPtr ret = NULL; virStorageVolPtr ret = NULL;
if (!data->vboxObj) { if (!data->vboxObj)
return ret; return ret;
}
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
...@@ -553,9 +547,8 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags) ...@@ -553,9 +547,8 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags)
vboxIIDUnion hddIID; vboxIIDUnion hddIID;
int ret = -1; int ret = -1;
if (!data->vboxObj) { if (!data->vboxObj)
return ret; return ret;
}
VBOX_IID_INITIALIZE(&hddIID); VBOX_IID_INITIALIZE(&hddIID);
virCheckFlags(0, -1); virCheckFlags(0, -1);
...@@ -707,9 +700,8 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info ...@@ -707,9 +700,8 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info
nsresult rc; nsresult rc;
int ret = -1; int ret = -1;
if (!data->vboxObj) { if (!data->vboxObj)
return ret; return ret;
}
if (!info) if (!info)
return ret; return ret;
...@@ -767,9 +759,8 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) ...@@ -767,9 +759,8 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
nsresult rc; nsresult rc;
char *ret = NULL; char *ret = NULL;
if (!data->vboxObj) { if (!data->vboxObj)
return ret; return ret;
}
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
...@@ -856,9 +847,8 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol) ...@@ -856,9 +847,8 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol)
nsresult rc; nsresult rc;
char *ret = NULL; char *ret = NULL;
if (!data->vboxObj) { if (!data->vboxObj)
return ret; return ret;
}
if (virUUIDParse(vol->key, uuid) < 0) { if (virUUIDParse(vol->key, uuid) < 0) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
......
...@@ -251,9 +251,8 @@ static void nsIDtoChar(unsigned char *uuid, const nsID *iid) ...@@ -251,9 +251,8 @@ static void nsIDtoChar(unsigned char *uuid, const nsID *iid)
uuidstrdst[16] = uuidstrsrc[14]; uuidstrdst[16] = uuidstrsrc[14];
uuidstrdst[17] = uuidstrsrc[15]; 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[i] = uuidstrsrc[i];
}
uuidstrdst[VIR_UUID_STRING_BUFLEN-1] = '\0'; uuidstrdst[VIR_UUID_STRING_BUFLEN-1] = '\0';
ignore_value(virUUIDParse(uuidstrdst, uuid)); ignore_value(virUUIDParse(uuidstrdst, uuid));
...@@ -291,9 +290,8 @@ static void nsIDFromChar(nsID *iid, const unsigned char *uuid) ...@@ -291,9 +290,8 @@ static void nsIDFromChar(nsID *iid, const unsigned char *uuid)
uuidstrdst[16] = uuidstrsrc[14]; uuidstrdst[16] = uuidstrsrc[14];
uuidstrdst[17] = uuidstrsrc[15]; 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[i] = uuidstrsrc[i];
}
uuidstrdst[VIR_UUID_STRING_BUFLEN-1] = '\0'; uuidstrdst[VIR_UUID_STRING_BUFLEN-1] = '\0';
ignore_value(virUUIDParse(uuidstrdst, uuidinterim)); ignore_value(virUUIDParse(uuidstrdst, uuidinterim));
...@@ -399,13 +397,11 @@ typedef struct _vboxIID_v2_x vboxIID_v2_x; ...@@ -399,13 +397,11 @@ typedef struct _vboxIID_v2_x vboxIID_v2_x;
static void static void
vboxIIDUnalloc_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid) vboxIIDUnalloc_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid)
{ {
if (iid->value == NULL) { if (iid->value == NULL)
return; return;
}
if (iid->value != &iid->backing) { if (iid->value != &iid->backing)
data->pFuncs->pfnComUnallocMem(iid->value); data->pFuncs->pfnComUnallocMem(iid->value);
}
iid->value = NULL; iid->value = NULL;
} }
...@@ -500,9 +496,8 @@ typedef struct _vboxIID_v3_x vboxIID_v3_x; ...@@ -500,9 +496,8 @@ typedef struct _vboxIID_v3_x vboxIID_v3_x;
static void static void
vboxIIDUnalloc_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid) 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); data->pFuncs->pfnUtf16Free(iid->value);
}
iid->value = NULL; iid->value = NULL;
iid->owner = true; iid->owner = true;
...@@ -1770,10 +1765,9 @@ vboxConnectDomainEventRegister(virConnectPtr conn, ...@@ -1770,10 +1765,9 @@ vboxConnectDomainEventRegister(virConnectPtr conn,
data->vboxCallback = vboxAllocCallbackObj(); data->vboxCallback = vboxAllocCallbackObj();
if (data->vboxCallback != NULL) { if (data->vboxCallback != NULL) {
rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, data->vboxCallback); rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, data->vboxCallback);
if (NS_SUCCEEDED(rc)) { if (NS_SUCCEEDED(rc))
vboxRet = 0; vboxRet = 0;
} }
}
} else { } else {
vboxRet = 0; vboxRet = 0;
} }
...@@ -1809,9 +1803,8 @@ vboxConnectDomainEventRegister(virConnectPtr conn, ...@@ -1809,9 +1803,8 @@ vboxConnectDomainEventRegister(virConnectPtr conn,
if (ret >= 0) { if (ret >= 0) {
return 0; return 0;
} else { } else {
if (data->vboxObj && data->vboxCallback) { if (data->vboxObj && data->vboxCallback)
data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback); data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback);
}
return -1; return -1;
} }
} }
...@@ -1876,10 +1869,9 @@ static int vboxConnectDomainEventRegisterAny(virConnectPtr conn, ...@@ -1876,10 +1869,9 @@ static int vboxConnectDomainEventRegisterAny(virConnectPtr conn,
data->vboxCallback = vboxAllocCallbackObj(); data->vboxCallback = vboxAllocCallbackObj();
if (data->vboxCallback != NULL) { if (data->vboxCallback != NULL) {
rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, data->vboxCallback); rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, data->vboxCallback);
if (NS_SUCCEEDED(rc)) { if (NS_SUCCEEDED(rc))
vboxRet = 0; vboxRet = 0;
} }
}
} else { } else {
vboxRet = 0; vboxRet = 0;
} }
...@@ -1917,9 +1909,8 @@ static int vboxConnectDomainEventRegisterAny(virConnectPtr conn, ...@@ -1917,9 +1909,8 @@ static int vboxConnectDomainEventRegisterAny(virConnectPtr conn,
if (ret >= 0) { if (ret >= 0) {
return ret; return ret;
} else { } else {
if (data->vboxObj && data->vboxCallback) { if (data->vboxObj && data->vboxCallback)
data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback); data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback);
}
return -1; return -1;
} }
} }
...@@ -2350,9 +2341,8 @@ _attachDVD(vboxGlobalData *data, IMachine *machine, const char *src) ...@@ -2350,9 +2341,8 @@ _attachDVD(vboxGlobalData *data, IMachine *machine, const char *src)
VBOX_UTF8_TO_UTF16(src, &dvdfileUtf16); VBOX_UTF8_TO_UTF16(src, &dvdfileUtf16);
data->vboxObj->vtbl->FindDVDImage(data->vboxObj, dvdfileUtf16, &dvdImage); data->vboxObj->vtbl->FindDVDImage(data->vboxObj, dvdfileUtf16, &dvdImage);
if (!dvdImage) { if (!dvdImage)
data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, dvdemptyuuid.value, &dvdImage); data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, dvdemptyuuid.value, &dvdImage);
}
if (!dvdImage) if (!dvdImage)
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册