[virt-tools-list] [libosinfo 2/4] Use new osinfo_list_new_* helpers everywhere
Christophe Fergeau
cfergeau at redhat.com
Fri Dec 7 09:35:00 UTC 2012
We need to do that before deprecating all the derived class
implementations of osinfo_xxxlist_new_*.
---
osinfo/osinfo_db.c | 25 ++++++++++++++++++++-----
osinfo/osinfo_os.c | 11 ++++++++---
test/test-devicelist.c | 6 +++---
test/test-oslist.c | 6 +++---
test/test-platformlist.c | 6 +++---
test/test-product.c | 8 ++++----
tools/osinfo-install-script.c | 8 ++++----
7 files changed, 45 insertions(+), 25 deletions(-)
diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
index 935e299..c17c512 100644
--- a/osinfo/osinfo_db.c
+++ b/osinfo/osinfo_db.c
@@ -238,9 +238,12 @@ OsinfoDeployment *osinfo_db_find_deployment(OsinfoDb *db,
*/
OsinfoOsList *osinfo_db_get_os_list(OsinfoDb *db)
{
+ OsinfoList *new_list;
+
g_return_val_if_fail(OSINFO_IS_DB(db), NULL);
+ new_list = osinfo_list_new_copy(OSINFO_LIST(db->priv->oses));
- return osinfo_oslist_new_copy(db->priv->oses);
+ return OSINFO_OSLIST(new_list);
}
/**
@@ -251,9 +254,12 @@ OsinfoOsList *osinfo_db_get_os_list(OsinfoDb *db)
*/
OsinfoPlatformList *osinfo_db_get_platform_list(OsinfoDb *db)
{
+ OsinfoList *new_list;
+
g_return_val_if_fail(OSINFO_IS_DB(db), NULL);
+ new_list = osinfo_list_new_copy(OSINFO_LIST(db->priv->platforms));
- return osinfo_platformlist_new_copy(db->priv->platforms);
+ return OSINFO_PLATFORMLIST(new_list);
}
/**
@@ -264,9 +270,12 @@ OsinfoPlatformList *osinfo_db_get_platform_list(OsinfoDb *db)
*/
OsinfoDeviceList *osinfo_db_get_device_list(OsinfoDb *db)
{
+ OsinfoList *new_list;
+
g_return_val_if_fail(OSINFO_IS_DB(db), NULL);
+ new_list = osinfo_list_new_copy(OSINFO_LIST(db->priv->devices));
- return osinfo_devicelist_new_copy(db->priv->devices);
+ return OSINFO_DEVICELIST(new_list);
}
@@ -278,9 +287,12 @@ OsinfoDeviceList *osinfo_db_get_device_list(OsinfoDb *db)
*/
OsinfoDeploymentList *osinfo_db_get_deployment_list(OsinfoDb *db)
{
+ OsinfoList *new_list;
+
g_return_val_if_fail(OSINFO_IS_DB(db), NULL);
+ new_list = osinfo_list_new_copy(OSINFO_LIST(db->priv->deployments));
- return osinfo_deploymentlist_new_copy(db->priv->deployments);
+ return OSINFO_DEPLOYMENTLIST(new_list);
}
@@ -292,9 +304,12 @@ OsinfoDeploymentList *osinfo_db_get_deployment_list(OsinfoDb *db)
*/
OsinfoInstallScriptList *osinfo_db_get_install_script_list(OsinfoDb *db)
{
+ OsinfoList *new_list;
+
g_return_val_if_fail(OSINFO_IS_DB(db), NULL);
+ new_list = osinfo_list_new_copy(OSINFO_LIST(db->priv->scripts));
- return osinfo_install_scriptlist_new_copy(db->priv->scripts);
+ return OSINFO_INSTALL_SCRIPTLIST(new_list);
}
diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c
index b91c4d9..92b0549 100644
--- a/osinfo/osinfo_os.c
+++ b/osinfo/osinfo_os.c
@@ -256,7 +256,8 @@ OsinfoDeviceList *osinfo_os_get_all_devices(OsinfoOs *os, OsinfoFilter *filter)
(OSINFO_PRODUCT(os), OSINFO_PRODUCT_RELATIONSHIP_DERIVES_FROM);
cloned = osinfo_product_get_related(OSINFO_PRODUCT(os),
OSINFO_PRODUCT_RELATIONSHIP_CLONES);
- related_list = osinfo_productlist_new_union(derived, cloned);
+ related_list = OSINFO_PRODUCTLIST(osinfo_list_new_union(OSINFO_LIST(derived),
+ OSINFO_LIST(cloned)));
g_object_unref(derived);
g_object_unref(cloned);
@@ -268,7 +269,8 @@ OsinfoDeviceList *osinfo_os_get_all_devices(OsinfoOs *os, OsinfoFilter *filter)
related_devices = osinfo_os_get_all_devices(OSINFO_OS(related), filter);
if (osinfo_list_get_length(OSINFO_LIST(related_devices)) > 0) {
OsinfoDeviceList *tmp_list = devices;
- devices = osinfo_devicelist_new_union(devices, related_devices);
+ devices = OSINFO_DEVICELIST(osinfo_list_new_union(OSINFO_LIST(devices),
+ OSINFO_LIST(related_devices)));
g_object_unref(tmp_list);
}
}
@@ -564,9 +566,12 @@ OsinfoInstallScript *osinfo_os_find_install_script(OsinfoOs *os, const gchar *pr
*/
OsinfoInstallScriptList *osinfo_os_get_install_script_list(OsinfoOs *os)
{
+ OsinfoList *new_list;
+
g_return_val_if_fail(OSINFO_IS_OS(os), NULL);
+ new_list = osinfo_list_new_copy(OSINFO_LIST(os->priv->scripts));
- return osinfo_install_scriptlist_new_copy(os->priv->scripts);
+ return OSINFO_INSTALL_SCRIPTLIST(new_list);
}
diff --git a/test/test-devicelist.c b/test/test-devicelist.c
index 31059df..1fd001a 100644
--- a/test/test-devicelist.c
+++ b/test/test-devicelist.c
@@ -43,7 +43,7 @@ START_TEST(test_union)
osinfo_list_add(OSINFO_LIST(list2), OSINFO_ENTITY(ent1));
osinfo_list_add(OSINFO_LIST(list2), OSINFO_ENTITY(ent4));
- list3 = osinfo_devicelist_new_union(list1, list2);
+ list3 = OSINFO_DEVICELIST(osinfo_list_new_union(OSINFO_LIST(list1), OSINFO_LIST(list2)));
fail_unless(osinfo_list_get_length(OSINFO_LIST(list3)) == 4, "List did not have 4 elements");
@@ -102,7 +102,7 @@ START_TEST(test_intersect)
osinfo_list_add(OSINFO_LIST(list2), OSINFO_ENTITY(ent3));
osinfo_list_add(OSINFO_LIST(list2), OSINFO_ENTITY(ent4));
- list3 = osinfo_devicelist_new_intersection(list1, list2);
+ list3 = OSINFO_DEVICELIST(osinfo_list_new_intersection(OSINFO_LIST(list1), OSINFO_LIST(list2)));
fail_unless(osinfo_list_get_length(OSINFO_LIST(list3)) == 2, "List did not have 2 elements");
@@ -166,7 +166,7 @@ START_TEST(test_filter)
osinfo_list_add(OSINFO_LIST(list1), OSINFO_ENTITY(ent3));
osinfo_list_add(OSINFO_LIST(list1), OSINFO_ENTITY(ent4));
- list2 = osinfo_devicelist_new_filtered(list1, filter);
+ list2 = OSINFO_DEVICELIST(osinfo_list_new_filtered(OSINFO_LIST(list1), filter));
fail_unless(osinfo_list_get_length(OSINFO_LIST(list2)) == 3, "List did not have 3 elements");
diff --git a/test/test-oslist.c b/test/test-oslist.c
index d63bb91..c3d114c 100644
--- a/test/test-oslist.c
+++ b/test/test-oslist.c
@@ -43,7 +43,7 @@ START_TEST(test_union)
osinfo_list_add(OSINFO_LIST(list2), OSINFO_ENTITY(ent1));
osinfo_list_add(OSINFO_LIST(list2), OSINFO_ENTITY(ent4));
- list3 = osinfo_oslist_new_union(list1, list2);
+ list3 = OSINFO_OSLIST(osinfo_list_new_union(OSINFO_LIST(list1), OSINFO_LIST(list2)));
fail_unless(osinfo_list_get_length(OSINFO_LIST(list3)) == 4, "List did not have 4 elements");
@@ -102,7 +102,7 @@ START_TEST(test_intersect)
osinfo_list_add(OSINFO_LIST(list2), OSINFO_ENTITY(ent3));
osinfo_list_add(OSINFO_LIST(list2), OSINFO_ENTITY(ent4));
- list3 = osinfo_oslist_new_intersection(list1, list2);
+ list3 = OSINFO_OSLIST(osinfo_list_new_intersection(OSINFO_LIST(list1), OSINFO_LIST(list2)));
fail_unless(osinfo_list_get_length(OSINFO_LIST(list3)) == 2, "List did not have 2 elements");
@@ -166,7 +166,7 @@ START_TEST(test_filter)
osinfo_list_add(OSINFO_LIST(list1), OSINFO_ENTITY(ent3));
osinfo_list_add(OSINFO_LIST(list1), OSINFO_ENTITY(ent4));
- list2 = osinfo_oslist_new_filtered(list1, filter);
+ list2 = OSINFO_OSLIST(osinfo_list_new_filtered(OSINFO_LIST(list1), filter));
fail_unless(osinfo_list_get_length(OSINFO_LIST(list2)) == 3, "List did not have 3 elements");
diff --git a/test/test-platformlist.c b/test/test-platformlist.c
index e6b6ce3..d191480 100644
--- a/test/test-platformlist.c
+++ b/test/test-platformlist.c
@@ -43,7 +43,7 @@ START_TEST(test_union)
osinfo_list_add(OSINFO_LIST(list2), OSINFO_ENTITY(ent1));
osinfo_list_add(OSINFO_LIST(list2), OSINFO_ENTITY(ent4));
- list3 = osinfo_platformlist_new_union(list1, list2);
+ list3 = OSINFO_PLATFORMLIST(osinfo_list_new_union(OSINFO_LIST(list1), OSINFO_LIST(list2)));
fail_unless(osinfo_list_get_length(OSINFO_LIST(list3)) == 4, "List did not have 4 elements");
@@ -102,7 +102,7 @@ START_TEST(test_intersect)
osinfo_list_add(OSINFO_LIST(list2), OSINFO_ENTITY(ent3));
osinfo_list_add(OSINFO_LIST(list2), OSINFO_ENTITY(ent4));
- list3 = osinfo_platformlist_new_intersection(list1, list2);
+ list3 = OSINFO_PLATFORMLIST(osinfo_list_new_intersection(OSINFO_LIST(list1), OSINFO_LIST(list2)));
fail_unless(osinfo_list_get_length(OSINFO_LIST(list3)) == 2, "List did not have 2 elements");
@@ -166,7 +166,7 @@ START_TEST(test_filter)
osinfo_list_add(OSINFO_LIST(list1), OSINFO_ENTITY(ent3));
osinfo_list_add(OSINFO_LIST(list1), OSINFO_ENTITY(ent4));
- list2 = osinfo_platformlist_new_filtered(list1, filter);
+ list2 = OSINFO_PLATFORMLIST(osinfo_list_new_filtered(OSINFO_LIST(list1), filter));
fail_unless(osinfo_list_get_length(OSINFO_LIST(list2)) == 3, "List did not have 3 elements");
diff --git a/test/test-product.c b/test/test-product.c
index 5d64795..412b6e1 100644
--- a/test/test-product.c
+++ b/test/test-product.c
@@ -137,7 +137,7 @@ START_TEST(test_supportdate)
/* Product 1 & 3 */
date = g_date_new_dmy(31, 12, 1999);
osinfo_productfilter_add_support_date_constraint(filter, date);
- tmp = osinfo_productlist_new_filtered(products, OSINFO_FILTER(filter));
+ tmp = OSINFO_PRODUCTLIST(osinfo_list_new_filtered(OSINFO_LIST(products), OSINFO_FILTER(filter)));
fail_unless(osinfo_list_get_length(OSINFO_LIST(tmp)) == 2, "2 products");
fail_unless(osinfo_list_get_nth(OSINFO_LIST(tmp), 0) == (OsinfoEntity*)product1, "Got product 1");
fail_unless(osinfo_list_get_nth(OSINFO_LIST(tmp), 1) == (OsinfoEntity*)product3, "Got product 3");
@@ -147,7 +147,7 @@ START_TEST(test_supportdate)
/* Product 1, 2 & 3 */
date = g_date_new_dmy(01, 01, 2000);
osinfo_productfilter_add_support_date_constraint(filter, date);
- tmp = osinfo_productlist_new_filtered(products, OSINFO_FILTER(filter));
+ tmp = OSINFO_PRODUCTLIST(osinfo_list_new_filtered(OSINFO_LIST(products), OSINFO_FILTER(filter)));
fail_unless(osinfo_list_get_length(OSINFO_LIST(tmp)) == 3, "3 products");
fail_unless(osinfo_list_get_nth(OSINFO_LIST(tmp), 0) == (OsinfoEntity*)product1, "Got product 1");
fail_unless(osinfo_list_get_nth(OSINFO_LIST(tmp), 1) == (OsinfoEntity*)product2, "Got product 2");
@@ -158,7 +158,7 @@ START_TEST(test_supportdate)
/* Product 1, 2 & 3 */
date = g_date_new_dmy(01, 01, 2010);
osinfo_productfilter_add_support_date_constraint(filter, date);
- tmp = osinfo_productlist_new_filtered(products, OSINFO_FILTER(filter));
+ tmp = OSINFO_PRODUCTLIST(osinfo_list_new_filtered(OSINFO_LIST(products), OSINFO_FILTER(filter)));
fail_unless(osinfo_list_get_length(OSINFO_LIST(tmp)) == 3, "3 products");
fail_unless(osinfo_list_get_nth(OSINFO_LIST(tmp), 0) == (OsinfoEntity*)product1, "Got product 1");
fail_unless(osinfo_list_get_nth(OSINFO_LIST(tmp), 1) == (OsinfoEntity*)product2, "Got product 2");
@@ -169,7 +169,7 @@ START_TEST(test_supportdate)
/* Product 1, 2 & 3 */
date = g_date_new_dmy(01, 05, 2005);
osinfo_productfilter_add_support_date_constraint(filter, date);
- tmp = osinfo_productlist_new_filtered(products, OSINFO_FILTER(filter));
+ tmp = OSINFO_PRODUCTLIST(osinfo_list_new_filtered(OSINFO_LIST(products), OSINFO_FILTER(filter)));
fail_unless(osinfo_list_get_length(OSINFO_LIST(tmp)) == 4, "4 products");
fail_unless(osinfo_list_get_nth(OSINFO_LIST(tmp), 0) == (OsinfoEntity*)product1, "Got product 1");
fail_unless(osinfo_list_get_nth(OSINFO_LIST(tmp), 1) == (OsinfoEntity*)product2, "Got product 2");
diff --git a/tools/osinfo-install-script.c b/tools/osinfo-install-script.c
index adb0660..5a766ba 100644
--- a/tools/osinfo-install-script.c
+++ b/tools/osinfo-install-script.c
@@ -94,8 +94,8 @@ static OsinfoOs *find_os(OsinfoDb *db,
OSINFO_PRODUCT_PROP_SHORT_ID,
idoruri);
- filteredList = osinfo_oslist_new_filtered(oslist,
- filter);
+ filteredList = OSINFO_OSLIST(osinfo_list_new_filtered(OSINFO_LIST(oslist),
+ filter));
if (osinfo_list_get_length(OSINFO_LIST(filteredList)) > 0)
os = OSINFO_OS(osinfo_list_get_nth(OSINFO_LIST(filteredList), 0));
@@ -122,8 +122,8 @@ static gboolean generate_script(OsinfoOs *os)
OSINFO_INSTALL_SCRIPT_PROP_PROFILE,
profile ? profile :
OSINFO_INSTALL_SCRIPT_PROFILE_JEOS);
- profile_scripts = osinfo_install_scriptlist_new_filtered(scripts,
- filter);
+ profile_scripts = OSINFO_INSTALL_SCRIPTLIST(osinfo_list_new_filtered(OSINFO_LIST(scripts),
+ filter));
l = osinfo_list_get_elements(OSINFO_LIST(profile_scripts));
for (tmp = l; tmp != NULL; tmp = tmp->next) {
OsinfoInstallScript *script = tmp->data;
--
1.8.0.1
More information about the virt-tools-list
mailing list