Re: [PATCH 1/7] hellolibvirt: Resolve Coverity issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 11, 2013 at 08:34:01AM -0400, John Ferlan wrote:
> Recent changes uncovered a NEGATIVE_RETURNS when processing 'numNames'
> in 'showDomains' in the for loop after a possible -1 return.
> ---
>  examples/hellolibvirt/hellolibvirt.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/examples/hellolibvirt/hellolibvirt.c b/examples/hellolibvirt/hellolibvirt.c
> index 83045b1..2a48681 100644
> --- a/examples/hellolibvirt/hellolibvirt.c
> +++ b/examples/hellolibvirt/hellolibvirt.c
> @@ -90,6 +90,13 @@ showDomains(virConnectPtr conn)
>      numNames = virConnectListAllDomains(conn,
>                                          &nameList,
>                                          flags);
> +    if (numNames == -1) {
> +        ret = 1;
> +        printf ("Failed to get a list of all domains: %s\n",
> +                virGetLastErrorMessage());
> +        goto out;
> +    }
> +
>      for (i = 0; i < numNames; i++) {
>          int active = virDomainIsActive(nameList[i]);
>          printf("  %8s (%s)\n",

ACK


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]