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

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

 



On 08/15/2013 08:41 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>
> ---
>  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;
>  }
>  
> 

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