177 lines
5.2 KiB
Diff
177 lines
5.2 KiB
Diff
From b6bfcce0340b2c602b42df8fceff68be83db3fe9 Mon Sep 17 00:00:00 2001
|
|
From: Laszlo Ersek <lersek@redhat.com>
|
|
Date: Tue, 1 Feb 2022 13:32:15 +0100
|
|
Subject: [PATCH] convert/libosinfo: factor out
|
|
v2v_osinfo_device_list_to_value_list()
|
|
|
|
Move the guts of v2v_osinfo_os_get_all_devices() to a new static function
|
|
called v2v_osinfo_device_list_to_value_list().
|
|
|
|
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2043333
|
|
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
Acked-by: Richard W.M. Jones <rjones@redhat.com>
|
|
Message-Id: <20220201123219.9317-4-lersek@redhat.com>
|
|
(cherry picked from commit 9045c87d3a6f43a4063f6b52d05c6dcf7e051319)
|
|
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
---
|
|
convert/libosinfo-c.c | 126 +++++++++++++++++++++++-------------------
|
|
1 file changed, 68 insertions(+), 58 deletions(-)
|
|
|
|
diff --git a/convert/libosinfo-c.c b/convert/libosinfo-c.c
|
|
index ec7c06d3..bc5816f6 100644
|
|
--- a/convert/libosinfo-c.c
|
|
+++ b/convert/libosinfo-c.c
|
|
@@ -210,59 +210,6 @@ glist_to_value_list (GList *list)
|
|
CAMLreturn (rv);
|
|
}
|
|
|
|
-value
|
|
-v2v_osinfo_os_get_device_drivers (value osv)
|
|
-{
|
|
- CAMLparam1 (osv);
|
|
- CAMLlocal4 (rv, v, vi, copyv);
|
|
- OsinfoDeviceDriverList *list;
|
|
- gint i, len;
|
|
-
|
|
- list = osinfo_os_get_device_drivers (OsinfoOs_t_val (osv));
|
|
- len = osinfo_list_get_length (OSINFO_LIST(list));
|
|
-
|
|
- rv = Val_emptylist;
|
|
- for (i = len - 1; i >= 0; --i) {
|
|
- OsinfoDeviceDriver *driver;
|
|
- const gchar *str;
|
|
- gboolean b;
|
|
- GList *l;
|
|
- gint64 i64;
|
|
-
|
|
- driver = OSINFO_DEVICE_DRIVER(osinfo_list_get_nth (OSINFO_LIST(list), i));
|
|
-
|
|
- vi = caml_alloc (6, 0);
|
|
- str = osinfo_device_driver_get_architecture (driver);
|
|
- copyv = caml_copy_string (str);
|
|
- Store_field (vi, 0, copyv);
|
|
- str = osinfo_device_driver_get_location (driver);
|
|
- copyv = caml_copy_string (str);
|
|
- Store_field (vi, 1, copyv);
|
|
- b = osinfo_device_driver_get_pre_installable (driver);
|
|
- Store_field (vi, 2, Val_bool (b));
|
|
- b = osinfo_device_driver_get_signed (driver);
|
|
- Store_field (vi, 3, Val_bool (b));
|
|
-#if IS_LIBOSINFO_VERSION(1, 7, 0)
|
|
- i64 = osinfo_device_driver_get_priority (driver);
|
|
-#else
|
|
- /* Same as OSINFO_DEVICE_DRIVER_DEFAULT_PRIORITY in libosinfo 1.7.0+. */
|
|
- i64 = 50;
|
|
-#endif
|
|
- copyv = caml_copy_int64 (i64);
|
|
- Store_field (vi, 4, copyv);
|
|
- l = osinfo_device_driver_get_files (driver);
|
|
- Store_field (vi, 5, glist_to_value_list (l));
|
|
- g_list_free (l);
|
|
-
|
|
- v = caml_alloc (2, 0);
|
|
- Store_field (v, 0, vi);
|
|
- Store_field (v, 1, rv);
|
|
- rv = v;
|
|
- }
|
|
-
|
|
- CAMLreturn (rv);
|
|
-}
|
|
-
|
|
/* Collect OsinfoDevice properties from two levels:
|
|
*
|
|
* - The OSINFO_ENTITY_PROP_ID property, originating from the OsinfoEntity base
|
|
@@ -288,17 +235,15 @@ static const char * const device_prop[] = {
|
|
};
|
|
#define NUM_DEVICE_PROPS (sizeof device_prop / sizeof device_prop[0])
|
|
|
|
-value
|
|
-v2v_osinfo_os_get_all_devices (value osv)
|
|
+static value
|
|
+v2v_osinfo_device_list_to_value_list (OsinfoDeviceList *dev_list)
|
|
{
|
|
- CAMLparam1 (osv);
|
|
+ CAMLparam0 ();
|
|
CAMLlocal4 (retvalv, linkv, propsv, copyv);
|
|
- g_autoptr (OsinfoDeviceList) dev_list = NULL;
|
|
OsinfoList *ent_list;
|
|
gint ent_nr;
|
|
|
|
retvalv = Val_emptylist;
|
|
- dev_list = osinfo_os_get_all_devices (OsinfoOs_t_val (osv), NULL);
|
|
ent_list = OSINFO_LIST (dev_list);
|
|
ent_nr = osinfo_list_get_length (ent_list);
|
|
|
|
@@ -328,3 +273,68 @@ v2v_osinfo_os_get_all_devices (value osv)
|
|
|
|
CAMLreturn (retvalv);
|
|
}
|
|
+
|
|
+value
|
|
+v2v_osinfo_os_get_device_drivers (value osv)
|
|
+{
|
|
+ CAMLparam1 (osv);
|
|
+ CAMLlocal4 (rv, v, vi, copyv);
|
|
+ OsinfoDeviceDriverList *list;
|
|
+ gint i, len;
|
|
+
|
|
+ list = osinfo_os_get_device_drivers (OsinfoOs_t_val (osv));
|
|
+ len = osinfo_list_get_length (OSINFO_LIST(list));
|
|
+
|
|
+ rv = Val_emptylist;
|
|
+ for (i = len - 1; i >= 0; --i) {
|
|
+ OsinfoDeviceDriver *driver;
|
|
+ const gchar *str;
|
|
+ gboolean b;
|
|
+ GList *l;
|
|
+ gint64 i64;
|
|
+
|
|
+ driver = OSINFO_DEVICE_DRIVER(osinfo_list_get_nth (OSINFO_LIST(list), i));
|
|
+
|
|
+ vi = caml_alloc (6, 0);
|
|
+ str = osinfo_device_driver_get_architecture (driver);
|
|
+ copyv = caml_copy_string (str);
|
|
+ Store_field (vi, 0, copyv);
|
|
+ str = osinfo_device_driver_get_location (driver);
|
|
+ copyv = caml_copy_string (str);
|
|
+ Store_field (vi, 1, copyv);
|
|
+ b = osinfo_device_driver_get_pre_installable (driver);
|
|
+ Store_field (vi, 2, Val_bool (b));
|
|
+ b = osinfo_device_driver_get_signed (driver);
|
|
+ Store_field (vi, 3, Val_bool (b));
|
|
+#if IS_LIBOSINFO_VERSION(1, 7, 0)
|
|
+ i64 = osinfo_device_driver_get_priority (driver);
|
|
+#else
|
|
+ /* Same as OSINFO_DEVICE_DRIVER_DEFAULT_PRIORITY in libosinfo 1.7.0+. */
|
|
+ i64 = 50;
|
|
+#endif
|
|
+ copyv = caml_copy_int64 (i64);
|
|
+ Store_field (vi, 4, copyv);
|
|
+ l = osinfo_device_driver_get_files (driver);
|
|
+ Store_field (vi, 5, glist_to_value_list (l));
|
|
+ g_list_free (l);
|
|
+
|
|
+ v = caml_alloc (2, 0);
|
|
+ Store_field (v, 0, vi);
|
|
+ Store_field (v, 1, rv);
|
|
+ rv = v;
|
|
+ }
|
|
+
|
|
+ CAMLreturn (rv);
|
|
+}
|
|
+
|
|
+value
|
|
+v2v_osinfo_os_get_all_devices (value osv)
|
|
+{
|
|
+ CAMLparam1 (osv);
|
|
+ CAMLlocal1 (retvalv);
|
|
+ g_autoptr (OsinfoDeviceList) dev_list = NULL;
|
|
+
|
|
+ dev_list = osinfo_os_get_all_devices (OsinfoOs_t_val (osv), NULL);
|
|
+ retvalv = v2v_osinfo_device_list_to_value_list (dev_list);
|
|
+ CAMLreturn (retvalv);
|
|
+}
|
|
--
|
|
2.19.1.3.g30247aa5d201
|
|
|