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

Re: [libvirt] [PATCH] storage_driver.c: remove two useless calls to virStorageBackendForType



On Fri, Sep 04, 2009 at 05:19:21PM +0200, Jim Meyering wrote:
> >From dead-store warnings:
> 
> >From c925b02828083a016f7b9a7ae93eb3a7bf5f4609 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering redhat com>
> Date: Fri, 4 Sep 2009 17:18:29 +0200
> Subject: [PATCH] storage_driver.c: remove two useless calls to virStorageBackendForType
> 
> * src/storage_driver.c (storagePoolGetInfo, storagePoolDefine):
> The result was never used, and the function has no side effects.
> ---
>  src/storage_driver.c |    8 --------
>  1 files changed, 0 insertions(+), 8 deletions(-)
> 
> diff --git a/src/storage_driver.c b/src/storage_driver.c
> index e9ecb20..e8d43b7 100644
> --- a/src/storage_driver.c
> +++ b/src/storage_driver.c
> @@ -519,15 +519,11 @@ storagePoolDefine(virConnectPtr conn,
>      virStoragePoolDefPtr def;
>      virStoragePoolObjPtr pool = NULL;
>      virStoragePoolPtr ret = NULL;
> -    virStorageBackendPtr backend;
> 
>      storageDriverLock(driver);
>      if (!(def = virStoragePoolDefParseString(conn, xml)))
>          goto cleanup;
> 
> -    if ((backend = virStorageBackendForType(def->type)) == NULL)
> -        goto cleanup;
> -
>      if (!(pool = virStoragePoolObjAssignDef(conn, &driver->pools, def)))
>          goto cleanup;
> 
> @@ -847,7 +843,6 @@ storagePoolGetInfo(virStoragePoolPtr obj,
>                     virStoragePoolInfoPtr info) {
>      virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
>      virStoragePoolObjPtr pool;
> -    virStorageBackendPtr backend;
>      int ret = -1;
> 
>      storageDriverLock(driver);
> @@ -860,9 +855,6 @@ storagePoolGetInfo(virStoragePoolPtr obj,
>          goto cleanup;
>      }
> 
> -    if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
> -        goto cleanup;
> -
>      memset(info, 0, sizeof(virStoragePoolInfo));
>      if (pool->active)
>          info->state = VIR_STORAGE_POOL_RUNNING;

  Hum ... I'm afraid it changes the semantic. If
  virStorageBackendForType fails because def->type is not one of the
  registered type for storage backend.

It seems that def->type is assigned in virStoragePoolDefParseXML() with

   if ((ret->type = virStoragePoolTypeFromString((const char *)type)) <
   0) {

so there we check that the type matches a StoragePoolType but a storage
backend type might be a subset.

  To be safe I would just remove the variable but keep

    if ((virStorageBackendForType(pool->def->type)) == NULL)
        goto cleanup;

checks and exits. Then we are sure to keep the semantic.

Daniel

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


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