/* 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);
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);
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;
}
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 */
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 */
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;
#include "viruuid.h"
#include "hyperv_private.h"
#include "hyperv_util.h"
+#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_HYPERV
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")) {
}
}
- 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;