On 05/13/2011 02:10 PM, Cole Robinson wrote:
> v2:
>     Simplify command building
>     Handle command building failure
> 
> Signed-off-by: Cole Robinson <[email protected]>
> ---
>  src/util/util.c |   74 ++++--------------------------------------------------
>  1 files changed, 6 insertions(+), 68 deletions(-)

fun 1:11 ratio

> +    int ret;
> +    virCommandPtr cmd = virCommandNewArgs(argv);
>  
> -    ret = 0;
> +    if (!cmd)
> +        return -1;

You should not add these two lines.  Why? Because you didn't report the
OOM error,

>  
> -  error:
> -    VIR_FREE(outbuf);
> -    VIR_FREE(errbuf);
> -    VIR_FORCE_CLOSE(outfd);
> -    VIR_FORCE_CLOSE(errfd);
> +    ret = virCommandRun(cmd, status);

but this safely handles NULL cmd on input and correctly reports the OOM
error.

ACK with that buglet fixed.

-- 
Eric Blake   [email protected]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to