osinfo_devicelinklist_get_devices() returns a list of OsinfoDevice
structs and in order to do so it has to iterate over the list of
OsinfoDeviceLink structs and get the device associated to each of the
OsinfoDeviceLink struct.

The current implementation was just trying to add the OsinfoDeviceLink
struct to the list, instead of getting the devices associated to it.

https://gitlab.com/libosinfo/osinfo-db/issues/13

Signed-off-by: Fabiano Fidêncio <[email protected]>
---
 osinfo/osinfo_devicelinklist.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/osinfo/osinfo_devicelinklist.c b/osinfo/osinfo_devicelinklist.c
index 8e72119..ccd7d11 100644
--- a/osinfo/osinfo_devicelinklist.c
+++ b/osinfo/osinfo_devicelinklist.c
@@ -180,8 +180,10 @@ OsinfoDeviceList 
*osinfo_devicelinklist_get_devices(OsinfoDeviceLinkList *list,
     int i;
     for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(list)); i++) {
         OsinfoEntity *ent = osinfo_list_get_nth(OSINFO_LIST(list), i);
-        if (!filter || osinfo_filter_matches(filter, ent))
-            osinfo_list_add(OSINFO_LIST(newList), ent);
+        if (!filter || osinfo_filter_matches(filter, ent)) {
+            OsinfoDevice *dev = 
osinfo_devicelink_get_target(OSINFO_DEVICELINK(ent));
+            osinfo_list_add(OSINFO_LIST(newList), OSINFO_ENTITY(dev));
+        }
     }
     return newList;
 }
-- 
2.19.1

_______________________________________________
Libosinfo mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libosinfo

Reply via email to