hyperv: use g_new0 instead of VIR_ALLOC*

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Ján Tomko 2020-09-23 20:44:11 +02:00
parent 3f8a30cd7d
commit 535d78630f
3 changed files with 9 additions and 20 deletions

View File

@ -128,8 +128,7 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
/* Allocate per-connection private data */
if (VIR_ALLOC(priv) < 0)
goto cleanup;
priv = g_new0(hypervPrivate, 1);
if (hypervParseUri(&priv->parsedUri, conn->uri) < 0)
goto cleanup;
@ -1221,8 +1220,8 @@ hypervConnectListAllDomains(virConnectPtr conn,
!MATCH(VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART)) ||
(MATCH(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT) &&
!MATCH(VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT))) {
if (domains && VIR_ALLOC_N(*domains, 1) < 0)
goto cleanup;
if (domains)
*domains = g_new0(virDomainPtr, 1);
ret = 0;
goto cleanup;
@ -1251,8 +1250,7 @@ hypervConnectListAllDomains(virConnectPtr conn,
goto cleanup;
if (domains) {
if (VIR_ALLOC_N(doms, 1) < 0)
goto cleanup;
doms = g_new0(virDomainPtr, 1);
ndoms = 1;
}
@ -1357,8 +1355,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset,
if (hypervGetMsvmKeyboardList(priv, &query, &keyboard) < 0)
goto cleanup;
if (VIR_ALLOC_N(translatedKeycodes, nkeycodes) < 0)
goto cleanup;
translatedKeycodes = g_new0(int, nkeycodes);
/* translate keycodes to win32 and generate keyup scancodes. */
for (i = 0; i < nkeycodes; i++) {

View File

@ -45,8 +45,7 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri)
return -1;
}
if (VIR_ALLOC(*parsedUri) < 0)
return -1;
*parsedUri = g_new0(hypervParsedUri, 1);
for (i = 0; i < uri->paramsCount; i++) {
virURIParamPtr queryParam = &uri->params[i];

View File

@ -176,14 +176,9 @@ hypervCreateInvokeParamsList(hypervPrivate *priv, const char *method,
if (hypervGetWmiClassInfo(priv, obj, &info) < 0)
return NULL;
if (VIR_ALLOC(params) < 0)
return NULL;
params = g_new0(hypervInvokeParamsList, 1);
if (VIR_ALLOC_N(params->params,
HYPERV_DEFAULT_PARAM_COUNT) < 0) {
VIR_FREE(params);
return NULL;
}
params->params = g_new0(hypervParam, HYPERV_DEFAULT_PARAM_COUNT);
params->method = method;
params->ns = info->rootUri;
@ -1052,9 +1047,7 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr wqlQuery,
goto cleanup;
}
if (VIR_ALLOC(object) < 0)
goto cleanup;
object = g_new0(hypervObject, 1);
object->info = wmiInfo;
object->data.common = data;