[libvirt] [PATCH 3/4] VIR_FREE: Avoid doing side work in callees

Ján Tomko jtomko at redhat.com
Tue Jul 15 12:58:59 UTC 2014


On 07/15/2014 02:38 PM, Michal Privoznik wrote:
> There are just two places where we rely on the fact that VIR_FREE()
> macro is without any side effects. In the future, this property of the
> macro is going to change, so we need the code to be adjusted to deal
> with argument passed to VIR_FREE() being evaluated multiple times.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/conf/network_conf.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)

NACK, this completely removes the side effect. You need to adjust the callers
for that.

IMO we should set n<elems> to 0 in all *Clear functions, not just
virNetworkDNSHostDefClear, after which NULL might be dereferenced based on the
n<elems> variable.

Jan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140715/91a1c013/attachment-0001.sig>


More information about the libvir-list mailing list