[libvirt PATCH 0/8] delete VIR_ALLOC and VIR_ALLOC_N (glib chronicles)

Ján Tomko (8): remote: refactor remoteSerializeDHCPLease libxl: xenParseXMOS: separate VIR_ALLOC call remote: use g_new0 instead of VIR_ALLOC remote: remoteDispatchAuthList: remove useless 'rv' src: use g_new0 instead of VIR_ALLOC tests: use g_new0 instead of VIR_ALLOC tests: delete VIR_ALLOC tests cases util: delete VIR_ALLOC and VIR_ALLOC_N src/access/viraccessmanager.c | 3 +- src/admin/admin_server_dispatch.c | 6 +- src/hypervisor/domain_driver.c | 3 +- src/hypervisor/virclosecallbacks.c | 7 +- src/libvirt_private.syms | 2 - src/libxl/xen_xm.c | 9 +- src/remote/remote_daemon_config.c | 3 +- src/remote/remote_daemon_dispatch.c | 279 +++++++++------------------- src/remote/remote_daemon_stream.c | 6 +- src/remote/remote_driver.c | 102 +++------- src/test/test_driver.c | 66 +++---- src/util/viralloc.c | 39 ---- src/util/viralloc.h | 33 ---- tests/viralloctest.c | 89 +-------- 14 files changed, 157 insertions(+), 490 deletions(-) -- 2.26.2

Use g_new0 for allocation and remove all the temporary variables. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/remote/remote_daemon_dispatch.c | 47 +++++------------------------ 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index c187932a3c..a659737bc7 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -6684,11 +6684,6 @@ remoteDispatchNodeGetFreePages(virNetServerPtr server G_GNUC_UNUSED, static int remoteSerializeDHCPLease(remote_network_dhcp_lease *lease_dst, virNetworkDHCPLeasePtr lease_src) { - char **mac_tmp = NULL; - char **iaid_tmp = NULL; - char **hostname_tmp = NULL; - char **clientid_tmp = NULL; - lease_dst->expirytime = lease_src->expirytime; lease_dst->type = lease_src->type; lease_dst->prefix = lease_src->prefix; @@ -6697,49 +6692,23 @@ remoteSerializeDHCPLease(remote_network_dhcp_lease *lease_dst, virNetworkDHCPLea lease_dst->ipaddr = g_strdup(lease_src->ipaddr); if (lease_src->mac) { - if (VIR_ALLOC(mac_tmp) < 0) - goto error; - *mac_tmp = g_strdup(lease_src->mac); + lease_dst->mac = g_new0(char *, 1); + *lease_dst->mac = g_strdup(lease_src->mac); } if (lease_src->iaid) { - if (VIR_ALLOC(iaid_tmp) < 0) - goto error; - *iaid_tmp = g_strdup(lease_src->iaid); + lease_dst->iaid = g_new0(char *, 1); + *lease_dst->iaid = g_strdup(lease_src->iaid); } if (lease_src->hostname) { - if (VIR_ALLOC(hostname_tmp) < 0) - goto error; - *hostname_tmp = g_strdup(lease_src->hostname); + lease_dst->hostname = g_new0(char *, 1); + *lease_dst->hostname = g_strdup(lease_src->hostname); } if (lease_src->clientid) { - if (VIR_ALLOC(clientid_tmp) < 0) - goto error; - *clientid_tmp = g_strdup(lease_src->clientid); + lease_dst->clientid = g_new0(char *, 1); + *lease_dst->clientid = g_strdup(lease_src->clientid); } - lease_dst->mac = mac_tmp; - lease_dst->iaid = iaid_tmp; - lease_dst->hostname = hostname_tmp; - lease_dst->clientid = clientid_tmp; - return 0; - - error: - if (mac_tmp) - VIR_FREE(*mac_tmp); - if (iaid_tmp) - VIR_FREE(*iaid_tmp); - if (hostname_tmp) - VIR_FREE(*hostname_tmp); - if (clientid_tmp) - VIR_FREE(*clientid_tmp); - VIR_FREE(mac_tmp); - VIR_FREE(iaid_tmp); - VIR_FREE(hostname_tmp); - VIR_FREE(clientid_tmp); - VIR_FREE(lease_dst->ipaddr); - VIR_FREE(lease_dst->iface); - return -1; } -- 2.26.2

To reduce churn in the following patches. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/libxl/xen_xm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index 8ade5aec1c..6d00f47544 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -42,8 +42,10 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def) if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { g_autofree char *boot = NULL; - if (VIR_ALLOC(def->os.loader) < 0 || - xenConfigCopyString(conf, "kernel", &def->os.loader->path) < 0) + if (VIR_ALLOC(def->os.loader) < 0) + return -1; + + if (xenConfigCopyString(conf, "kernel", &def->os.loader->path) < 0) return -1; if (xenConfigGetString(conf, "boot", &boot, "c") < 0) -- 2.26.2

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/remote/remote_daemon_config.c | 3 +- src/remote/remote_daemon_dispatch.c | 225 ++++++++++------------------ src/remote/remote_daemon_stream.c | 6 +- src/remote/remote_driver.c | 102 ++++--------- 4 files changed, 108 insertions(+), 228 deletions(-) diff --git a/src/remote/remote_daemon_config.c b/src/remote/remote_daemon_config.c index a09f287656..f0cca42925 100644 --- a/src/remote/remote_daemon_config.c +++ b/src/remote/remote_daemon_config.c @@ -94,8 +94,7 @@ daemonConfigNew(bool privileged G_GNUC_UNUSED) { struct daemonConfig *data; - if (VIR_ALLOC(data) < 0) - return NULL; + data = g_new0(struct daemonConfig, 1); #ifdef WITH_IP # ifdef LIBVIRTD diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index a659737bc7..90115167fb 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -1597,8 +1597,7 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr conn, data.seconds = seconds; data.micros = micros; if (details) { - if (VIR_ALLOC(data.details) < 0) - goto error; + data.details = g_new0(char *, 1); *(data.details) = g_strdup(details); } make_nonnull_domain(&data.dom, dom); @@ -1608,11 +1607,6 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr conn, (xdrproc_t)xdr_qemu_domain_monitor_event_msg, &data); return; - - error: - xdr_free((xdrproc_t)xdr_qemu_domain_monitor_event_msg, - (char *) &data); - return; } static @@ -1907,8 +1901,7 @@ void *remoteClientNew(virNetServerClientPtr client, { struct daemonClientPrivate *priv; - if (VIR_ALLOC(priv) < 0) - return NULL; + priv = g_new0(struct daemonClientPrivate, 1); if (virMutexInit(&priv->lock) < 0) { VIR_FREE(priv); @@ -2309,8 +2302,8 @@ remoteDispatchDomainGetSchedulerParameters(virNetServerPtr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params = g_new0(virTypedParameter, args->nparams); nparams = args->nparams; if (!(dom = get_nonnull_domain(conn, args->dom))) @@ -2357,8 +2350,8 @@ remoteDispatchDomainGetSchedulerParametersFlags(virNetServerPtr server G_GNUC_UN virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params = g_new0(virTypedParameter, args->nparams); nparams = args->nparams; if (!(dom = get_nonnull_domain(conn, args->dom))) @@ -2413,16 +2406,14 @@ remoteDispatchDomainMemoryStats(virNetServerPtr server G_GNUC_UNUSED, goto cleanup; /* Allocate stats array for making dispatch call */ - if (VIR_ALLOC_N(stats, args->maxStats) < 0) - goto cleanup; + stats = g_new0(struct _virDomainMemoryStat, args->maxStats); nr_stats = virDomainMemoryStats(dom, stats, args->maxStats, args->flags); if (nr_stats < 0) goto cleanup; /* Allocate return buffer */ - if (VIR_ALLOC_N(ret->stats.stats_val, args->maxStats) < 0) - goto cleanup; + ret->stats.stats_val = g_new0(remote_domain_memory_stat, args->maxStats); /* Copy the stats into the xdr return structure */ for (i = 0; i < nr_stats; i++) { @@ -2473,8 +2464,7 @@ remoteDispatchDomainBlockPeek(virNetServerPtr server G_GNUC_UNUSED, } ret->buffer.buffer_len = size; - if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) - goto cleanup; + ret->buffer.buffer_val = g_new0(char, size); if (virDomainBlockPeek(dom, path, offset, size, ret->buffer.buffer_val, flags) < 0) @@ -2518,8 +2508,8 @@ remoteDispatchDomainBlockStatsFlags(virNetServerPtr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params = g_new0(virTypedParameter, args->nparams); nparams = args->nparams; if (virDomainBlockStatsFlags(dom, path, params, &nparams, flags) < 0) @@ -2583,8 +2573,7 @@ remoteDispatchDomainMemoryPeek(virNetServerPtr server G_GNUC_UNUSED, } ret->buffer.buffer_len = size; - if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) - goto cleanup; + ret->buffer.buffer_val = g_new0(char, size); if (virDomainMemoryPeek(dom, offset, size, ret->buffer.buffer_val, flags) < 0) @@ -2620,15 +2609,13 @@ remoteDispatchDomainGetSecurityLabel(virNetServerPtr server G_GNUC_UNUSED, if (!(dom = get_nonnull_domain(conn, args->dom))) goto cleanup; - if (VIR_ALLOC(seclabel) < 0) - goto cleanup; + seclabel = g_new0(virSecurityLabel, 1); if (virDomainGetSecurityLabel(dom, seclabel) < 0) goto cleanup; ret->label.label_len = strlen(seclabel->label) + 1; - if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) - goto cleanup; + ret->label.label_val = g_new0(char, ret->label.label_len); strcpy(ret->label.label_val, seclabel->label); ret->enforcing = seclabel->enforcing; @@ -2669,8 +2656,7 @@ remoteDispatchDomainGetSecurityLabelList(virNetServerPtr server G_GNUC_UNUSED, goto done; } - if (VIR_ALLOC_N(ret->labels.labels_val, len) < 0) - goto cleanup; + ret->labels.labels_val = g_new0(remote_domain_get_security_label_ret, len); for (i = 0; i < len; i++) { size_t label_len = strlen(seclabels[i].label) + 1; @@ -2711,13 +2697,11 @@ remoteDispatchNodeGetSecurityModel(virNetServerPtr server G_GNUC_UNUSED, goto cleanup; ret->model.model_len = strlen(secmodel.model) + 1; - if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0) - goto cleanup; + ret->model.model_val = g_new0(char, ret->model.model_len); strcpy(ret->model.model_val, secmodel.model); ret->doi.doi_len = strlen(secmodel.doi) + 1; - if (VIR_ALLOC_N(ret->doi.doi_val, ret->doi.doi_len) < 0) - goto cleanup; + ret->doi.doi_val = g_new0(char, ret->doi.doi_len); strcpy(ret->doi.doi_val, secmodel.doi); rv = 0; @@ -2760,9 +2744,8 @@ remoteDispatchDomainGetVcpuPinInfo(virNetServerPtr server G_GNUC_UNUSED, } /* Allocate buffers to take the results. */ - if (args->maplen > 0 && - VIR_ALLOC_N(cpumaps, args->ncpumaps * args->maplen) < 0) - goto cleanup; + if (args->maplen > 0) + cpumaps = g_new0(unsigned char, args->ncpumaps * args->maplen); if ((num = virDomainGetVcpuPinInfo(dom, args->ncpumaps, @@ -2844,9 +2827,8 @@ remoteDispatchDomainGetEmulatorPinInfo(virNetServerPtr server G_GNUC_UNUSED, goto cleanup; /* Allocate buffers to take the results */ - if (args->maplen > 0 && - VIR_ALLOC_N(cpumaps, args->maplen) < 0) - goto cleanup; + if (args->maplen > 0) + cpumaps = g_new0(unsigned char, args->maplen); if ((r = virDomainGetEmulatorPinInfo(dom, cpumaps, @@ -2903,11 +2885,9 @@ remoteDispatchDomainGetVcpus(virNetServerPtr server G_GNUC_UNUSED, } /* Allocate buffers to take the results. */ - if (VIR_ALLOC_N(info, args->maxinfo) < 0) - goto cleanup; - if (args->maplen > 0 && - VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0) - goto cleanup; + info = g_new0(virVcpuInfo, args->maxinfo); + if (args->maplen > 0) + cpumaps = g_new0(unsigned char, args->maxinfo * args->maplen); if ((info_len = virDomainGetVcpus(dom, info, args->maxinfo, @@ -2916,8 +2896,7 @@ remoteDispatchDomainGetVcpus(virNetServerPtr server G_GNUC_UNUSED, /* Allocate the return buffer for info. */ ret->info.info_len = info_len; - if (VIR_ALLOC_N(ret->info.info_val, info_len) < 0) - goto cleanup; + ret->info.info_val = g_new0(remote_vcpu_info, info_len); for (i = 0; i < info_len; ++i) { ret->info.info_val[i].number = info[i].number; @@ -2980,9 +2959,7 @@ remoteDispatchDomainGetIOThreadInfo(virNetServerPtr server G_GNUC_UNUSED, } if (ninfo) { - if (VIR_ALLOC_N(ret->info.info_val, ninfo) < 0) - goto cleanup; - + ret->info.info_val = g_new0(remote_domain_iothread_info, ninfo); ret->info.info_len = ninfo; for (i = 0; i < ninfo; i++) { @@ -3040,8 +3017,7 @@ remoteDispatchDomainMigratePrepare(virNetServerPtr server G_GNUC_UNUSED, dname = args->dname == NULL ? NULL : *args->dname; /* Wacky world of XDR ... */ - if (VIR_ALLOC(uri_out) < 0) - goto cleanup; + uri_out = g_new0(char *, 1); if (virDomainMigratePrepare(conn, &cookie, &cookielen, uri_in, uri_out, @@ -3092,8 +3068,7 @@ remoteDispatchDomainMigratePrepare2(virNetServerPtr server G_GNUC_UNUSED, dname = args->dname == NULL ? NULL : *args->dname; /* Wacky world of XDR ... */ - if (VIR_ALLOC(uri_out) < 0) - goto cleanup; + uri_out = g_new0(char *, 1); if (virDomainMigratePrepare2(conn, &cookie, &cookielen, uri_in, uri_out, @@ -3142,8 +3117,8 @@ remoteDispatchDomainGetMemoryParameters(virNetServerPtr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params = g_new0(virTypedParameter, args->nparams); nparams = args->nparams; if (!(dom = get_nonnull_domain(conn, args->dom))) @@ -3202,8 +3177,8 @@ remoteDispatchDomainGetNumaParameters(virNetServerPtr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params = g_new0(virTypedParameter, args->nparams); nparams = args->nparams; if (!(dom = get_nonnull_domain(conn, args->dom))) @@ -3262,8 +3237,8 @@ remoteDispatchDomainGetBlkioParameters(virNetServerPtr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params = g_new0(virTypedParameter, args->nparams); nparams = args->nparams; if (!(dom = get_nonnull_domain(conn, args->dom))) @@ -3323,8 +3298,8 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params = g_new0(virNodeCPUStats, args->nparams); nparams = args->nparams; if (virNodeGetCPUStats(conn, cpuNum, params, &nparams, flags) < 0) @@ -3340,8 +3315,7 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr server G_GNUC_UNUSED, /* Serialise the memory parameters. */ ret->params.params_len = nparams; - if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0) - goto cleanup; + ret->params.params_val = g_new0(remote_node_get_cpu_stats, nparams); for (i = 0; i < nparams; ++i) { /* remoteDispatchClientRequest will free this: */ @@ -3391,8 +3365,8 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params = g_new0(virNodeMemoryStats, args->nparams); nparams = args->nparams; if (virNodeGetMemoryStats(conn, cellNum, params, &nparams, flags) < 0) @@ -3408,8 +3382,7 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr server G_GNUC_UNUSED, /* Serialise the memory parameters. */ ret->params.params_len = nparams; - if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0) - goto cleanup; + ret->params.params_val = g_new0(remote_node_get_memory_stats, nparams); for (i = 0; i < nparams; ++i) { /* remoteDispatchClientRequest will free this: */ @@ -3573,8 +3546,8 @@ remoteDispatchDomainGetBlockIoTune(virNetServerPtr server G_GNUC_UNUSED, goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params = g_new0(virTypedParameter, args->nparams); nparams = args->nparams; if (!(dom = get_nonnull_domain(conn, args->dom))) @@ -3649,8 +3622,7 @@ remoteDispatchAuthList(virNetServerPtr server, } ret->types.types_len = 1; - if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0) - goto cleanup; + ret->types.types_val = g_new0(remote_auth_type, ret->types.types_len); switch ((virNetServerServiceAuthMethods) auth) { case VIR_NET_SERVER_SERVICE_AUTH_NONE: @@ -3666,7 +3638,6 @@ remoteDispatchAuthList(virNetServerPtr server, rv = 0; - cleanup: if (rv < 0) virNetMessageSaveError(rerr); return rv; @@ -3846,8 +3817,7 @@ remoteDispatchAuthSaslStart(virNetServerPtr server, /* NB, distinction of NULL vs "" is *critical* in SASL */ if (serverout) { - if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) - goto authfail; + ret->data.data_val = g_new0(char, serveroutlen); memcpy(ret->data.data_val, serverout, serveroutlen); } else { ret->data.data_val = NULL; @@ -3942,8 +3912,7 @@ remoteDispatchAuthSaslStep(virNetServerPtr server, /* NB, distinction of NULL vs "" is *critical* in SASL */ if (serverout) { - if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) - goto authfail; + ret->data.data_val = g_new0(char, serveroutlen); memcpy(ret->data.data_val, serverout, serveroutlen); } else { ret->data.data_val = NULL; @@ -4147,8 +4116,7 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr server G_GNUC_UNUSED, ret->parentName = NULL; } else { /* remoteDispatchClientRequest will free this. */ - if (VIR_ALLOC(ret->parentName) < 0) - goto cleanup; + ret->parentName = g_new0(char *, 1); *(ret->parentName) = g_strdup(parent); } @@ -4250,8 +4218,7 @@ remoteDispatchConnectDomainEventRegister(virNetServerPtr server G_GNUC_UNUSED, * clearing 'callback' and having to juggle the pointer * between 'ref' and 'callback'. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback = g_new0(daemonClientEventCallback, 1); callback->client = virObjectRef(client); callback->program = virObjectRef(remoteProgram); callback->eventID = VIR_DOMAIN_EVENT_ID_LIFECYCLE; @@ -4479,8 +4446,7 @@ remoteDispatchConnectDomainEventRegisterAny(virNetServerPtr server G_GNUC_UNUSED * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback = g_new0(daemonClientEventCallback, 1); callback->client = virObjectRef(client); callback->program = virObjectRef(remoteProgram); callback->eventID = args->eventID; @@ -4555,8 +4521,7 @@ remoteDispatchConnectDomainEventCallbackRegisterAny(virNetServerPtr server G_GNU * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback = g_new0(daemonClientEventCallback, 1); callback->client = virObjectRef(client); callback->program = virObjectRef(remoteProgram); callback->eventID = args->eventID; @@ -4799,8 +4764,7 @@ remoteDispatchDomainMigratePrepare3(virNetServerPtr server G_GNUC_UNUSED, dname = args->dname == NULL ? NULL : *args->dname; /* Wacky world of XDR ... */ - if (VIR_ALLOC(uri_out) < 0) - goto cleanup; + uri_out = g_new0(char *, 1); if (virDomainMigratePrepare3(conn, args->cookie_in.cookie_in_val, @@ -5130,8 +5094,8 @@ remoteDispatchDomainGetInterfaceParameters(virNetServerPtr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params = g_new0(virTypedParameter, args->nparams); nparams = args->nparams; if (!(dom = get_nonnull_domain(conn, args->dom))) @@ -5192,9 +5156,8 @@ remoteDispatchDomainGetCPUStats(virNetServerPtr server G_GNUC_UNUSED, goto cleanup; } - if (args->nparams > 0 && - VIR_ALLOC_N(params, args->ncpus * args->nparams) < 0) - goto cleanup; + if (args->nparams > 0) + params = g_new0(virTypedParameter, args->ncpus * args->nparams); if (!(dom = get_nonnull_domain(conn, args->dom))) goto cleanup; @@ -5261,9 +5224,8 @@ remoteDispatchDomainGetDiskErrors(virNetServerPtr server G_GNUC_UNUSED, goto cleanup; } - if (args->maxerrors && - VIR_ALLOC_N(errors, args->maxerrors) < 0) - goto cleanup; + if (args->maxerrors) + errors = g_new0(virDomainDiskError, args->maxerrors); if ((len = virDomainGetDiskErrors(dom, errors, args->maxerrors, @@ -5352,8 +5314,8 @@ remoteDispatchNodeGetMemoryParameters(virNetServerPtr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params = g_new0(virTypedParameter, args->nparams); nparams = args->nparams; if (virNodeGetMemoryParameters(conn, params, &nparams, flags) < 0) @@ -5602,8 +5564,7 @@ remoteDispatchDomainMigratePrepare3Params(virNetServerPtr server G_GNUC_UNUSED, goto cleanup; /* Wacky world of XDR ... */ - if (VIR_ALLOC(uri_out) < 0) - goto cleanup; + uri_out = g_new0(char *, 1); if (virDomainMigratePrepare3Params(conn, params, nparams, args->cookie_in.cookie_in_val, @@ -5924,8 +5885,7 @@ remoteDispatchDomainCreateXMLWithFiles(virNetServerPtr server G_GNUC_UNUSED, if (!conn) goto cleanup; - if (VIR_ALLOC_N(files, msg->nfds) < 0) - goto cleanup; + files = g_new0(int, msg->nfds); for (i = 0; i < msg->nfds; i++) { if ((files[i] = virNetMessageDupFD(msg, i)) < 0) goto cleanup; @@ -5969,8 +5929,7 @@ static int remoteDispatchDomainCreateWithFiles(virNetServerPtr server G_GNUC_UNU if (!conn) goto cleanup; - if (VIR_ALLOC_N(files, msg->nfds) < 0) - goto cleanup; + files = g_new0(int, msg->nfds); for (i = 0; i < msg->nfds; i++) { if ((files[i] = virNetMessageDupFD(msg, i)) < 0) goto cleanup; @@ -6038,8 +5997,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server G_GNUC_UNUSE * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback = g_new0(daemonClientEventCallback, 1); callback->client = virObjectRef(client); callback->program = virObjectRef(remoteProgram); callback->eventID = args->eventID; @@ -6159,8 +6117,7 @@ remoteDispatchConnectStoragePoolEventRegisterAny(virNetServerPtr server G_GNUC_U * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback = g_new0(daemonClientEventCallback, 1); callback->client = virObjectRef(client); callback->program = virObjectRef(remoteProgram); callback->eventID = args->eventID; @@ -6279,8 +6236,7 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(virNetServerPtr server G_GNUC_UN * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback = g_new0(daemonClientEventCallback, 1); callback->client = virObjectRef(client); callback->program = virObjectRef(remoteProgram); callback->eventID = args->eventID; @@ -6399,8 +6355,7 @@ remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server G_GNUC_UNUSED * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback = g_new0(daemonClientEventCallback, 1); callback->client = virObjectRef(client); callback->program = virObjectRef(remoteProgram); callback->eventID = args->eventID; @@ -6514,8 +6469,7 @@ qemuDispatchConnectDomainMonitorEventRegister(virNetServerPtr server G_GNUC_UNUS * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback = g_new0(daemonClientEventCallback, 1); callback->client = virObjectRef(client); callback->program = virObjectRef(qemuProgram); callback->eventID = -1; @@ -6656,9 +6610,8 @@ remoteDispatchNodeGetFreePages(virNetServerPtr server G_GNUC_UNUSED, } /* Allocate return buffer. */ - if (VIR_ALLOC_N(ret->counts.counts_val, - args->pages.pages_len * args->cellCount) < 0) - goto cleanup; + ret->counts.counts_val = g_new0(uint64_t, + args->pages.pages_len * args->cellCount); if ((len = virNodeGetFreePages(conn, args->pages.pages_len, @@ -6747,9 +6700,7 @@ remoteDispatchNetworkGetDHCPLeases(virNetServerPtr server G_GNUC_UNUSED, } if (leases && nleases) { - if (VIR_ALLOC_N(ret->leases.leases_val, nleases) < 0) - goto cleanup; - + ret->leases.leases_val = g_new0(remote_network_dhcp_lease, nleases); ret->leases.leases_len = nleases; for (i = 0; i < nleases; i++) { @@ -6797,8 +6748,7 @@ remoteDispatchConnectGetAllDomainStats(virNetServerPtr server G_GNUC_UNUSED, goto cleanup; if (args->doms.doms_len) { - if (VIR_ALLOC_N(doms, args->doms.doms_len + 1) < 0) - goto cleanup; + doms = g_new0(virDomainPtr, args->doms.doms_len + 1); for (i = 0; i < args->doms.doms_len; i++) { if (!(doms[i] = get_nonnull_domain(conn, args->doms.doms_val[i]))) @@ -6827,9 +6777,7 @@ remoteDispatchConnectGetAllDomainStats(virNetServerPtr server G_GNUC_UNUSED, goto cleanup; } - if (VIR_ALLOC_N(ret->retStats.retStats_val, nrecords) < 0) - goto cleanup; - + ret->retStats.retStats_val = g_new0(remote_domain_stats_record, nrecords); ret->retStats.retStats_len = nrecords; for (i = 0; i < nrecords; i++) { @@ -6934,9 +6882,7 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr server G_GNUC_UNUSED, } if (ninfo) { - if (VIR_ALLOC_N(ret->info.info_val, ninfo) < 0) - goto cleanup; - + ret->info.info_val = g_new0(remote_domain_fsinfo, ninfo); ret->info.info_len = ninfo; for (i = 0; i < ninfo; i++) { @@ -6956,8 +6902,7 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr server G_GNUC_UNUSED, } if (ndisk > 0) { - if (VIR_ALLOC_N(dst->dev_aliases.dev_aliases_val, ndisk) < 0) - goto cleanup; + dst->dev_aliases.dev_aliases_val = g_new0(char *, ndisk); for (j = 0; j < ndisk; j++) dst->dev_aliases.dev_aliases_val[j] = g_strdup(info[i]->devAlias[j]); @@ -7019,9 +6964,7 @@ remoteSerializeDomainInterface(virDomainInterfacePtr *ifaces, return -1; } - if (VIR_ALLOC_N(ret->ifaces.ifaces_val, ifaces_count) < 0) - return -1; - + ret->ifaces.ifaces_val = g_new0(remote_domain_interface, ifaces_count); ret->ifaces.ifaces_len = ifaces_count; for (i = 0; i < ifaces_count; i++) { @@ -7031,8 +6974,7 @@ remoteSerializeDomainInterface(virDomainInterfacePtr *ifaces, iface_ret->name = g_strdup(iface->name); if (iface->hwaddr) { - if (VIR_ALLOC(iface_ret->hwaddr) < 0) - goto cleanup; + iface_ret->hwaddr = g_new0(char *, 1); *iface_ret->hwaddr = g_strdup(iface->hwaddr); } @@ -7043,10 +6985,7 @@ remoteSerializeDomainInterface(virDomainInterfacePtr *ifaces, goto cleanup; } - if (VIR_ALLOC_N(iface_ret->addrs.addrs_val, - iface->naddrs) < 0) - goto cleanup; - + iface_ret->addrs.addrs_val = g_new0(remote_domain_ip_addr, iface->naddrs); iface_ret->addrs.addrs_len = iface->naddrs; for (j = 0; j < iface->naddrs; j++) { @@ -7362,8 +7301,7 @@ remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr errors, remote_domain_disk_error *val = NULL; size_t i = 0; - if (VIR_ALLOC_N(val, nerrors) < 0) - goto error; + val = g_new0(remote_domain_disk_error, nerrors); for (i = 0; i < nerrors; i++) { val[i].disk = g_strdup(errors[i].disk); @@ -7374,15 +7312,6 @@ remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr errors, *ret_errors_val = val; return 0; - - error: - if (val) { - size_t j; - for (j = 0; j < i; j++) - VIR_FREE(val[j].disk); - VIR_FREE(val); - } - return -1; } static int diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_stream.c index 9a62189cd6..b4a3cb6741 100644 --- a/src/remote/remote_daemon_stream.c +++ b/src/remote/remote_daemon_stream.c @@ -362,8 +362,7 @@ daemonCreateClientStream(virNetServerClientPtr client, VIR_DEBUG("client=%p, proc=%d, serial=%u, st=%p", client, header->proc, header->serial, st); - if (VIR_ALLOC(stream) < 0) - return NULL; + stream = g_new0(daemonClientStream, 1); stream->refs = 1; stream->priv = priv; @@ -853,8 +852,7 @@ daemonStreamHandleRead(virNetServerClientPtr client, memset(&rerr, 0, sizeof(rerr)); - if (VIR_ALLOC_N(buffer, bufferLen) < 0) - return -1; + buffer = g_new0(char, bufferLen); if (!(msg = virNetMessageNew(false))) goto cleanup; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 6e0c04f168..49769ac04d 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -1207,8 +1207,7 @@ static struct private_data * remoteAllocPrivateData(void) { struct private_data *priv; - if (VIR_ALLOC(priv) < 0) - return NULL; + priv = g_new0(struct private_data, 1); if (virMutexInit(&priv->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -2271,18 +2270,15 @@ remoteDomainGetIOThreadInfo(virDomainPtr dom, goto cleanup; } - if (VIR_ALLOC_N(info_ret, ret.info.info_len) < 0) - goto cleanup; + info_ret = g_new0(virDomainIOThreadInfoPtr, ret.info.info_len); for (i = 0; i < ret.info.info_len; i++) { src = &ret.info.info_val[i]; - if (VIR_ALLOC(info_ret[i]) < 0) - goto cleanup; + info_ret[i] = g_new0(virDomainIOThreadInfo, 1); info_ret[i]->iothread_id = src->iothread_id; - if (VIR_ALLOC_N(info_ret[i]->cpumap, src->cpumap.cpumap_len) < 0) - goto cleanup; + info_ret[i]->cpumap = g_new0(unsigned char, src->cpumap.cpumap_len); memcpy(info_ret[i]->cpumap, src->cpumap.cpumap_val, src->cpumap.cpumap_len); info_ret[i]->cpumaplen = src->cpumap.cpumap_len; @@ -2367,8 +2363,7 @@ remoteDomainGetSecurityLabelList(virDomainPtr domain, virSecurityLabelPtr* secla goto done; } - if (VIR_ALLOC_N(*seclabels, ret.labels.labels_len) < 0) - goto cleanup; + *seclabels = g_new0(virSecurityLabel, ret.labels.labels_len); for (i = 0; i < ret.labels.labels_len; i++) { remote_domain_get_security_label_ret *cur = &ret.labels.labels_val[i]; @@ -3766,8 +3761,7 @@ static sasl_callback_t *remoteAuthMakeCallbacks(int *credtype, int ncredtype) sasl_callback_t *cbs; size_t i; int n; - if (VIR_ALLOC_N(cbs, ncredtype+1) < 0) - return NULL; + cbs = g_new0(sasl_callback_t, ncredtype + 1); for (i = 0, n = 0; i < ncredtype; i++) { int id = remoteAuthCredVir2SASL(credtype[i]); @@ -3804,8 +3798,7 @@ static int remoteAuthMakeCredentials(sasl_interact_t *interact, (*ncred)++; } - if (VIR_ALLOC_N(*cred, *ncred) < 0) - return -1; + *cred = g_new0(virConnectCredential, *ncred); for (ninteract = 0, *ncred = 0; interact[ninteract].id != 0; ninteract++) { if (interact[ninteract].result) @@ -4665,22 +4658,18 @@ remoteDomainBuildEventGraphicsHelper(virConnectPtr conn, if (!dom) return; - if (VIR_ALLOC(localAddr) < 0) - goto error; + localAddr = g_new0(virDomainEventGraphicsAddress, 1); localAddr->family = msg->local.family; localAddr->service = g_strdup(msg->local.service); localAddr->node = g_strdup(msg->local.node); - if (VIR_ALLOC(remoteAddr) < 0) - goto error; + remoteAddr = g_new0(virDomainEventGraphicsAddress, 1); remoteAddr->family = msg->remote.family; remoteAddr->service = g_strdup(msg->remote.service); remoteAddr->node = g_strdup(msg->remote.node); - if (VIR_ALLOC(subject) < 0) - goto error; - if (VIR_ALLOC_N(subject->identities, msg->subject.subject_len) < 0) - goto error; + subject = g_new0(virDomainEventGraphicsSubject, 1); + subject->identities = g_new0(virDomainEventGraphicsSubjectIdentity, msg->subject.subject_len); subject->nidentity = msg->subject.subject_len; for (i = 0; i < subject->nidentity; i++) { subject->identities[i].type = g_strdup(msg->subject.subject_val[i].type); @@ -4698,28 +4687,6 @@ remoteDomainBuildEventGraphicsHelper(virConnectPtr conn, virObjectEventStateQueueRemote(priv->eventState, event, callbackID); return; - - error: - if (localAddr) { - VIR_FREE(localAddr->service); - VIR_FREE(localAddr->node); - VIR_FREE(localAddr); - } - if (remoteAddr) { - VIR_FREE(remoteAddr->service); - VIR_FREE(remoteAddr->node); - VIR_FREE(remoteAddr); - } - if (subject) { - for (i = 0; i < subject->nidentity; i++) { - VIR_FREE(subject->identities[i].type); - VIR_FREE(subject->identities[i].name); - } - VIR_FREE(subject->identities); - VIR_FREE(subject); - } - virObjectUnref(dom); - return; } static void remoteDomainBuildEventGraphics(virNetClientProgramPtr prog G_GNUC_UNUSED, @@ -5640,8 +5607,7 @@ remoteStreamEventAddCallback(virStreamPtr st, int ret = -1; struct remoteStreamCallbackData *cbdata; - if (VIR_ALLOC(cbdata) < 0) - return -1; + cbdata = g_new0(struct remoteStreamCallbackData, 1); cbdata->cb = cb; cbdata->opaque = opaque; cbdata->ff = ff; @@ -6304,8 +6270,7 @@ remoteConnectGetCPUModelNames(virConnectPtr conn, } if (models) { - if (VIR_ALLOC_N(retmodels, ret.models.models_len + 1) < 0) - goto cleanup; + retmodels = g_new0(char *, ret.models.models_len + 1); for (i = 0; i < ret.models.models_len; i++) { retmodels[i] = ret.models.models_val[i]; @@ -6738,8 +6703,7 @@ remoteNodeGetCPUMap(virConnectPtr conn, goto cleanup; if (cpumap) { - if (VIR_ALLOC_N(*cpumap, ret.cpumap.cpumap_len) < 0) - goto cleanup; + *cpumap = g_new0(unsigned char, ret.cpumap.cpumap_len); memcpy(*cpumap, ret.cpumap.cpumap_val, ret.cpumap.cpumap_len); } @@ -7467,13 +7431,11 @@ remoteNetworkGetDHCPLeases(virNetworkPtr net, } if (leases) { - if (ret.leases.leases_len && - VIR_ALLOC_N(leases_ret, ret.leases.leases_len + 1) < 0) - goto cleanup; + if (ret.leases.leases_len) + leases_ret = g_new0(virNetworkDHCPLeasePtr, ret.leases.leases_len + 1); for (i = 0; i < ret.leases.leases_len; i++) { - if (VIR_ALLOC(leases_ret[i]) < 0) - goto cleanup; + leases_ret[i] = g_new0(virNetworkDHCPLease, 1); if (remoteSerializeDHCPLease(leases_ret[i], &ret.leases.leases_val[i]) < 0) goto cleanup; @@ -7519,8 +7481,7 @@ remoteConnectGetAllDomainStats(virConnectPtr conn, memset(&args, 0, sizeof(args)); if (ndoms) { - if (VIR_ALLOC_N(args.doms.doms_val, ndoms) < 0) - goto cleanup; + args.doms.doms_val = g_new0(remote_nonnull_domain, ndoms); for (i = 0; i < ndoms; i++) make_nonnull_domain(args.doms.doms_val + i, doms[i]); @@ -7550,14 +7511,12 @@ remoteConnectGetAllDomainStats(virConnectPtr conn, *retStats = NULL; - if (VIR_ALLOC_N(tmpret, ret.retStats.retStats_len + 1) < 0) - goto cleanup; + tmpret = g_new0(virDomainStatsRecordPtr, ret.retStats.retStats_len + 1); for (i = 0; i < ret.retStats.retStats_len; i++) { remote_domain_stats_record *rec = ret.retStats.retStats_val + i; - if (VIR_ALLOC(elem) < 0) - goto cleanup; + elem = g_new0(virDomainStatsRecord, 1); if (!(elem->dom = get_nonnull_domain(conn, rec->dom))) goto cleanup; @@ -7676,14 +7635,13 @@ remoteDomainGetFSInfo(virDomainPtr dom, goto cleanup; } - if (VIR_ALLOC_N(info_ret, ret.info.info_len) < 0) + info_ret = g_new0(virDomainFSInfoPtr, ret.info.info_len); goto cleanup; for (i = 0; i < ret.info.info_len; i++) { src = &ret.info.info_val[i]; - if (VIR_ALLOC(info_ret[i]) < 0) - goto cleanup; + info_ret[i] = g_new0(virDomainFSInfo, 1); info_ret[i]->mountpoint = g_strdup(src->mountpoint); @@ -7693,9 +7651,8 @@ remoteDomainGetFSInfo(virDomainPtr dom, len = src->dev_aliases.dev_aliases_len; info_ret[i]->ndevAlias = len; - if (len && - VIR_ALLOC_N(info_ret[i]->devAlias, len) < 0) - goto cleanup; + if (len) + info_ret[i]->devAlias = g_new0(char *, len); for (j = 0; j < len; j++) info_ret[i]->devAlias[j] = g_strdup(src->dev_aliases.dev_aliases_val[j]); @@ -7760,16 +7717,14 @@ remoteDomainInterfaceAddresses(virDomainPtr dom, goto cleanup; } - if (ret.ifaces.ifaces_len && - VIR_ALLOC_N(ifaces_ret, ret.ifaces.ifaces_len) < 0) - goto cleanup; + if (ret.ifaces.ifaces_len) + ifaces_ret = g_new0(virDomainInterfacePtr, ret.ifaces.ifaces_len); for (i = 0; i < ret.ifaces.ifaces_len; i++) { virDomainInterfacePtr iface; remote_domain_interface *iface_ret = &(ret.ifaces.ifaces_val[i]); - if (VIR_ALLOC(ifaces_ret[i]) < 0) - goto cleanup; + ifaces_ret[i] = g_new0(virDomainInterface, 1); iface = ifaces_ret[i]; @@ -7788,8 +7743,7 @@ remoteDomainInterfaceAddresses(virDomainPtr dom, iface->naddrs = iface_ret->addrs.addrs_len; if (iface->naddrs) { - if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0) - goto cleanup; + iface->addrs = g_new0(virDomainIPAddress, iface->naddrs); for (j = 0; j < iface->naddrs; j++) { virDomainIPAddressPtr ip_addr = &(iface->addrs[j]); -- 2.26.2

On Thu, Oct 08, 2020 at 02:12:09PM +0200, Ján Tomko wrote:
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/remote/remote_daemon_config.c | 3 +- src/remote/remote_daemon_dispatch.c | 225 ++++++++++------------------ src/remote/remote_daemon_stream.c | 6 +- src/remote/remote_driver.c | 102 ++++--------- 4 files changed, 108 insertions(+), 228 deletions(-)
[...]
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index a659737bc7..90115167fb 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -2413,16 +2406,14 @@ remoteDispatchDomainMemoryStats(virNetServerPtr server G_GNUC_UNUSED, goto cleanup;
/* Allocate stats array for making dispatch call */ - if (VIR_ALLOC_N(stats, args->maxStats) < 0) - goto cleanup; + stats = g_new0(struct _virDomainMemoryStat, args->maxStats);
We have virDomainMemoryStatStruct but this works as well. Pavel

On 10/8/20 8:12 AM, Ján Tomko wrote:
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/remote/remote_daemon_config.c | 3 +- src/remote/remote_daemon_dispatch.c | 225 ++++++++++------------------ src/remote/remote_daemon_stream.c | 6 +- src/remote/remote_driver.c | 102 ++++--------- 4 files changed, 108 insertions(+), 228 deletions(-)
[...]
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 6e0c04f168..49769ac04d 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c
[...]
@@ -7676,14 +7635,13 @@ remoteDomainGetFSInfo(virDomainPtr dom, goto cleanup; }
- if (VIR_ALLOC_N(info_ret, ret.info.info_len) < 0) + info_ret = g_new0(virDomainFSInfoPtr, ret.info.info_len); goto cleanup;
^^^^ Coverity notes a simple / trivial cleanup [...]

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/remote/remote_daemon_dispatch.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index 90115167fb..b8813611c8 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -3593,7 +3593,6 @@ remoteDispatchAuthList(virNetServerPtr server, virNetMessageErrorPtr rerr, remote_auth_list_ret *ret) { - int rv = -1; int auth = virNetServerClientGetAuth(client); uid_t callerUid; gid_t callerGid; @@ -3636,11 +3635,7 @@ remoteDispatchAuthList(virNetServerPtr server, break; } - rv = 0; - - if (rv < 0) - virNetMessageSaveError(rerr); - return rv; + return 0; } -- 2.26.2

On Thu, Oct 08, 2020 at 02:12:10PM +0200, Ján Tomko wrote:
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/remote/remote_daemon_dispatch.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index 90115167fb..b8813611c8 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -3593,7 +3593,6 @@ remoteDispatchAuthList(virNetServerPtr server, virNetMessageErrorPtr rerr, remote_auth_list_ret *ret) { - int rv = -1; int auth = virNetServerClientGetAuth(client); uid_t callerUid; gid_t callerGid; @@ -3636,11 +3635,7 @@ remoteDispatchAuthList(virNetServerPtr server, break; }
- rv = 0; - - if (rv < 0) - virNetMessageSaveError(rerr); - return rv; + return 0; }
../src/remote/remote_daemon_dispatch.c: In function ‘remoteDispatchAuthList’: ../src/remote/remote_daemon_dispatch.c:3593:46: error: unused parameter ‘rerr’ [-Werror=unused-parameter] 3593 | virNetMessageErrorPtr rerr, | ~~~~~~~~~~~~~~~~~~~~~~^~~~ cc1: all warnings being treated as errors

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/access/viraccessmanager.c | 3 +- src/admin/admin_server_dispatch.c | 6 +-- src/hypervisor/domain_driver.c | 3 +- src/hypervisor/virclosecallbacks.c | 7 +--- src/libxl/xen_xm.c | 7 +--- src/test/test_driver.c | 66 +++++++++++------------------- 6 files changed, 32 insertions(+), 60 deletions(-) diff --git a/src/access/viraccessmanager.c b/src/access/viraccessmanager.c index e2ceeca57f..02e4464ef5 100644 --- a/src/access/viraccessmanager.c +++ b/src/access/viraccessmanager.c @@ -91,8 +91,7 @@ static virAccessManagerPtr virAccessManagerNewDriver(virAccessDriverPtr drv) if (virAccessManagerInitialize() < 0) return NULL; - if (VIR_ALLOC_N(privateData, drv->privateDataLen) < 0) - return NULL; + privateData = g_new0(char, drv->privateDataLen); if (!(mgr = virObjectLockableNew(virAccessManagerClass))) { VIR_FREE(privateData); diff --git a/src/admin/admin_server_dispatch.c b/src/admin/admin_server_dispatch.c index b3da577995..0efb4485d4 100644 --- a/src/admin/admin_server_dispatch.c +++ b/src/admin/admin_server_dispatch.c @@ -88,8 +88,7 @@ remoteAdmClientNew(virNetServerClientPtr client G_GNUC_UNUSED, return NULL; } - if (VIR_ALLOC(priv) < 0) - return NULL; + priv = g_new0(struct daemonAdmClientPrivate, 1); if (virMutexInit(&priv->lock) < 0) { VIR_FREE(priv); @@ -511,8 +510,7 @@ adminDispatchConnectGetLoggingFilters(virNetServerPtr server G_GNUC_UNUSED, ret->filters = NULL; } else { char **ret_filters = NULL; - if (VIR_ALLOC(ret_filters) < 0) - return -1; + ret_filters = g_new0(char *, 1); *ret_filters = filters; ret->filters = ret_filters; diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index f5f0f6e2e9..8dc5870a61 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -219,8 +219,7 @@ virDomainDriverParseBlkioDeviceStr(char *blkioDeviceStr, const char *type, ndevices = (nsep + 1) / 2; - if (VIR_ALLOC_N(result, ndevices) < 0) - return -1; + result = g_new0(virBlkioDevice, ndevices); i = 0; temp = blkioDeviceStr; diff --git a/src/hypervisor/virclosecallbacks.c b/src/hypervisor/virclosecallbacks.c index 200577e18e..403af047fb 100644 --- a/src/hypervisor/virclosecallbacks.c +++ b/src/hypervisor/virclosecallbacks.c @@ -120,9 +120,7 @@ virCloseCallbacksSet(virCloseCallbacksPtr closeCallbacks, closeDef->cb = cb; } else { - if (VIR_ALLOC(closeDef) < 0) - goto cleanup; - + closeDef = g_new0(virDriverCloseDef, 1); closeDef->conn = conn; closeDef->cb = cb; if (virHashAddEntry(closeCallbacks->list, uuidstr, closeDef) < 0) { @@ -284,8 +282,7 @@ virCloseCallbacksGetForConn(virCloseCallbacksPtr closeCallbacks, virCloseCallbacksListPtr list = NULL; struct virCloseCallbacksData data; - if (VIR_ALLOC(list) < 0) - return NULL; + list = g_new0(virCloseCallbacksList, 1); data.conn = conn; data.list = list; diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index 6d00f47544..9063a43135 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -42,8 +42,7 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def) if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { g_autofree char *boot = NULL; - if (VIR_ALLOC(def->os.loader) < 0) - return -1; + def->os.loader = g_new0(virDomainLoaderDef, 1); if (xenConfigCopyString(conf, "kernel", &def->os.loader->path) < 0) return -1; @@ -346,9 +345,7 @@ xenFormatXMDisk(virConfValuePtr list, return -1; } - if (VIR_ALLOC(val) < 0) - return -1; - + val = g_new0(virConfValue, 1); val->type = VIR_CONF_STRING; val->str = virBufferContentAndReset(&buf); tmp = list->list; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7824e44ed9..bb26fc247c 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -212,15 +212,14 @@ testDomainDefNamespaceParse(xmlXPathContextPtr ctxt, unsigned int tmpuint; g_autofree xmlNodePtr *nodes = NULL; - if (VIR_ALLOC(nsdata) < 0) - return -1; + nsdata = g_new0(testDomainNamespaceDef, 1); n = virXPathNodeSet("./test:domainsnapshot", ctxt, &nodes); if (n < 0) goto error; - if (n && VIR_ALLOC_N(nsdata->snap_nodes, n) < 0) - goto error; + if (n) + nsdata->snap_nodes = g_new0(xmlNodePtr, n); for (i = 0; i < n; i++) { xmlNodePtr newnode = xmlCopyNode(nodes[i], 1); @@ -302,8 +301,7 @@ testBuildCapabilities(virConnectPtr conn) virCapabilitiesHostInitIOMMU(caps); - if (VIR_ALLOC_N(caps->host.pagesSize, 4) < 0) - goto error; + caps->host.pagesSize = g_new0(unsigned int, 4); caps->host.pagesSize[caps->host.nPagesSize++] = 4; caps->host.pagesSize[caps->host.nPagesSize++] = 8; @@ -316,11 +314,8 @@ testBuildCapabilities(virConnectPtr conn) virCapsHostNUMACellPageInfoPtr pages; size_t nPages = caps->host.nPagesSize - 1; - if (VIR_ALLOC_N(cpu_cells, privconn->cells[i].numCpus) < 0 || - VIR_ALLOC_N(pages, nPages) < 0) { - VIR_FREE(cpu_cells); - goto error; - } + cpu_cells = g_new0(virCapsHostNUMACellCPU, privconn->cells[i].numCpus); + pages = g_new0(virCapsHostNUMACellPageInfo, nPages); memcpy(cpu_cells, privconn->cells[i].cpus, sizeof(*cpu_cells) * privconn->cells[i].numCpus); @@ -364,8 +359,7 @@ testBuildCapabilities(virConnectPtr conn) } caps->host.nsecModels = 1; - if (VIR_ALLOC_N(caps->host.secModels, caps->host.nsecModels) < 0) - goto error; + caps->host.secModels = g_new0(virCapsHostSecModel, caps->host.nsecModels); caps->host.secModels[0].model = g_strdup("testSecurity"); caps->host.secModels[0].doi = g_strdup(""); @@ -396,8 +390,7 @@ testDomainObjPrivateAlloc(void *opaque) { testDomainObjPrivatePtr priv; - if (VIR_ALLOC(priv) < 0) - return NULL; + priv = g_new0(testDomainObjPrivate, 1); priv->driver = opaque; priv->frozen[0] = priv->frozen[1] = false; @@ -760,8 +753,7 @@ static char *testBuildFilename(const char *relativeTo, if ((baseLen = (offset-relativeTo+1))) { char *absFile; int totalLen = baseLen + strlen(filename) + 1; - if (VIR_ALLOC_N(absFile, totalLen) < 0) - return NULL; + absFile = g_new0(char, totalLen); if (virStrncpy(absFile, relativeTo, baseLen, totalLen) < 0) { VIR_FREE(absFile); return NULL; @@ -1233,8 +1225,8 @@ testParseAuthUsers(testDriverPtr privconn, return -1; privconn->numAuths = num; - if (num && VIR_ALLOC_N(privconn->auths, num) < 0) - return -1; + if (num) + privconn->auths = g_new0(testAuth, num); for (i = 0; i < num; i++) { g_autofree char *username = NULL; @@ -2298,8 +2290,7 @@ testDomainSaveImageOpen(testDriverPtr driver, goto error; } - if (VIR_ALLOC_N(xml, len+1) < 0) - goto error; + xml = g_new0(char, len + 1); if (saferead(fd, xml, len) != len) { virReportSystemError(errno, _("incomplete metadata in '%s'"), path); @@ -3491,10 +3482,9 @@ testDomainSetInterfaceParameters(virDomainPtr dom, if (!(net = virDomainNetFind(def, device))) goto cleanup; - if ((VIR_ALLOC(bandwidth) < 0) || - (VIR_ALLOC(bandwidth->in) < 0) || - (VIR_ALLOC(bandwidth->out) < 0)) - goto cleanup; + bandwidth = g_new0(virNetDevBandwidth, 1); + bandwidth->in = g_new0(virNetDevBandwidthRate, 1); + bandwidth->out = g_new0(virNetDevBandwidthRate, 1); for (i = 0; i < nparams; i++) { virTypedParameterPtr param = ¶ms[i]; @@ -4726,21 +4716,17 @@ testDomainGetFSInfo(virDomainPtr dom, if (vm->def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) { char *name = vm->def->disks[i]->dst; - if (VIR_ALLOC_N(info_ret, 2) < 0) - goto cleanup; - - if (VIR_ALLOC(info_ret[0]) < 0 || - VIR_ALLOC(info_ret[0]->devAlias) < 0) - goto cleanup; + info_ret = g_new0(virDomainFSInfo *, 2); + info_ret[0] = g_new0(virDomainFSInfo, 1); + info_ret[0]->devAlias = g_new0(char *, 1); info_ret[0]->mountpoint = g_strdup("/"); info_ret[0]->fstype = g_strdup("ext4"); info_ret[0]->devAlias[0] = g_strdup(name); info_ret[0]->name = g_strdup_printf("%s1", name); - if (VIR_ALLOC(info_ret[1]) < 0 || - VIR_ALLOC(info_ret[1]->devAlias) < 0) - goto cleanup; + info_ret[1] = g_new0(virDomainFSInfo, 1); + info_ret[1]->devAlias = g_new0(char *, 1); info_ret[1]->mountpoint = g_strdup("/boot"); info_ret[1]->fstype = g_strdup("ext4"); @@ -5076,22 +5062,19 @@ testDomainInterfaceAddresses(virDomainPtr dom, if (virDomainObjCheckActive(vm) < 0) goto cleanup; - if (VIR_ALLOC_N(ifaces_ret, vm->def->nnets) < 0) - goto cleanup; + ifaces_ret = g_new0(virDomainInterfacePtr, vm->def->nnets); for (i = 0; i < vm->def->nnets; i++) { const virDomainNetDef *net = vm->def->nets[i]; - if (VIR_ALLOC(iface) < 0) - goto cleanup; + iface = g_new0(virDomainInterface, 1); iface->name = g_strdup(net->ifname); virMacAddrFormat(&net->mac, macaddr); iface->hwaddr = g_strdup(macaddr); - if (VIR_ALLOC(iface->addrs) < 0) - goto cleanup; + iface->addrs = g_new0(virDomainIPAddress, 1); iface->naddrs = 1; if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) { @@ -7741,8 +7724,7 @@ testNodeGetCPUMap(virConnectPtr conn G_GNUC_UNUSED, virCheckFlags(0, -1); if (cpumap) { - if (VIR_ALLOC_N(*cpumap, 1) < 0) - return -1; + *cpumap = g_new0(unsigned char, 1); *cpumap[0] = 0x15; } -- 2.26.2

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/viralloctest.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/viralloctest.c b/tests/viralloctest.c index c52483998b..785728d6f9 100644 --- a/tests/viralloctest.c +++ b/tests/viralloctest.c @@ -117,8 +117,7 @@ testReallocArray(const void *opaque G_GNUC_UNUSED) size_t nt = 10, i; int ret = -1; - if (VIR_ALLOC_N(t, nt) < 0) - return -1; + t = g_new0(testDummyStruct, nt); if (testCheckNonNull(t) < 0) goto cleanup; @@ -191,8 +190,7 @@ testExpandArray(const void *opaque G_GNUC_UNUSED) size_t nt = 10, i; int ret = -1; - if (VIR_ALLOC_N(t, nt) < 0) - return -1; + t = g_new0(testDummyStruct, nt); if (testCheckNonNull(t) < 0) goto cleanup; @@ -271,8 +269,7 @@ testResizeArray(const void *opaque G_GNUC_UNUSED) size_t nt = 10, at, i; int ret = -1; - if (VIR_ALLOC_N(t, nt) < 0) - return -1; + t = g_new0(testDummyStruct, nt); at = nt; @@ -333,8 +330,7 @@ testInsertArray(const void *opaque G_GNUC_UNUSED) int ret = -1; testDummyStruct *n = (void *)0xff; - if (VIR_ALLOC_N(t, nt) < 0) - return -1; + t = g_new0(testDummyStruct, nt); if (testCheckNonNull(t) < 0) goto cleanup; @@ -398,14 +394,12 @@ testDispose(const void *opaque G_GNUC_UNUSED) nnums = 10; VIR_DISPOSE_N(nums, nnums); - if (VIR_ALLOC(num) < 0) - return -1; + num = g_new0(int, 1); VIR_DISPOSE(num); nnums = 10; - if (VIR_ALLOC_N(nums, nnums) < 0) - return -1; + nums = g_new0(int, nnums); VIR_DISPOSE_N(nums, nnums); -- 2.26.2

On Thu, Oct 08, 2020 at 02:12:12PM +0200, Ján Tomko wrote:
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/viralloctest.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/tests/viralloctest.c b/tests/viralloctest.c index c52483998b..785728d6f9 100644 --- a/tests/viralloctest.c +++ b/tests/viralloctest.c @@ -117,8 +117,7 @@ testReallocArray(const void *opaque G_GNUC_UNUSED) size_t nt = 10, i; int ret = -1;
- if (VIR_ALLOC_N(t, nt) < 0) - return -1; + t = g_new0(testDummyStruct, nt);
if (testCheckNonNull(t) < 0) goto cleanup; @@ -191,8 +190,7 @@ testExpandArray(const void *opaque G_GNUC_UNUSED) size_t nt = 10, i; int ret = -1;
- if (VIR_ALLOC_N(t, nt) < 0) - return -1; + t = g_new0(testDummyStruct, nt);
if (testCheckNonNull(t) < 0) goto cleanup; @@ -271,8 +269,7 @@ testResizeArray(const void *opaque G_GNUC_UNUSED) size_t nt = 10, at, i; int ret = -1;
- if (VIR_ALLOC_N(t, nt) < 0) - return -1; + t = g_new0(testDummyStruct, nt);
at = nt;
@@ -333,8 +330,7 @@ testInsertArray(const void *opaque G_GNUC_UNUSED) int ret = -1; testDummyStruct *n = (void *)0xff;
- if (VIR_ALLOC_N(t, nt) < 0) - return -1; + t = g_new0(testDummyStruct, nt);
../tests/viralloctest.c: In function ‘testInsertArray’: ../tests/viralloctest.c:266:7: error: assignment to ‘testDummyStruct **’ from incompatible pointer type ‘testDummyStruct *’ [-Werror=incompatible-pointer-types] 266 | t = g_new0(testDummyStruct, nt); | ^ cc1: all warnings being treated as errors
if (testCheckNonNull(t) < 0) goto cleanup; @@ -398,14 +394,12 @@ testDispose(const void *opaque G_GNUC_UNUSED) nnums = 10; VIR_DISPOSE_N(nums, nnums);
- if (VIR_ALLOC(num) < 0) - return -1; + num = g_new0(int, 1);
VIR_DISPOSE(num);
nnums = 10; - if (VIR_ALLOC_N(nums, nnums) < 0) - return -1; + nums = g_new0(int, nnums);
VIR_DISPOSE_N(nums, nnums);
-- 2.26.2

There are no more users of VIR_ALLOC or VIR_ALLOC_N. Delete their test cases. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/viralloctest.c | 71 -------------------------------------------- 1 file changed, 71 deletions(-) diff --git a/tests/viralloctest.c b/tests/viralloctest.c index 785728d6f9..bc7bb114c1 100644 --- a/tests/viralloctest.c +++ b/tests/viralloctest.c @@ -43,73 +43,6 @@ testCheckNonNull(void *t) return 0; } -static int -testAllocScalar(const void *opaque G_GNUC_UNUSED) -{ - testDummyStruct *t; - int ret = -1; - - if (VIR_ALLOC(t) < 0) - return -1; - - if (testCheckNonNull(t) < 0) - goto cleanup; - - if (t->a != 0 || - t->b != 0) { - fprintf(stderr, "Allocated ram was not zerod\n"); - goto cleanup; - } - - VIR_FREE(t); - - if (t != NULL) { - fprintf(stderr, "Pointer is still set after free\n"); - goto cleanup; - } - - ret = 0; - cleanup: - VIR_FREE(t); - return ret; -} - - -static int -testAllocArray(const void *opaque G_GNUC_UNUSED) -{ - testDummyStruct *t; - size_t nt = 10, i; - int ret = -1; - - if (VIR_ALLOC_N(t, nt) < 0) - return -1; - - if (testCheckNonNull(t) < 0) - goto cleanup; - - for (i = 0; i < nt; i++) { - if (t[i].a != 0 || - t[i].b != 0) { - fprintf(stderr, "Allocated ram block %zu was not zerod\n", i); - goto cleanup; - } - } - - VIR_FREE(t); - - if (t != NULL) { - fprintf(stderr, "Pointer is still set after free\n"); - goto cleanup; - } - - ret = 0; - cleanup: - VIR_FREE(t); - return ret; -} - - static int testReallocArray(const void *opaque G_GNUC_UNUSED) { @@ -416,10 +349,6 @@ mymain(void) { int ret = 0; - if (virTestRun("alloc scalar", testAllocScalar, NULL) < 0) - ret = -1; - if (virTestRun("alloc array", testAllocArray, NULL) < 0) - ret = -1; if (virTestRun("realloc array", testReallocArray, NULL) < 0) ret = -1; if (virTestRun("expand array", testExpandArray, NULL) < 0) -- 2.26.2

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/libvirt_private.syms | 2 -- src/util/viralloc.c | 39 --------------------------------------- src/util/viralloc.h | 33 --------------------------------- 3 files changed, 74 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7cf8bea962..152083d220 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1614,8 +1614,6 @@ vir_g_strdup_vprintf; # util/viralloc.h -virAlloc; -virAllocN; virAllocVar; virDeleteElementsN; virDispose; diff --git a/src/util/viralloc.c b/src/util/viralloc.c index e254416cdf..0360b8a8aa 100644 --- a/src/util/viralloc.c +++ b/src/util/viralloc.c @@ -31,45 +31,6 @@ VIR_LOG_INIT("util.alloc"); -/** - * virAlloc: - * @ptrptr: pointer to pointer for address of allocated memory - * @size: number of bytes to allocate - * - * Allocate 'size' bytes of memory. Return the address of the - * allocated memory in 'ptrptr'. The newly allocated memory is - * filled with zeros. - * - * Returns zero on success, aborts on OOM - */ -int virAlloc(void *ptrptr, - size_t size) -{ - *(void **)ptrptr = g_malloc0(size); - return 0; -} - -/** - * virAllocN: - * @ptrptr: pointer to pointer for address of allocated memory - * @size: number of bytes to allocate - * @count: number of elements to allocate - * - * Allocate an array of memory 'count' elements long, - * each with 'size' bytes. Return the address of the - * allocated memory in 'ptrptr'. The newly allocated - * memory is filled with zeros. - * - * Returns zero on success, aborts on OOM - */ -int virAllocN(void *ptrptr, - size_t size, - size_t count) -{ - *(void**)ptrptr = g_malloc0_n(count, size); - return 0; -} - /** * virReallocN: * @ptrptr: pointer to pointer for address of allocated memory diff --git a/src/util/viralloc.h b/src/util/viralloc.h index a50cd5d632..1abd94fac4 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -34,10 +34,6 @@ */ /* Don't call these directly - use the macros below */ -int virAlloc(void *ptrptr, size_t size) - G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1); -int virAllocN(void *ptrptr, size_t size, size_t count) - G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1); int virReallocN(void *ptrptr, size_t size, size_t count) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1); int virExpandN(void *ptrptr, size_t size, size_t *count, size_t add) @@ -61,35 +57,6 @@ void virDispose(void *ptrptr, size_t count, size_t element_size, size_t *countpt void virDisposeString(char **strptr) ATTRIBUTE_NONNULL(1); -/** - * VIR_ALLOC: - * @ptr: pointer to hold address of allocated memory - * - * Allocate sizeof(*ptr) bytes of memory and store - * the address of allocated memory in 'ptr'. Fill the - * newly allocated memory with zeros. - * - * This macro is safe to use on arguments with side effects. - * - * Returns 0 on success, aborts on OOM - */ -#define VIR_ALLOC(ptr) virAlloc(&(ptr), sizeof(*(ptr))) - -/** - * VIR_ALLOC_N: - * @ptr: pointer to hold address of allocated memory - * @count: number of elements to allocate - * - * Allocate an array of 'count' elements, each sizeof(*ptr) - * bytes long and store the address of allocated memory in - * 'ptr'. Fill the newly allocated memory with zeros. - * - * This macro is safe to use on arguments with side effects. - * - * Returns 0 on success, aborts on OOM - */ -#define VIR_ALLOC_N(ptr, count) virAllocN(&(ptr), sizeof(*(ptr)), (count)) - /** * VIR_REALLOC_N: * @ptr: pointer to hold address of allocated memory -- 2.26.2

On Thu, Oct 08, 2020 at 02:12:06PM +0200, Ján Tomko wrote:
Ján Tomko (8): remote: refactor remoteSerializeDHCPLease libxl: xenParseXMOS: separate VIR_ALLOC call remote: use g_new0 instead of VIR_ALLOC remote: remoteDispatchAuthList: remove useless 'rv' src: use g_new0 instead of VIR_ALLOC tests: use g_new0 instead of VIR_ALLOC tests: delete VIR_ALLOC tests cases util: delete VIR_ALLOC and VIR_ALLOC_N
src/access/viraccessmanager.c | 3 +- src/admin/admin_server_dispatch.c | 6 +- src/hypervisor/domain_driver.c | 3 +- src/hypervisor/virclosecallbacks.c | 7 +- src/libvirt_private.syms | 2 - src/libxl/xen_xm.c | 9 +- src/remote/remote_daemon_config.c | 3 +- src/remote/remote_daemon_dispatch.c | 279 +++++++++------------------- src/remote/remote_daemon_stream.c | 6 +- src/remote/remote_driver.c | 102 +++------- src/test/test_driver.c | 66 +++---- src/util/viralloc.c | 39 ---- src/util/viralloc.h | 33 ---- tests/viralloctest.c | 89 +-------- 14 files changed, 157 insertions(+), 490 deletions(-)
With the build error fixed Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
participants (3)
-
John Ferlan
-
Ján Tomko
-
Pavel Hrdina