[libvirt] [PATCH 6/8] Resolve Coverity CHECKED_RETURN
Peter Krempa
pkrempa at redhat.com
Mon Sep 15 07:52:32 UTC 2014
On 09/13/14 15:27, John Ferlan wrote:
> Coverity complained that checking the return of virDomainCreate()
> was not consistent amongst the callers - so added the return check
> to the objecteventtest.c and adjust the virt-login-shell to compare
> < 0 rather than just non zero for the failure condition.
>
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
> tests/objecteventtest.c | 3 ++-
> tools/virt-login-shell.c | 2 +-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tests/objecteventtest.c b/tests/objecteventtest.c
> index 919f559..052dbe5 100644
> --- a/tests/objecteventtest.c
> +++ b/tests/objecteventtest.c
> @@ -359,7 +359,8 @@ testDomainStartStopEvent(const void *data)
>
> /* Test domain is started */
> virDomainDestroy(dom);
> - virDomainCreate(dom);
> + if (virDomainCreate(dom) < 0)
> + goto cleanup;
>
> if (virEventRunDefaultImpl() < 0)
> goto cleanup;
> diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c
> index be15a32..ceb271d 100644
> --- a/tools/virt-login-shell.c
> +++ b/tools/virt-login-shell.c
> @@ -275,7 +275,7 @@ main(int argc, char **argv)
> if (!dom)
> goto cleanup;
>
> - if (!virDomainIsActive(dom) && virDomainCreate(dom)) {
> + if (!virDomainIsActive(dom) && virDomainCreate(dom) < 0) {
This shouldn't be necessary, it returns only 0 or -1 although if it
shuts coverity up then it's fine with me.
> virErrorPtr last_error;
> last_error = virGetLastError();
> if (last_error->code != VIR_ERR_OPERATION_INVALID) {
>
ACK,
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140915/1db5b39c/attachment-0001.sig>
More information about the libvir-list
mailing list