[libosinfo PATCH v2 02/15] devicelinklist: Fix _get_devices()

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

 



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 <fidencio@xxxxxxxxxx>
---
 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
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux