提交 0310d97a 编写于 作者: J Ján Tomko

vboxDumpNetwork: Use a single utf8 temp variable

Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 56a3f565
...@@ -3700,7 +3700,7 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter) ...@@ -3700,7 +3700,7 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter)
PRUint32 attachmentType = NetworkAttachmentType_Null; PRUint32 attachmentType = NetworkAttachmentType_Null;
PRUint32 adapterType = NetworkAdapterType_Null; PRUint32 adapterType = NetworkAdapterType_Null;
PRUnichar *utf16 = NULL; PRUnichar *utf16 = NULL;
char *MACAddress = NULL; char *utf8 = NULL;
virDomainNetDefPtr net = NULL; virDomainNetDefPtr net = NULL;
if (VIR_ALLOC(net) < 0) if (VIR_ALLOC(net) < 0)
...@@ -3712,42 +3712,36 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter) ...@@ -3712,42 +3712,36 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter)
net->type = VIR_DOMAIN_NET_TYPE_USER; net->type = VIR_DOMAIN_NET_TYPE_USER;
} else if (attachmentType == NetworkAttachmentType_Bridged) { } else if (attachmentType == NetworkAttachmentType_Bridged) {
char *hostInt = NULL;
net->type = VIR_DOMAIN_NET_TYPE_BRIDGE; net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
gVBoxAPI.UINetworkAdapter.GetBridgedInterface(adapter, &utf16); gVBoxAPI.UINetworkAdapter.GetBridgedInterface(adapter, &utf16);
VBOX_UTF16_TO_UTF8(utf16, &hostInt); VBOX_UTF16_TO_UTF8(utf16, &utf8);
ignore_value(VIR_STRDUP(net->data.bridge.brname, hostInt)); ignore_value(VIR_STRDUP(net->data.bridge.brname, utf8));
VBOX_UTF8_FREE(hostInt); VBOX_UTF8_FREE(utf8);
VBOX_UTF16_FREE(utf16); VBOX_UTF16_FREE(utf16);
} else if (attachmentType == NetworkAttachmentType_Internal) { } else if (attachmentType == NetworkAttachmentType_Internal) {
char *intNet = NULL;
net->type = VIR_DOMAIN_NET_TYPE_INTERNAL; net->type = VIR_DOMAIN_NET_TYPE_INTERNAL;
gVBoxAPI.UINetworkAdapter.GetInternalNetwork(adapter, &utf16); gVBoxAPI.UINetworkAdapter.GetInternalNetwork(adapter, &utf16);
VBOX_UTF16_TO_UTF8(utf16, &intNet); VBOX_UTF16_TO_UTF8(utf16, &utf8);
ignore_value(VIR_STRDUP(net->data.internal.name, intNet)); ignore_value(VIR_STRDUP(net->data.internal.name, utf8));
VBOX_UTF8_FREE(intNet); VBOX_UTF8_FREE(utf8);
VBOX_UTF16_FREE(utf16); VBOX_UTF16_FREE(utf16);
} else if (attachmentType == NetworkAttachmentType_HostOnly) { } else if (attachmentType == NetworkAttachmentType_HostOnly) {
char *hostInt = NULL;
net->type = VIR_DOMAIN_NET_TYPE_NETWORK; net->type = VIR_DOMAIN_NET_TYPE_NETWORK;
gVBoxAPI.UINetworkAdapter.GetHostOnlyInterface(adapter, &utf16); gVBoxAPI.UINetworkAdapter.GetHostOnlyInterface(adapter, &utf16);
VBOX_UTF16_TO_UTF8(utf16, &hostInt); VBOX_UTF16_TO_UTF8(utf16, &utf8);
ignore_value(VIR_STRDUP(net->data.network.name, hostInt)); ignore_value(VIR_STRDUP(net->data.network.name, utf8));
VBOX_UTF8_FREE(hostInt); VBOX_UTF8_FREE(utf8);
VBOX_UTF16_FREE(utf16); VBOX_UTF16_FREE(utf16);
} else { } else {
...@@ -3775,15 +3769,15 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter) ...@@ -3775,15 +3769,15 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter)
} }
gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &utf16); gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &utf16);
VBOX_UTF16_TO_UTF8(utf16, &MACAddress); VBOX_UTF16_TO_UTF8(utf16, &utf8);
VBOX_UTF16_FREE(utf16); VBOX_UTF16_FREE(utf16);
if (virMacAddrParseHex(MACAddress, &net->mac) < 0) { if (virMacAddrParseHex(utf8, &net->mac) < 0) {
VBOX_UTF8_FREE(MACAddress); VBOX_UTF8_FREE(utf8);
goto error; goto error;
} }
VBOX_UTF8_FREE(MACAddress); VBOX_UTF8_FREE(utf8);
return net; return net;
error: error:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册