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

Re: [libvirt] [PATCH glib] Remove dead cleanup code in object fetch_list helpers



On 08/15/2013 08:41 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange redhat com>
> 
> The fetch_list helper cleanup code iterates over the
> elements in 'lst' array free'ing each one. This is dead
> code, however, since the only way to get there is from
> codepaths which do not populate 'lst' elements.
> 
> This fixes two coverity DEADCODE reports
> 
> Signed-off-by: Daniel P. Berrange <berrange redhat com>
> ---
>  libvirt-gobject/libvirt-gobject-connection.c   | 6 +-----
>  libvirt-gobject/libvirt-gobject-storage-pool.c | 6 +-----
>  2 files changed, 2 insertions(+), 10 deletions(-)
> 


This does fix the coverity error, but for both the "gint i;" is now
unnecessary resulting in:

libvirt-gobject-storage-pool.c:324:10: error: unused variable 'i'
[-Werror=unused-variable]
     gint i;
          ^

John
> diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
> index 5c8eb16..687a185 100644
> --- a/libvirt-gobject/libvirt-gobject-connection.c
> +++ b/libvirt-gobject/libvirt-gobject-connection.c
> @@ -719,11 +719,7 @@ static gchar ** fetch_list(virConnectPtr vconn,
>      return lst;
>  
>  error:
> -    if (lst != NULL) {
> -        for (i = 0 ; i < n; i++)
> -            g_free(lst[i]);
> -        g_free(lst);
> -    }
> +    g_free(lst);
>      return NULL;
>  }
>  
> diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
> index e02adc8..aa27872 100644
> --- a/libvirt-gobject/libvirt-gobject-storage-pool.c
> +++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
> @@ -347,11 +347,7 @@ static gchar ** fetch_list(virStoragePoolPtr vpool,
>      return lst;
>  
>  error:
> -    if (lst != NULL) {
> -        for (i = 0 ; i < n; i++)
> -            g_free(lst[i]);
> -        g_free(lst);
> -    }
> +    g_free(lst);
>      return NULL;
>  }
>  
> 


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