mirror of https://gitee.com/openkylin/libvirt.git
Adapt to VIR_STRDUP and VIR_STRNDUP in src/hyperv/*
This commit is contained in:
parent
a315f866e2
commit
544cb4375f
|
@ -140,12 +140,8 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags
|
|||
|
||||
/* Request credentials */
|
||||
if (conn->uri->user != NULL) {
|
||||
username = strdup(conn->uri->user);
|
||||
|
||||
if (username == NULL) {
|
||||
virReportOOMError();
|
||||
if (VIR_STRDUP(username, conn->uri->user) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
username = virAuthGetUsername(conn, auth, "hyperv", "administrator", conn->uri->server);
|
||||
|
||||
|
@ -257,12 +253,7 @@ hypervConnectGetHostname(virConnectPtr conn)
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
hostname = strdup(computerSystem->data->DNSHostName);
|
||||
|
||||
if (hostname == NULL) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
ignore_value(VIR_STRDUP(hostname, computerSystem->data->DNSHostName));
|
||||
|
||||
cleanup:
|
||||
hypervFreeObject(priv, (hypervObject *)computerSystem);
|
||||
|
@ -652,13 +643,9 @@ hypervDomainDestroy(virDomainPtr domain)
|
|||
static char *
|
||||
hypervDomainGetOSType(virDomainPtr domain ATTRIBUTE_UNUSED)
|
||||
{
|
||||
char *osType = strdup("hvm");
|
||||
|
||||
if (osType == NULL) {
|
||||
virReportOOMError();
|
||||
return NULL;
|
||||
}
|
||||
char *osType;
|
||||
|
||||
ignore_value(VIR_STRDUP(osType, "hvm"));
|
||||
return osType;
|
||||
}
|
||||
|
||||
|
@ -908,21 +895,11 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
def->name = strdup(computerSystem->data->ElementName);
|
||||
|
||||
if (def->name == NULL) {
|
||||
virReportOOMError();
|
||||
if (VIR_STRDUP(def->name, computerSystem->data->ElementName) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virtualSystemSettingData->data->Notes != NULL) {
|
||||
def->description = strdup(virtualSystemSettingData->data->Notes);
|
||||
|
||||
if (def->description == NULL) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if (VIR_STRDUP(def->description, virtualSystemSettingData->data->Notes) < 0)
|
||||
goto cleanup;
|
||||
|
||||
def->mem.max_balloon = memorySettingData->data->Limit * 1024; /* megabyte to kilobyte */
|
||||
def->mem.cur_balloon = memorySettingData->data->VirtualQuantity * 1024; /* megabyte to kilobyte */
|
||||
|
@ -930,12 +907,8 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
|||
def->vcpus = processorSettingData->data->VirtualQuantity;
|
||||
def->maxvcpus = processorSettingData->data->VirtualQuantity;
|
||||
|
||||
def->os.type = strdup("hvm");
|
||||
|
||||
if (def->os.type == NULL) {
|
||||
virReportOOMError();
|
||||
if (VIR_STRDUP(def->os.type, "hvm") < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* FIXME: devices section is totally missing */
|
||||
|
||||
|
@ -981,12 +954,8 @@ hypervConnectListDefinedDomains(virConnectPtr conn, char **const names, int maxn
|
|||
|
||||
for (computerSystem = computerSystemList; computerSystem != NULL;
|
||||
computerSystem = computerSystem->next) {
|
||||
names[count] = strdup(computerSystem->data->ElementName);
|
||||
|
||||
if (names[count] == NULL) {
|
||||
virReportOOMError();
|
||||
if (VIR_STRDUP(names[count], computerSystem->data->ElementName) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
++count;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "viruuid.h"
|
||||
#include "hyperv_private.h"
|
||||
#include "hyperv_util.h"
|
||||
#include "virstring.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_HYPERV
|
||||
|
||||
|
@ -56,12 +57,8 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri)
|
|||
if (STRCASEEQ(queryParam->name, "transport")) {
|
||||
VIR_FREE((*parsedUri)->transport);
|
||||
|
||||
(*parsedUri)->transport = strdup(queryParam->value);
|
||||
|
||||
if ((*parsedUri)->transport == NULL) {
|
||||
virReportOOMError();
|
||||
if (VIR_STRDUP((*parsedUri)->transport, queryParam->value) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (STRNEQ((*parsedUri)->transport, "http") &&
|
||||
STRNEQ((*parsedUri)->transport, "https")) {
|
||||
|
@ -77,14 +74,9 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri)
|
|||
}
|
||||
}
|
||||
|
||||
if ((*parsedUri)->transport == NULL) {
|
||||
(*parsedUri)->transport = strdup("https");
|
||||
|
||||
if ((*parsedUri)->transport == NULL) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if (!(*parsedUri)->transport &&
|
||||
VIR_STRDUP((*parsedUri)->transport, "https") < 0)
|
||||
goto cleanup;
|
||||
|
||||
result = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue