[libvirt] [PATCH libvirt-python 07/17] Remove use of VIR_ALLOC_N

Eric Blake eblake at redhat.com
Mon Sep 9 17:23:48 UTC 2013


On 09/09/2013 10:01 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
>  libvirt-override.c | 106 ++++++++++++++++++++++++++---------------------------
>  1 file changed, 53 insertions(+), 53 deletions(-)

Do we really want to make this change?  It makes maintenance harder to
reason about.  I'd lean instead towards adding a single internal header,
where we #define VIR_ALLOC_N, so that existing code can continue to use
the nicer interface (where it's harder to typo the sizeof(*var)*len).
Furthermore, VIR_ALLOC_N has bounds checking (it ensures OOM failure if
sizeof()*len would overflow) that you are losing in your rewrite.

-- 
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/20130909/c9262a06/attachment-0001.sig>


More information about the libvir-list mailing list