]> xenbits.xensource.com Git - libvirt.git/commit
command: improve behavior on no output
authorEric Blake <eblake@redhat.com>
Fri, 3 Dec 2010 21:14:16 +0000 (14:14 -0700)
committerEric Blake <eblake@redhat.com>
Tue, 7 Dec 2010 22:35:30 +0000 (15:35 -0700)
commitcc5e2a849c853d172a067b12fabfbc6696f9bd08
tree066f92df8da52044061e3bdd48a9e6c6e39b0023
parentee11729d7f06197fd9770b3389118e2772b515a8
command: improve behavior on no output

Guarantee that outbuf/errbuf are allocated on success, even if to the
empty string.  Caller always has to free the result, and empty output
check requires checking if *outbuf=='\0'.  Makes the API easier to use
safely.  Failure is best effort allocation (some paths, like
out-of-memory, cannot allocate a buffer, but most do), so caller must
free buffer on failure.

* docs/internals/command.html.in: Update documentation.
* src/util/command.c (virCommandSetOutputBuffer)
(virCommandSetErrorBuffer, virCommandProcessIO) Guarantee empty
string on no output.
* tests/commandtest.c (test17): New test.
docs/internals/command.html.in
src/util/command.c
tests/commandtest.c