Use the virMacAddrParse helper that does not require colon-separated values instead of using extra code to format it that way. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/vbox/vbox_common.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index c807d2965..3099e20c5 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3701,7 +3701,6 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter) PRUint32 adapterType = NetworkAdapterType_Null; PRUnichar *MACAddressUtf16 = NULL; char *MACAddress = NULL; - char macaddr[VIR_MAC_STRING_BUFLEN] = {0}; virDomainNetDefPtr net = NULL; if (VIR_ALLOC(net) < 0) @@ -3780,18 +3779,19 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter) gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &MACAddressUtf16); VBOX_UTF16_TO_UTF8(MACAddressUtf16, &MACAddress); - snprintf(macaddr, VIR_MAC_STRING_BUFLEN, - "%c%c:%c%c:%c%c:%c%c:%c%c:%c%c", - MACAddress[0], MACAddress[1], MACAddress[2], MACAddress[3], - MACAddress[4], MACAddress[5], MACAddress[6], MACAddress[7], - MACAddress[8], MACAddress[9], MACAddress[10], MACAddress[11]); + VBOX_UTF16_FREE(MACAddressUtf16); - /* XXX some real error handling here some day ... */ - ignore_value(virMacAddrParse(macaddr, &net->mac)); + if (virMacAddrParseHex(MACAddress, &net->mac) < 0) { + VBOX_UTF8_FREE(MACAddress); + goto error; + } - VBOX_UTF16_FREE(MACAddressUtf16); VBOX_UTF8_FREE(MACAddress); return net; + + error: + virDomainNetDefFree(net); + return NULL; } static int -- 2.13.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list