[virt-tools-list] [PATCH 13/47] Remove unused error variable from db populate list iterator

Daniel P. Berrange berrange at redhat.com
Wed Aug 25 19:37:08 UTC 2010


The GError object passed around when getting lists of OS,
or Hypervisor objects from the DB, is never actually set,
nor can failure ever occur in any of the codepaths.
Since it is unused, it can be removed completely.

* osinfo/osinfo_common.h: Remove errcode & err from
  struct __osinfoPopulateListArgs.
* osinfo/osinfo_db.c: Don't pass around GError object
  when populating entity lists
---
 osinfo/osinfo_common.h |    2 --
 osinfo/osinfo_db.c     |   37 +++++--------------------------------
 2 files changed, 5 insertions(+), 34 deletions(-)

diff --git a/osinfo/osinfo_common.h b/osinfo/osinfo_common.h
index 386446d..8c4b6c6 100644
--- a/osinfo/osinfo_common.h
+++ b/osinfo/osinfo_common.h
@@ -67,8 +67,6 @@ struct __osinfoPtrArrayErr {
 };
 
 struct __osinfoPopulateListArgs {
-    GError **err;
-    int errcode;
     OsinfoFilter *filter;
     OsinfoList *list;
 };
diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
index f3ebc4c..4b464c7 100644
--- a/osinfo/osinfo_db.c
+++ b/osinfo/osinfo_db.c
@@ -235,7 +235,6 @@ static gboolean __osinfoFilteredAddToList(gpointer key, gpointer value, gpointer
     args = (struct __osinfoPopulateListArgs *) data;
     OsinfoFilter *filter = args->filter;
     OsinfoList *list = args->list;
-    GError **err = args->err;
 
     // Key is string ID, value is pointer to entity
     OsinfoEntity *entity = (OsinfoEntity *) value;
@@ -243,16 +242,13 @@ static gboolean __osinfoFilteredAddToList(gpointer key, gpointer value, gpointer
         osinfo_list_add(list, entity);
     }
 
-    args->errcode = 0;
-
     return FALSE; // continue iteration
 }
 
-static int __osinfoPopulateList(GTree *entities, OsinfoList *newList, OsinfoFilter *filter, GError **err)
+static void osinfo_db_populate_list(GTree *entities, OsinfoList *newList, OsinfoFilter *filter)
 {
-    struct __osinfoPopulateListArgs args = {err, 0, filter, newList};
+    struct __osinfoPopulateListArgs args = { filter, newList};
     g_tree_foreach(entities, __osinfoFilteredAddToList, &args);
-    return args.errcode;
 }
 
 OsinfoOsList *osinfo_db_get_os_list(OsinfoDb *self, OsinfoFilter *filter, GError **err)
@@ -272,14 +268,7 @@ OsinfoOsList *osinfo_db_get_os_list(OsinfoDb *self, OsinfoFilter *filter, GError
 
     // Create list
     OsinfoOsList *newList = g_object_new(OSINFO_TYPE_OSLIST, NULL);
-    int ret;
-    ret = __osinfoPopulateList(self->priv->oses, OSINFO_LIST (newList), filter, err);
-    if (ret != 0) {
-        g_object_unref(newList);
-        g_set_error_literal(err, g_quark_from_static_string("libosinfo"), ret, __osinfoErrorToString(ret));
-        return NULL;
-    }
-
+    osinfo_db_populate_list(self->priv->oses, OSINFO_LIST (newList), filter);
     return newList;
 }
 
@@ -297,15 +286,7 @@ OsinfoHypervisorList *osinfo_db_get_hypervisor_list(OsinfoDb *self, OsinfoFilter
 
     // Create list
     OsinfoHypervisorList *newList = g_object_new(OSINFO_TYPE_HYPERVISORLIST, NULL);
-
-    int ret;
-    ret = __osinfoPopulateList(self->priv->hypervisors, OSINFO_LIST (newList), filter, err);
-    if (ret != 0) {
-        g_object_unref(newList);
-        g_set_error_literal(err, g_quark_from_static_string("libosinfo"), ret, __osinfoErrorToString(ret));
-        return NULL;
-    }
-
+    osinfo_db_populate_list(self->priv->hypervisors, OSINFO_LIST (newList), filter);
     return newList;
 }
 
@@ -323,15 +304,7 @@ OsinfoDeviceList *osinfo_db_get_device_list(OsinfoDb *self, OsinfoFilter *filter
 
     // Create list
     OsinfoDeviceList *newList = g_object_new(OSINFO_TYPE_DEVICELIST, NULL);
-
-    int ret;
-    ret = __osinfoPopulateList(self->priv->devices, OSINFO_LIST (newList), filter, err);
-    if (ret != 0) {
-        g_object_unref(newList);
-        g_set_error_literal(err, g_quark_from_static_string("libosinfo"), ret, __osinfoErrorToString(ret));
-        return NULL;
-    }
-
+    osinfo_db_populate_list(self->priv->devices, OSINFO_LIST (newList), filter);
     return newList;
 }
 
-- 
1.7.2.1




More information about the virt-tools-list mailing list