Re: [PATCH] Detect heap allocation failure; factor out some duplication.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daniel P. Berrange wrote:
On Wed, Nov 28, 2007 at 02:18:22PM +0100, Jim Meyering wrote:
I spotted a few unchecked heap allocations (strdup, malloc, calloc)
in qemud.c and have fixed it so such failure evokes a proper diagnostic
rather than e.g., a segfault.

Yep, good stuff.

I've also arranged to free some of the memory upon failure,
but not all (see comments for why).

In spite of those additions, this patch factors out enough
duplication that the net change is to remove a few lines from the
file.  Although in general I prefer to factor things out into
separate functions, in this case, it seemed better to use macros.

I really don't like the macros, particularly when the macro definitions
are inline to the function. I'd prefer to see these helpers as separate
functions. The compiler is perfectly able to decide whether to inline the code or not & it makes it more friendly to edit & read when it is using separate functions.

The macros were my doing ... I'll leave it up to Jim's judgement as to whether he wants to refactor them out into functions.

Rich.

--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]