[libvirt] [PATCH v2] Delete udevFreeIfaceDef function in udev interface driver
Eric Blake
eblake at redhat.com
Wed May 8 15:52:11 UTC 2013
On 05/08/2013 03:45 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
>
> The udevFreeIfaceDef function in the udev interface driver
> just duplicates code from virInterfaceDefFree. Delete it
> and call the standard API instead.
>
> Fix the udevGetIfaceDefVlan method so that it doesn't
> store pointers to the middle of a malloc'd memory
> area.
>
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
>
> /* Set the VLAN specifics */
> - ifacedef->data.vlan.tag = vid;
> - ifacedef->data.vlan.devname = vlan_parent_dev;
> + if (!(ifacedef->data.vlan.tag = strdup(vid + 1)))
> + goto no_memory;
VIR_STRDUP exists in the tree now, if you'd like to start using it
(instead of making Michal touch up yet another spot when he finally
turns on the syntax-check rule at the end of his series).
> + if (!(ifacedef->data.vlan.devname = strndup(name,
> + (vid - name))))
> + goto no_memory;
Same for VIR_STRNDUP.
>
> return 0;
>
> -cleanup:
> - VIR_FREE(vlan_parent_dev);
> +no_memory:
> + VIR_FREE(ifacedef->data.vlan.tag);
> + VIR_FREE(ifacedef->data.vlan.devname);
Also, by using VIR_STRDUP, I wouldn't have to call you on your missing
virReportOOMError() :)
ACK.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130508/86bf60fb/attachment-0001.sig>
More information about the libvir-list
mailing list