Re: [libvirt] [PATCH] qparams.c: do not skip va_end, twice

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

 



On Thu, Feb 18, 2010 at 08:29:38PM +0100, Jim Meyering wrote:
> More coverity-prompted fixes:
> 
> >From 56d339d99b09c5943fa36600ca39939080cc64f4 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering@xxxxxxxxxx>
> Date: Thu, 18 Feb 2010 20:27:22 +0100
> Subject: [PATCH] qparams.c: do not skip va_end, twice
> 
> * src/util/qparams.c (new_qparam_set, append_qparams): Do not skip
> va_end due to an early return.
> ---
>  src/util/qparams.c |   14 +++++++++-----
>  1 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/src/util/qparams.c b/src/util/qparams.c
> index 9535ca4..f6d0713 100644
> --- a/src/util/qparams.c
> +++ b/src/util/qparams.c
> @@ -1,6 +1,6 @@
> -/* Copyright (C) 2007, 2009 Red Hat, Inc.
> +/* Copyright (C) 2007, 2009-2010 Red Hat, Inc.
>   *
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
>   * License as published by the Free Software Foundation; either
>   * version 2.1 of the License, or (at your option) any later version.
> @@ -60,11 +60,12 @@ new_qparam_set (int init_alloc, ...)
>      while ((pname = va_arg (args, char *)) != NULL) {
>          pvalue = va_arg (args, char *);
> 
>          if (append_qparam (ps, pname, pvalue) == -1) {
>              free_qparam_set (ps);
> -            return NULL;
> +            ps = NULL;
> +            break;
>          }
>      }
>      va_end (args);
> 
>      return ps;
> @@ -73,21 +74,24 @@ new_qparam_set (int init_alloc, ...)
>  int
>  append_qparams (struct qparam_set *ps, ...)
>  {
>      va_list args;
>      const char *pname, *pvalue;
> +    int ret = 0;
> 
>      va_start (args, ps);
>      while ((pname = va_arg (args, char *)) != NULL) {
>          pvalue = va_arg (args, char *);
> 
> -        if (append_qparam (ps, pname, pvalue) == -1)
> -            return -1;
> +        if (append_qparam (ps, pname, pvalue) == -1) {
> +            ret = -1;
> +            break;
> +        }
>      }
>      va_end (args);
> 
> -    return 0;
> +    return ret;
>  }
> 
>  /* Ensure there is space to store at least one more parameter
>   * at the end of the set.
>   */

  ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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