[libvirt] [PATCH 8/9] util: Implement virRun as a wrapper around virCommand
Eric Blake
eblake at redhat.com
Fri May 13 22:19:59 UTC 2011
On 05/13/2011 02:10 PM, Cole Robinson wrote:
> v2:
> Simplify command building
> Handle command building failure
>
> Signed-off-by: Cole Robinson <crobinso at redhat.com>
> ---
> 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 eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110513/22b03318/attachment-0001.sig>
More information about the libvir-list
mailing list