On 05/13/2011 02:10 PM, Cole Robinson wrote:
v2:
Simplify command building
Handle command building failure
Signed-off-by: Cole Robinson <crobinso(a)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(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org