Re: [PATCH 4/3] conf: Resolve Coverity NEGATIVE_RETURNS

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

 



On 05/18/2015 09:21 AM, John Ferlan wrote:
> Commit id '73eda710' added virDomainKeyWrapDefParseXML which uses
> virXPathNodeSet, but does not handle a -1 return thus causing a possible
> loop condition exit problem later when the return value is used.
>
> Change the logic to return the value from virXPathNodeSet if <= 0
>
> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
> ---
>  src/conf/domain_conf.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index e2b1194..a97e640 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -940,8 +940,8 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlXPathContextPtr ctxt)
>      xmlNodePtr *nodes = NULL;
>      int n;
>  
> -    if (!(n = virXPathNodeSet("./keywrap/cipher", ctxt, &nodes)))
> -        return 0;
> +    if ((n = virXPathNodeSet("./keywrap/cipher", ctxt, &nodes)) < 0)
> +        return n;

Seemed a bit strange at first (since the n == 0 case now continues
instead of returning immediately), but in the end it makes sense - if n
is 0, you end up allocating keywrap, never going through the loop, then
freeing keywrap and returning 0, to the result is the same as before.

ACK.

>  
>      if (VIR_ALLOC(def->keywrap) < 0)
>          goto cleanup;

--
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]