From: Stefan Berger Date: Wed, 25 Apr 2012 11:55:07 +0000 (-0400) Subject: macvtap: use embedded buffers X-Git-Tag: v0.9.12-rc1~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f86880082ddf6a96a76c0078cc156891b9819390;p=thirdparty%2Flibvirt.git macvtap: use embedded buffers Use embedded buffers for the MAC addresses and the VM's UUID. --- diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index 879d846e85..a5a5f03bc6 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -435,10 +435,10 @@ static const uint32_t modeMap[VIR_NETDEV_MACVLAN_MODE_LAST] = { struct virNetlinkCallbackData { char *cr_ifname; virNetDevVPortProfilePtr virtPortProfile; - unsigned char *macaddress; + unsigned char macaddress[VIR_UUID_BUFLEN]; char *linkdev; int vf; - unsigned char *vmuuid; + unsigned char vmuuid[VIR_UUID_BUFLEN]; enum virNetDevVPortProfileOp vmOp; unsigned int linkState; }; @@ -728,9 +728,7 @@ virNetlinkCallbackDataFree(virNetlinkCallbackDataPtr calld) if (calld) { VIR_FREE(calld->cr_ifname); VIR_FREE(calld->virtPortProfile); - VIR_FREE(calld->macaddress); VIR_FREE(calld->linkdev); - VIR_FREE(calld->vmuuid); } VIR_FREE(calld); } @@ -772,14 +770,10 @@ virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname, if (VIR_ALLOC(calld->virtPortProfile) < 0) goto memory_error; memcpy(calld->virtPortProfile, virtPortProfile, sizeof(*virtPortProfile)); - if (VIR_ALLOC_N(calld->macaddress, VIR_MAC_BUFLEN) < 0) - goto memory_error; - memcpy(calld->macaddress, macaddress, VIR_MAC_BUFLEN); + memcpy(calld->macaddress, macaddress, sizeof(calld->macaddress)); if ((calld->linkdev = strdup(linkdev)) == NULL) goto memory_error; - if (VIR_ALLOC_N(calld->vmuuid, VIR_UUID_BUFLEN) < 0) - goto memory_error; - memcpy(calld->vmuuid, vmuuid, VIR_UUID_BUFLEN); + memcpy(calld->vmuuid, vmuuid, sizeof(calld->vmuuid)); calld->vmOp = vmOp;