mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
remote: use g_strdup instead of VIR_STRDUP
Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a = g_strdup(b); Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
ce36e33c10
commit
b2d079c113
@ -1100,18 +1100,12 @@ int main(int argc, char **argv) {
|
||||
|
||||
case 'p':
|
||||
VIR_FREE(pid_file);
|
||||
if (VIR_STRDUP_QUIET(pid_file, optarg) < 0) {
|
||||
VIR_ERROR(_("Can't allocate memory"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
pid_file = g_strdup(optarg);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
VIR_FREE(remote_config_file);
|
||||
if (VIR_STRDUP_QUIET(remote_config_file, optarg) < 0) {
|
||||
VIR_ERROR(_("Can't allocate memory"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
remote_config_file = g_strdup(optarg);
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
@ -1222,10 +1216,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
/* Ensure the rundir exists (on tmpfs on some systems) */
|
||||
if (privileged) {
|
||||
if (VIR_STRDUP_QUIET(run_dir, RUNSTATEDIR "/libvirt") < 0) {
|
||||
VIR_ERROR(_("Can't allocate memory"));
|
||||
goto cleanup;
|
||||
}
|
||||
run_dir = g_strdup(RUNSTATEDIR "/libvirt");
|
||||
} else {
|
||||
run_dir = virGetUserRuntimeDirectory();
|
||||
|
||||
|
@ -77,9 +77,7 @@ int
|
||||
daemonConfigFilePath(bool privileged, char **configfile)
|
||||
{
|
||||
if (privileged) {
|
||||
if (VIR_STRDUP(*configfile,
|
||||
SYSCONFDIR "/libvirt/" DAEMON_NAME ".conf") < 0)
|
||||
goto error;
|
||||
*configfile = g_strdup(SYSCONFDIR "/libvirt/" DAEMON_NAME ".conf");
|
||||
} else {
|
||||
char *configdir = NULL;
|
||||
|
||||
@ -115,9 +113,8 @@ daemonConfigNew(bool privileged G_GNUC_UNUSED)
|
||||
# endif /* ! LIBVIRTD */
|
||||
data->listen_tcp = 0;
|
||||
|
||||
if (VIR_STRDUP(data->tls_port, LIBVIRTD_TLS_PORT) < 0 ||
|
||||
VIR_STRDUP(data->tcp_port, LIBVIRTD_TCP_PORT) < 0)
|
||||
goto error;
|
||||
data->tls_port = g_strdup(LIBVIRTD_TLS_PORT);
|
||||
data->tcp_port = g_strdup(LIBVIRTD_TCP_PORT);
|
||||
#endif /* !WITH_IP */
|
||||
|
||||
/* Only default to PolicyKit if running as root */
|
||||
@ -133,11 +130,9 @@ daemonConfigNew(bool privileged G_GNUC_UNUSED)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (VIR_STRDUP(data->unix_sock_rw_perms,
|
||||
data->auth_unix_rw == REMOTE_AUTH_POLKIT ? "0777" : "0700") < 0 ||
|
||||
VIR_STRDUP(data->unix_sock_ro_perms, "0777") < 0 ||
|
||||
VIR_STRDUP(data->unix_sock_admin_perms, "0700") < 0)
|
||||
goto error;
|
||||
data->unix_sock_rw_perms = g_strdup(data->auth_unix_rw == REMOTE_AUTH_POLKIT ? "0777" : "0700");
|
||||
data->unix_sock_ro_perms = g_strdup("0777");
|
||||
data->unix_sock_admin_perms = g_strdup("0700");
|
||||
|
||||
#ifdef WITH_IP
|
||||
# if WITH_SASL
|
||||
@ -176,10 +171,6 @@ daemonConfigNew(bool privileged G_GNUC_UNUSED)
|
||||
data->ovs_timeout = VIR_NETDEV_OVS_DEFAULT_TIMEOUT;
|
||||
|
||||
return data;
|
||||
|
||||
error:
|
||||
daemonConfigFree(data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
@ -266,8 +257,7 @@ daemonConfigLoadOptions(struct daemonConfig *data,
|
||||
*/
|
||||
if (data->auth_unix_rw == REMOTE_AUTH_POLKIT) {
|
||||
VIR_FREE(data->unix_sock_rw_perms);
|
||||
if (VIR_STRDUP(data->unix_sock_rw_perms, "0777") < 0)
|
||||
goto error;
|
||||
data->unix_sock_rw_perms = g_strdup("0777");
|
||||
}
|
||||
#endif
|
||||
if (remoteConfigGetAuth(conf, filename, "auth_unix_ro", &data->auth_unix_ro) < 0)
|
||||
|
@ -509,9 +509,8 @@ remoteRelayDomainEventIOError(virConnectPtr conn,
|
||||
|
||||
/* build return data */
|
||||
memset(&data, 0, sizeof(data));
|
||||
if (VIR_STRDUP(data.srcPath, srcPath) < 0 ||
|
||||
VIR_STRDUP(data.devAlias, devAlias) < 0)
|
||||
goto error;
|
||||
data.srcPath = g_strdup(srcPath);
|
||||
data.devAlias = g_strdup(devAlias);
|
||||
if (make_nonnull_domain(&data.dom, dom) < 0)
|
||||
goto error;
|
||||
data.action = action;
|
||||
@ -559,10 +558,9 @@ remoteRelayDomainEventIOErrorReason(virConnectPtr conn,
|
||||
|
||||
/* build return data */
|
||||
memset(&data, 0, sizeof(data));
|
||||
if (VIR_STRDUP(data.srcPath, srcPath) < 0 ||
|
||||
VIR_STRDUP(data.devAlias, devAlias) < 0 ||
|
||||
VIR_STRDUP(data.reason, reason) < 0)
|
||||
goto error;
|
||||
data.srcPath = g_strdup(srcPath);
|
||||
data.devAlias = g_strdup(devAlias);
|
||||
data.reason = g_strdup(reason);
|
||||
data.action = action;
|
||||
|
||||
if (make_nonnull_domain(&data.dom, dom) < 0)
|
||||
@ -623,21 +621,23 @@ remoteRelayDomainEventGraphics(virConnectPtr conn,
|
||||
data.phase = phase;
|
||||
data.local.family = local->family;
|
||||
data.remote.family = remote->family;
|
||||
if (VIR_STRDUP(data.authScheme, authScheme) < 0 ||
|
||||
VIR_STRDUP(data.local.node, local->node) < 0 ||
|
||||
VIR_STRDUP(data.local.service, local->service) < 0 ||
|
||||
VIR_STRDUP(data.remote.node, remote->node) < 0 ||
|
||||
VIR_STRDUP(data.remote.service, remote->service) < 0)
|
||||
goto error;
|
||||
data.authScheme = g_strdup(authScheme);
|
||||
|
||||
data.local.node = g_strdup(local->node);
|
||||
|
||||
data.local.service = g_strdup(local->service);
|
||||
|
||||
data.remote.node = g_strdup(remote->node);
|
||||
|
||||
data.remote.service = g_strdup(remote->service);
|
||||
|
||||
data.subject.subject_len = subject->nidentity;
|
||||
if (VIR_ALLOC_N(data.subject.subject_val, data.subject.subject_len) < 0)
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < data.subject.subject_len; i++) {
|
||||
if (VIR_STRDUP(data.subject.subject_val[i].type, subject->identities[i].type) < 0 ||
|
||||
VIR_STRDUP(data.subject.subject_val[i].name, subject->identities[i].name) < 0)
|
||||
goto error;
|
||||
data.subject.subject_val[i].type = g_strdup(subject->identities[i].type);
|
||||
data.subject.subject_val[i].name = g_strdup(subject->identities[i].name);
|
||||
}
|
||||
if (make_nonnull_domain(&data.dom, dom) < 0)
|
||||
goto error;
|
||||
@ -683,8 +683,7 @@ remoteRelayDomainEventBlockJob(virConnectPtr conn,
|
||||
|
||||
/* build return data */
|
||||
memset(&data, 0, sizeof(data));
|
||||
if (VIR_STRDUP(data.path, path) < 0)
|
||||
return -1;
|
||||
data.path = g_strdup(path);
|
||||
data.type = type;
|
||||
data.status = status;
|
||||
if (make_nonnull_domain(&data.dom, dom) < 0)
|
||||
@ -776,18 +775,19 @@ remoteRelayDomainEventDiskChange(virConnectPtr conn,
|
||||
|
||||
/* build return data */
|
||||
memset(&data, 0, sizeof(data));
|
||||
if (oldSrcPath &&
|
||||
((VIR_ALLOC(data.oldSrcPath) < 0) ||
|
||||
VIR_STRDUP(*(data.oldSrcPath), oldSrcPath) < 0))
|
||||
goto error;
|
||||
if (oldSrcPath) {
|
||||
if (VIR_ALLOC(data.oldSrcPath) < 0)
|
||||
goto error;
|
||||
*(data.oldSrcPath) = g_strdup(oldSrcPath);
|
||||
}
|
||||
|
||||
if (newSrcPath &&
|
||||
((VIR_ALLOC(data.newSrcPath) < 0) ||
|
||||
VIR_STRDUP(*(data.newSrcPath), newSrcPath) < 0))
|
||||
goto error;
|
||||
if (newSrcPath) {
|
||||
if (VIR_ALLOC(data.newSrcPath) < 0)
|
||||
goto error;
|
||||
*(data.newSrcPath) = g_strdup(newSrcPath);
|
||||
}
|
||||
|
||||
if (VIR_STRDUP(data.devAlias, devAlias) < 0)
|
||||
goto error;
|
||||
data.devAlias = g_strdup(devAlias);
|
||||
data.reason = reason;
|
||||
|
||||
if (make_nonnull_domain(&data.dom, dom) < 0)
|
||||
@ -835,8 +835,7 @@ remoteRelayDomainEventTrayChange(virConnectPtr conn,
|
||||
/* build return data */
|
||||
memset(&data, 0, sizeof(data));
|
||||
|
||||
if (VIR_STRDUP(data.devAlias, devAlias) < 0)
|
||||
return -1;
|
||||
data.devAlias = g_strdup(devAlias);
|
||||
data.reason = reason;
|
||||
|
||||
if (make_nonnull_domain(&data.dom, dom) < 0)
|
||||
@ -1052,8 +1051,7 @@ remoteRelayDomainEventDeviceRemoved(virConnectPtr conn,
|
||||
/* build return data */
|
||||
memset(&data, 0, sizeof(data));
|
||||
|
||||
if (VIR_STRDUP(data.devAlias, devAlias) < 0)
|
||||
return -1;
|
||||
data.devAlias = g_strdup(devAlias);
|
||||
|
||||
if (make_nonnull_domain(&data.dom, dom) < 0)
|
||||
goto error;
|
||||
@ -1103,8 +1101,7 @@ remoteRelayDomainEventBlockJob2(virConnectPtr conn,
|
||||
/* build return data */
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.callbackID = callback->callbackID;
|
||||
if (VIR_STRDUP(data.dst, dst) < 0)
|
||||
return -1;
|
||||
data.dst = g_strdup(dst);
|
||||
data.type = type;
|
||||
data.status = status;
|
||||
if (make_nonnull_domain(&data.dom, dom) < 0)
|
||||
@ -1228,8 +1225,7 @@ remoteRelayDomainEventDeviceAdded(virConnectPtr conn,
|
||||
/* build return data */
|
||||
memset(&data, 0, sizeof(data));
|
||||
|
||||
if (VIR_STRDUP(data.devAlias, devAlias) < 0)
|
||||
return -1;
|
||||
data.devAlias = g_strdup(devAlias);
|
||||
|
||||
if (make_nonnull_domain(&data.dom, dom) < 0)
|
||||
goto error;
|
||||
@ -1352,8 +1348,7 @@ remoteRelayDomainEventDeviceRemovalFailed(virConnectPtr conn,
|
||||
/* build return data */
|
||||
memset(&data, 0, sizeof(data));
|
||||
|
||||
if (VIR_STRDUP(data.devAlias, devAlias) < 0)
|
||||
return -1;
|
||||
data.devAlias = g_strdup(devAlias);
|
||||
|
||||
if (make_nonnull_domain(&data.dom, dom) < 0)
|
||||
goto error;
|
||||
@ -1395,9 +1390,9 @@ remoteRelayDomainEventMetadataChange(virConnectPtr conn,
|
||||
|
||||
data.type = type;
|
||||
if (nsuri) {
|
||||
if (VIR_ALLOC(data.nsuri) < 0 ||
|
||||
VIR_STRDUP(*(data.nsuri), nsuri) < 0)
|
||||
if (VIR_ALLOC(data.nsuri) < 0)
|
||||
goto error;
|
||||
*(data.nsuri) = g_strdup(nsuri);
|
||||
}
|
||||
|
||||
if (make_nonnull_domain(&data.dom, dom) < 0)
|
||||
@ -1440,12 +1435,11 @@ remoteRelayDomainEventBlockThreshold(virConnectPtr conn,
|
||||
/* build return data */
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.callbackID = callback->callbackID;
|
||||
if (VIR_STRDUP(data.dev, dev) < 0)
|
||||
goto error;
|
||||
data.dev = g_strdup(dev);
|
||||
if (path) {
|
||||
if (VIR_ALLOC(data.path) < 0 ||
|
||||
VIR_STRDUP(*(data.path), path) < 0)
|
||||
if (VIR_ALLOC(data.path) < 0)
|
||||
goto error;
|
||||
*(data.path) = g_strdup(path);
|
||||
}
|
||||
data.threshold = threshold;
|
||||
data.excess = excess;
|
||||
@ -1798,14 +1792,14 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr conn,
|
||||
/* build return data */
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.callbackID = callback->callbackID;
|
||||
if (VIR_STRDUP(data.event, event) < 0)
|
||||
goto error;
|
||||
data.event = g_strdup(event);
|
||||
data.seconds = seconds;
|
||||
data.micros = micros;
|
||||
if (details &&
|
||||
((VIR_ALLOC(data.details) < 0) ||
|
||||
VIR_STRDUP(*(data.details), details) < 0))
|
||||
goto error;
|
||||
if (details) {
|
||||
if (VIR_ALLOC(data.details) < 0)
|
||||
goto error;
|
||||
*(data.details) = g_strdup(details);
|
||||
}
|
||||
if (make_nonnull_domain(&data.dom, dom) < 0)
|
||||
goto error;
|
||||
|
||||
@ -2886,11 +2880,7 @@ remoteDispatchDomainGetSecurityLabelList(virNetServerPtr server G_GNUC_UNUSED,
|
||||
for (i = 0; i < len; i++) {
|
||||
size_t label_len = strlen(seclabels[i].label) + 1;
|
||||
remote_domain_get_security_label_ret *cur = &ret->labels.labels_val[i];
|
||||
if (VIR_STRDUP(cur->label.label_val, seclabels[i].label) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("failed to copy security label"));
|
||||
goto cleanup;
|
||||
}
|
||||
cur->label.label_val = g_strdup(seclabels[i].label);
|
||||
cur->label.label_len = label_len;
|
||||
cur->enforcing = seclabels[i].enforcing;
|
||||
}
|
||||
@ -3560,8 +3550,7 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr server G_GNUC_UNUSED,
|
||||
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
/* remoteDispatchClientRequest will free this: */
|
||||
if (VIR_STRDUP(ret->params.params_val[i].field, params[i].field) < 0)
|
||||
goto cleanup;
|
||||
ret->params.params_val[i].field = g_strdup(params[i].field);
|
||||
|
||||
ret->params.params_val[i].value = params[i].value;
|
||||
}
|
||||
@ -3629,8 +3618,7 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr server G_GNUC_UNUSED,
|
||||
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
/* remoteDispatchClientRequest will free this: */
|
||||
if (VIR_STRDUP(ret->params.params_val[i].field, params[i].field) < 0)
|
||||
goto cleanup;
|
||||
ret->params.params_val[i].field = g_strdup(params[i].field);
|
||||
|
||||
ret->params.params_val[i].value = params[i].value;
|
||||
}
|
||||
@ -4365,9 +4353,9 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr server G_GNUC_UNUSED,
|
||||
ret->parentName = NULL;
|
||||
} else {
|
||||
/* remoteDispatchClientRequest will free this. */
|
||||
if (VIR_ALLOC(ret->parentName) < 0 ||
|
||||
VIR_STRDUP(*(ret->parentName), parent) < 0)
|
||||
if (VIR_ALLOC(ret->parentName) < 0)
|
||||
goto cleanup;
|
||||
*(ret->parentName) = g_strdup(parent);
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
@ -6907,29 +6895,28 @@ remoteSerializeDHCPLease(remote_network_dhcp_lease *lease_dst, virNetworkDHCPLea
|
||||
lease_dst->type = lease_src->type;
|
||||
lease_dst->prefix = lease_src->prefix;
|
||||
|
||||
if (VIR_STRDUP(lease_dst->iface, lease_src->iface) < 0 ||
|
||||
VIR_STRDUP(lease_dst->ipaddr, lease_src->ipaddr) < 0)
|
||||
goto error;
|
||||
lease_dst->iface = g_strdup(lease_src->iface);
|
||||
lease_dst->ipaddr = g_strdup(lease_src->ipaddr);
|
||||
|
||||
if (lease_src->mac) {
|
||||
if (VIR_ALLOC(mac_tmp) < 0 ||
|
||||
VIR_STRDUP(*mac_tmp, lease_src->mac) < 0)
|
||||
if (VIR_ALLOC(mac_tmp) < 0)
|
||||
goto error;
|
||||
*mac_tmp = g_strdup(lease_src->mac);
|
||||
}
|
||||
if (lease_src->iaid) {
|
||||
if (VIR_ALLOC(iaid_tmp) < 0 ||
|
||||
VIR_STRDUP(*iaid_tmp, lease_src->iaid) < 0)
|
||||
if (VIR_ALLOC(iaid_tmp) < 0)
|
||||
goto error;
|
||||
*iaid_tmp = g_strdup(lease_src->iaid);
|
||||
}
|
||||
if (lease_src->hostname) {
|
||||
if (VIR_ALLOC(hostname_tmp) < 0 ||
|
||||
VIR_STRDUP(*hostname_tmp, lease_src->hostname) < 0)
|
||||
if (VIR_ALLOC(hostname_tmp) < 0)
|
||||
goto error;
|
||||
*hostname_tmp = g_strdup(lease_src->hostname);
|
||||
}
|
||||
if (lease_src->clientid) {
|
||||
if (VIR_ALLOC(clientid_tmp) < 0 ||
|
||||
VIR_STRDUP(*clientid_tmp, lease_src->clientid) < 0)
|
||||
if (VIR_ALLOC(clientid_tmp) < 0)
|
||||
goto error;
|
||||
*clientid_tmp = g_strdup(lease_src->clientid);
|
||||
}
|
||||
|
||||
lease_dst->mac = mac_tmp;
|
||||
@ -7188,14 +7175,11 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr server G_GNUC_UNUSED,
|
||||
|
||||
for (i = 0; i < ninfo; i++) {
|
||||
dst = &ret->info.info_val[i];
|
||||
if (VIR_STRDUP(dst->mountpoint, info[i]->mountpoint) < 0)
|
||||
goto cleanup;
|
||||
dst->mountpoint = g_strdup(info[i]->mountpoint);
|
||||
|
||||
if (VIR_STRDUP(dst->name, info[i]->name) < 0)
|
||||
goto cleanup;
|
||||
dst->name = g_strdup(info[i]->name);
|
||||
|
||||
if (VIR_STRDUP(dst->fstype, info[i]->fstype) < 0)
|
||||
goto cleanup;
|
||||
dst->fstype = g_strdup(info[i]->fstype);
|
||||
|
||||
ndisk = info[i]->ndevAlias;
|
||||
if (ndisk > REMOTE_DOMAIN_FSINFO_DISKS_MAX) {
|
||||
@ -7209,11 +7193,8 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr server G_GNUC_UNUSED,
|
||||
if (VIR_ALLOC_N(dst->dev_aliases.dev_aliases_val, ndisk) < 0)
|
||||
goto cleanup;
|
||||
|
||||
for (j = 0; j < ndisk; j++) {
|
||||
if (VIR_STRDUP(dst->dev_aliases.dev_aliases_val[j],
|
||||
info[i]->devAlias[j]) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
for (j = 0; j < ndisk; j++)
|
||||
dst->dev_aliases.dev_aliases_val[j] = g_strdup(info[i]->devAlias[j]);
|
||||
|
||||
dst->dev_aliases.dev_aliases_len = ndisk;
|
||||
} else {
|
||||
@ -7281,13 +7262,13 @@ remoteSerializeDomainInterface(virDomainInterfacePtr *ifaces,
|
||||
virDomainInterfacePtr iface = ifaces[i];
|
||||
remote_domain_interface *iface_ret = &(ret->ifaces.ifaces_val[i]);
|
||||
|
||||
if ((VIR_STRDUP(iface_ret->name, iface->name)) < 0)
|
||||
goto cleanup;
|
||||
iface_ret->name = g_strdup(iface->name);
|
||||
|
||||
if (iface->hwaddr &&
|
||||
(VIR_ALLOC(iface_ret->hwaddr) < 0 ||
|
||||
VIR_STRDUP(*iface_ret->hwaddr, iface->hwaddr) < 0))
|
||||
goto cleanup;
|
||||
if (iface->hwaddr) {
|
||||
if (VIR_ALLOC(iface_ret->hwaddr) < 0)
|
||||
goto cleanup;
|
||||
*iface_ret->hwaddr = g_strdup(iface->hwaddr);
|
||||
}
|
||||
|
||||
if (iface->naddrs > REMOTE_DOMAIN_IP_ADDR_MAX) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
@ -7307,8 +7288,7 @@ remoteSerializeDomainInterface(virDomainInterfacePtr *ifaces,
|
||||
remote_domain_ip_addr *ip_addr_ret =
|
||||
&(iface_ret->addrs.addrs_val[j]);
|
||||
|
||||
if (VIR_STRDUP(ip_addr_ret->addr, ip_addr->addr) < 0)
|
||||
goto cleanup;
|
||||
ip_addr_ret->addr = g_strdup(ip_addr->addr);
|
||||
|
||||
ip_addr_ret->prefix = ip_addr->prefix;
|
||||
ip_addr_ret->type = ip_addr->type;
|
||||
@ -7559,8 +7539,7 @@ static int
|
||||
make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainPtr dom_src)
|
||||
{
|
||||
dom_dst->id = dom_src->id;
|
||||
if (VIR_STRDUP(dom_dst->name, dom_src->name) < 0)
|
||||
return -1;
|
||||
dom_dst->name = g_strdup(dom_src->name);
|
||||
memcpy(dom_dst->uuid, dom_src->uuid, VIR_UUID_BUFLEN);
|
||||
return 0;
|
||||
}
|
||||
@ -7568,8 +7547,7 @@ make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainPtr dom_src)
|
||||
static int
|
||||
make_nonnull_network(remote_nonnull_network *net_dst, virNetworkPtr net_src)
|
||||
{
|
||||
if (VIR_STRDUP(net_dst->name, net_src->name) < 0)
|
||||
return -1;
|
||||
net_dst->name = g_strdup(net_src->name);
|
||||
memcpy(net_dst->uuid, net_src->uuid, VIR_UUID_BUFLEN);
|
||||
return 0;
|
||||
}
|
||||
@ -7577,8 +7555,7 @@ make_nonnull_network(remote_nonnull_network *net_dst, virNetworkPtr net_src)
|
||||
static int
|
||||
make_nonnull_network_port(remote_nonnull_network_port *port_dst, virNetworkPortPtr port_src)
|
||||
{
|
||||
if (VIR_STRDUP(port_dst->net.name, port_src->net->name) < 0)
|
||||
return -1;
|
||||
port_dst->net.name = g_strdup(port_src->net->name);
|
||||
memcpy(port_dst->net.uuid, port_src->net->uuid, VIR_UUID_BUFLEN);
|
||||
memcpy(port_dst->uuid, port_src->uuid, VIR_UUID_BUFLEN);
|
||||
return 0;
|
||||
@ -7588,20 +7565,15 @@ static int
|
||||
make_nonnull_interface(remote_nonnull_interface *interface_dst,
|
||||
virInterfacePtr interface_src)
|
||||
{
|
||||
if (VIR_STRDUP(interface_dst->name, interface_src->name) < 0)
|
||||
return -1;
|
||||
if (VIR_STRDUP(interface_dst->mac, interface_src->mac) < 0) {
|
||||
VIR_FREE(interface_dst->name);
|
||||
return -1;
|
||||
}
|
||||
interface_dst->name = g_strdup(interface_src->name);
|
||||
interface_dst->mac = g_strdup(interface_src->mac);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
make_nonnull_storage_pool(remote_nonnull_storage_pool *pool_dst, virStoragePoolPtr pool_src)
|
||||
{
|
||||
if (VIR_STRDUP(pool_dst->name, pool_src->name) < 0)
|
||||
return -1;
|
||||
pool_dst->name = g_strdup(pool_src->name);
|
||||
memcpy(pool_dst->uuid, pool_src->uuid, VIR_UUID_BUFLEN);
|
||||
return 0;
|
||||
}
|
||||
@ -7609,25 +7581,16 @@ make_nonnull_storage_pool(remote_nonnull_storage_pool *pool_dst, virStoragePoolP
|
||||
static int
|
||||
make_nonnull_storage_vol(remote_nonnull_storage_vol *vol_dst, virStorageVolPtr vol_src)
|
||||
{
|
||||
if (VIR_STRDUP(vol_dst->pool, vol_src->pool) < 0)
|
||||
return -1;
|
||||
if (VIR_STRDUP(vol_dst->name, vol_src->name) < 0) {
|
||||
VIR_FREE(vol_dst->pool);
|
||||
return -1;
|
||||
}
|
||||
if (VIR_STRDUP(vol_dst->key, vol_src->key) < 0) {
|
||||
VIR_FREE(vol_dst->pool);
|
||||
VIR_FREE(vol_dst->name);
|
||||
return -1;
|
||||
}
|
||||
vol_dst->pool = g_strdup(vol_src->pool);
|
||||
vol_dst->name = g_strdup(vol_src->name);
|
||||
vol_dst->key = g_strdup(vol_src->key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
make_nonnull_node_device(remote_nonnull_node_device *dev_dst, virNodeDevicePtr dev_src)
|
||||
{
|
||||
if (VIR_STRDUP(dev_dst->name, dev_src->name) < 0)
|
||||
return -1;
|
||||
dev_dst->name = g_strdup(dev_src->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -7636,16 +7599,14 @@ make_nonnull_secret(remote_nonnull_secret *secret_dst, virSecretPtr secret_src)
|
||||
{
|
||||
memcpy(secret_dst->uuid, secret_src->uuid, VIR_UUID_BUFLEN);
|
||||
secret_dst->usageType = secret_src->usageType;
|
||||
if (VIR_STRDUP(secret_dst->usageID, secret_src->usageID) < 0)
|
||||
return -1;
|
||||
secret_dst->usageID = g_strdup(secret_src->usageID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
make_nonnull_nwfilter(remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfilter_src)
|
||||
{
|
||||
if (VIR_STRDUP(nwfilter_dst->name, nwfilter_src->name) < 0)
|
||||
return -1;
|
||||
nwfilter_dst->name = g_strdup(nwfilter_src->name);
|
||||
memcpy(nwfilter_dst->uuid, nwfilter_src->uuid, VIR_UUID_BUFLEN);
|
||||
return 0;
|
||||
}
|
||||
@ -7653,20 +7614,15 @@ make_nonnull_nwfilter(remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfi
|
||||
static int
|
||||
make_nonnull_nwfilter_binding(remote_nonnull_nwfilter_binding *binding_dst, virNWFilterBindingPtr binding_src)
|
||||
{
|
||||
if (VIR_STRDUP(binding_dst->portdev, binding_src->portdev) < 0)
|
||||
return -1;
|
||||
if (VIR_STRDUP(binding_dst->filtername, binding_src->filtername) < 0) {
|
||||
VIR_FREE(binding_dst->portdev);
|
||||
return -1;
|
||||
}
|
||||
binding_dst->portdev = g_strdup(binding_src->portdev);
|
||||
binding_dst->filtername = g_strdup(binding_src->filtername);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
make_nonnull_domain_checkpoint(remote_nonnull_domain_checkpoint *checkpoint_dst, virDomainCheckpointPtr checkpoint_src)
|
||||
{
|
||||
if (VIR_STRDUP(checkpoint_dst->name, checkpoint_src->name) < 0)
|
||||
return -1;
|
||||
checkpoint_dst->name = g_strdup(checkpoint_src->name);
|
||||
if (make_nonnull_domain(&checkpoint_dst->dom, checkpoint_src->domain) < 0) {
|
||||
VIR_FREE(checkpoint_dst->name);
|
||||
return -1;
|
||||
@ -7677,8 +7633,7 @@ make_nonnull_domain_checkpoint(remote_nonnull_domain_checkpoint *checkpoint_dst,
|
||||
static int
|
||||
make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src)
|
||||
{
|
||||
if (VIR_STRDUP(snapshot_dst->name, snapshot_src->name) < 0)
|
||||
return -1;
|
||||
snapshot_dst->name = g_strdup(snapshot_src->name);
|
||||
if (make_nonnull_domain(&snapshot_dst->dom, snapshot_src->domain) < 0) {
|
||||
VIR_FREE(snapshot_dst->name);
|
||||
return -1;
|
||||
@ -7699,8 +7654,7 @@ remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr errors,
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < nerrors; i++) {
|
||||
if (VIR_STRDUP(val[i].disk, errors[i].disk) < 0)
|
||||
goto error;
|
||||
val[i].disk = g_strdup(errors[i].disk);
|
||||
val[i].error = errors[i].error;
|
||||
}
|
||||
|
||||
|
@ -219,10 +219,7 @@ static int remoteSplitURIScheme(virURIPtr uri,
|
||||
return -1;
|
||||
|
||||
if (p) {
|
||||
if (VIR_STRDUP(*transport, p + 1) < 0) {
|
||||
VIR_FREE(*driver);
|
||||
return -1;
|
||||
}
|
||||
*transport = g_strdup(p + 1);
|
||||
|
||||
p = *transport;
|
||||
while (*p) {
|
||||
@ -744,8 +741,7 @@ remoteConnectSupportsFeatureUnlocked(virConnectPtr conn,
|
||||
#define EXTRACT_URI_ARG_STR(ARG_NAME, ARG_VAR) \
|
||||
if (STRCASEEQ(var->name, ARG_NAME)) { \
|
||||
VIR_FREE(ARG_VAR); \
|
||||
if (VIR_STRDUP(ARG_VAR, var->value) < 0) \
|
||||
goto failed; \
|
||||
ARG_VAR = g_strdup(var->value); \
|
||||
var->ignore = 1; \
|
||||
continue; \
|
||||
}
|
||||
@ -826,8 +822,7 @@ remoteGetUNIXSocket(remoteDriverTransport transport,
|
||||
virAsprintf(&direct_daemon, "virt%sd", driver) < 0)
|
||||
return NULL;
|
||||
|
||||
if (VIR_STRDUP(legacy_daemon, "libvirtd") < 0)
|
||||
return NULL;
|
||||
legacy_daemon = g_strdup("libvirtd");
|
||||
|
||||
if (driver &&
|
||||
!(direct_sock_name = remoteGetUNIXSocketHelper(transport, direct_daemon, flags)))
|
||||
@ -1011,20 +1006,15 @@ doRemoteOpen(virConnectPtr conn,
|
||||
if (virAsprintf(&port, "%d", conn->uri->port) < 0)
|
||||
goto failed;
|
||||
} else if (transport == REMOTE_DRIVER_TRANSPORT_TLS) {
|
||||
if (VIR_STRDUP(port, LIBVIRTD_TLS_PORT) < 0)
|
||||
goto failed;
|
||||
port = g_strdup(LIBVIRTD_TLS_PORT);
|
||||
} else if (transport == REMOTE_DRIVER_TRANSPORT_TCP) {
|
||||
if (VIR_STRDUP(port, LIBVIRTD_TCP_PORT) < 0)
|
||||
goto failed;
|
||||
port = g_strdup(LIBVIRTD_TCP_PORT);
|
||||
} /* Port not used for unix, ext., default for ssh */
|
||||
|
||||
if (VIR_STRDUP(priv->hostname,
|
||||
conn->uri && conn->uri->server ?
|
||||
conn->uri->server : "localhost") < 0)
|
||||
goto failed;
|
||||
priv->hostname = g_strdup(conn->uri && conn->uri->server ? conn->uri->server : "localhost");
|
||||
|
||||
if (conn->uri && VIR_STRDUP(username, conn->uri->user) < 0)
|
||||
goto failed;
|
||||
if (conn->uri)
|
||||
username = g_strdup(conn->uri->user);
|
||||
|
||||
/* Get the variables from the query string.
|
||||
* Then we need to reconstruct the query string (because
|
||||
@ -1070,8 +1060,7 @@ doRemoteOpen(virConnectPtr conn,
|
||||
(STREQ(conn->uri->scheme, "remote") ||
|
||||
STRPREFIX(conn->uri->scheme, "remote+"))) {
|
||||
/* Allow remote serve to probe */
|
||||
if (VIR_STRDUP(name, "") < 0)
|
||||
goto failed;
|
||||
name = g_strdup("");
|
||||
} else {
|
||||
virURI tmpuri = {
|
||||
.scheme = (char *)driver_str,
|
||||
@ -1090,8 +1079,7 @@ doRemoteOpen(virConnectPtr conn,
|
||||
}
|
||||
} else {
|
||||
/* Probe URI server side */
|
||||
if (VIR_STRDUP(name, "") < 0)
|
||||
goto failed;
|
||||
name = g_strdup("");
|
||||
}
|
||||
|
||||
if (conf && !mode_str &&
|
||||
@ -1934,8 +1922,7 @@ remoteDeserializeDomainDiskErrors(remote_domain_disk_error *ret_errors_val,
|
||||
}
|
||||
|
||||
for (i = 0; i < ret_errors_len; i++) {
|
||||
if (VIR_STRDUP(errors[i].disk, ret_errors_val[i].disk) < 0)
|
||||
goto error;
|
||||
errors[i].disk = g_strdup(ret_errors_val[i].disk);
|
||||
errors[i].error = ret_errors_val[i].error;
|
||||
}
|
||||
|
||||
@ -4924,16 +4911,14 @@ remoteDomainBuildEventGraphicsHelper(virConnectPtr conn,
|
||||
if (VIR_ALLOC(localAddr) < 0)
|
||||
goto error;
|
||||
localAddr->family = msg->local.family;
|
||||
if (VIR_STRDUP(localAddr->service, msg->local.service) < 0 ||
|
||||
VIR_STRDUP(localAddr->node, msg->local.node) < 0)
|
||||
goto error;
|
||||
localAddr->service = g_strdup(msg->local.service);
|
||||
localAddr->node = g_strdup(msg->local.node);
|
||||
|
||||
if (VIR_ALLOC(remoteAddr) < 0)
|
||||
goto error;
|
||||
remoteAddr->family = msg->remote.family;
|
||||
if (VIR_STRDUP(remoteAddr->service, msg->remote.service) < 0 ||
|
||||
VIR_STRDUP(remoteAddr->node, msg->remote.node) < 0)
|
||||
goto error;
|
||||
remoteAddr->service = g_strdup(msg->remote.service);
|
||||
remoteAddr->node = g_strdup(msg->remote.node);
|
||||
|
||||
if (VIR_ALLOC(subject) < 0)
|
||||
goto error;
|
||||
@ -4941,9 +4926,8 @@ remoteDomainBuildEventGraphicsHelper(virConnectPtr conn,
|
||||
goto error;
|
||||
subject->nidentity = msg->subject.subject_len;
|
||||
for (i = 0; i < subject->nidentity; i++) {
|
||||
if (VIR_STRDUP(subject->identities[i].type, msg->subject.subject_val[i].type) < 0 ||
|
||||
VIR_STRDUP(subject->identities[i].name, msg->subject.subject_val[i].name) < 0)
|
||||
goto error;
|
||||
subject->identities[i].type = g_strdup(msg->subject.subject_val[i].type);
|
||||
subject->identities[i].name = g_strdup(msg->subject.subject_val[i].name);
|
||||
}
|
||||
|
||||
event = virDomainEventGraphicsNewFromDom(dom,
|
||||
@ -6158,12 +6142,10 @@ remoteDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
|
||||
(xdrproc_t) xdr_qemu_domain_monitor_command_ret, (char *) &ret) == -1)
|
||||
goto done;
|
||||
|
||||
if (VIR_STRDUP(*result, ret.result) < 0)
|
||||
goto cleanup;
|
||||
*result = g_strdup(ret.result);
|
||||
|
||||
rv = 0;
|
||||
|
||||
cleanup:
|
||||
xdr_free((xdrproc_t) xdr_qemu_domain_monitor_command_ret, (char *) &ret);
|
||||
|
||||
done:
|
||||
@ -7658,45 +7640,35 @@ remoteSerializeDHCPLease(virNetworkDHCPLeasePtr lease_dst, remote_network_dhcp_l
|
||||
lease_dst->type = lease_src->type;
|
||||
lease_dst->prefix = lease_src->prefix;
|
||||
|
||||
if (VIR_STRDUP(lease_dst->iface, lease_src->iface) < 0)
|
||||
goto error;
|
||||
lease_dst->iface = g_strdup(lease_src->iface);
|
||||
|
||||
if (VIR_STRDUP(lease_dst->ipaddr, lease_src->ipaddr) < 0)
|
||||
goto error;
|
||||
lease_dst->ipaddr = g_strdup(lease_src->ipaddr);
|
||||
|
||||
if (lease_src->mac) {
|
||||
if (VIR_STRDUP(lease_dst->mac, *lease_src->mac) < 0)
|
||||
goto error;
|
||||
lease_dst->mac = g_strdup(*lease_src->mac);
|
||||
} else {
|
||||
lease_src->mac = NULL;
|
||||
}
|
||||
|
||||
if (lease_src->iaid) {
|
||||
if (VIR_STRDUP(lease_dst->iaid, *lease_src->iaid) < 0)
|
||||
goto error;
|
||||
lease_dst->iaid = g_strdup(*lease_src->iaid);
|
||||
} else {
|
||||
lease_src->iaid = NULL;
|
||||
}
|
||||
|
||||
if (lease_src->hostname) {
|
||||
if (VIR_STRDUP(lease_dst->hostname, *lease_src->hostname) < 0)
|
||||
goto error;
|
||||
lease_dst->hostname = g_strdup(*lease_src->hostname);
|
||||
} else {
|
||||
lease_src->hostname = NULL;
|
||||
}
|
||||
|
||||
if (lease_src->clientid) {
|
||||
if (VIR_STRDUP(lease_dst->clientid, *lease_src->clientid) < 0)
|
||||
goto error;
|
||||
lease_dst->clientid = g_strdup(*lease_src->clientid);
|
||||
} else {
|
||||
lease_src->clientid = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
virNetworkDHCPLeaseFree(lease_dst);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@ -7953,14 +7925,11 @@ remoteDomainGetFSInfo(virDomainPtr dom,
|
||||
if (VIR_ALLOC(info_ret[i]) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (VIR_STRDUP(info_ret[i]->mountpoint, src->mountpoint) < 0)
|
||||
goto cleanup;
|
||||
info_ret[i]->mountpoint = g_strdup(src->mountpoint);
|
||||
|
||||
if (VIR_STRDUP(info_ret[i]->name, src->name) < 0)
|
||||
goto cleanup;
|
||||
info_ret[i]->name = g_strdup(src->name);
|
||||
|
||||
if (VIR_STRDUP(info_ret[i]->fstype, src->fstype) < 0)
|
||||
goto cleanup;
|
||||
info_ret[i]->fstype = g_strdup(src->fstype);
|
||||
|
||||
len = src->dev_aliases.dev_aliases_len;
|
||||
info_ret[i]->ndevAlias = len;
|
||||
@ -7968,11 +7937,8 @@ remoteDomainGetFSInfo(virDomainPtr dom,
|
||||
VIR_ALLOC_N(info_ret[i]->devAlias, len) < 0)
|
||||
goto cleanup;
|
||||
|
||||
for (j = 0; j < len; j++) {
|
||||
if (VIR_STRDUP(info_ret[i]->devAlias[j],
|
||||
src->dev_aliases.dev_aliases_val[j]) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
for (j = 0; j < len; j++)
|
||||
info_ret[i]->devAlias[j] = g_strdup(src->dev_aliases.dev_aliases_val[j]);
|
||||
}
|
||||
|
||||
*info = info_ret;
|
||||
@ -8047,12 +8013,10 @@ remoteDomainInterfaceAddresses(virDomainPtr dom,
|
||||
|
||||
iface = ifaces_ret[i];
|
||||
|
||||
if (VIR_STRDUP(iface->name, iface_ret->name) < 0)
|
||||
goto cleanup;
|
||||
iface->name = g_strdup(iface_ret->name);
|
||||
|
||||
if (iface_ret->hwaddr &&
|
||||
VIR_STRDUP(iface->hwaddr, *iface_ret->hwaddr) < 0)
|
||||
goto cleanup;
|
||||
if (iface_ret->hwaddr)
|
||||
iface->hwaddr = g_strdup(*iface_ret->hwaddr);
|
||||
|
||||
if (iface_ret->addrs.addrs_len > REMOTE_DOMAIN_IP_ADDR_MAX) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
@ -8072,8 +8036,7 @@ remoteDomainInterfaceAddresses(virDomainPtr dom,
|
||||
remote_domain_ip_addr *ip_addr_ret =
|
||||
&(iface_ret->addrs.addrs_val[j]);
|
||||
|
||||
if (VIR_STRDUP(ip_addr->addr, ip_addr_ret->addr) < 0)
|
||||
goto cleanup;
|
||||
ip_addr->addr = g_strdup(ip_addr_ret->addr);
|
||||
|
||||
ip_addr->prefix = ip_addr_ret->prefix;
|
||||
ip_addr->type = ip_addr_ret->type;
|
||||
@ -8170,8 +8133,7 @@ remoteDomainRename(virDomainPtr dom, const char *new_name, unsigned int flags)
|
||||
remote_domain_rename_ret ret;
|
||||
char *tmp = NULL;
|
||||
|
||||
if (VIR_STRDUP(tmp, new_name) < 0)
|
||||
return -1;
|
||||
tmp = g_strdup(new_name);
|
||||
|
||||
remoteDriverLock(priv);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user