summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKohei Tokunaga <ktokunaga.mail@gmail.com>2025-04-22 14:27:06 +0900
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2025-04-25 17:00:41 +0200
commit7748cdbae899f54f672e2e5ecd2c556c256b2b08 (patch)
tree5d1d4e9b02e50f958d5c36ac28ccde9da7d9f8a1
parent2cd09e47aa522dfc7bb206f13d6dccb68dd09887 (diff)
downloadfocaccia-qemu-7748cdbae899f54f672e2e5ecd2c556c256b2b08.tar.gz
focaccia-qemu-7748cdbae899f54f672e2e5ecd2c556c256b2b08.zip
qom/object: Fix type conflict of GLib function pointers
On Emscripten, function pointer casts can result in runtime failures due to
strict function signature checks. This affects the use of g_list_sort and
g_slist_sort, which internally perform function pointer casts that are not
supported by Emscripten. To avoid these issues, g_list_sort_with_data and
g_slist_sort_with_data should be used instead, as they do not rely on
function pointer casting.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <8ca13f4e2b9eba9d1f6030b0afb442a24330e463.1745295397.git.ktokunaga.mail@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
-rw-r--r--qom/object.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/qom/object.c b/qom/object.c
index 425ee2f0ee..664f0f24ae 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1191,7 +1191,7 @@ GSList *object_class_get_list(const char *implements_type,
     return list;
 }
 
-static gint object_class_cmp(gconstpointer a, gconstpointer b)
+static gint object_class_cmp(gconstpointer a, gconstpointer b, gpointer d)
 {
     return strcasecmp(object_class_get_name((ObjectClass *)a),
                       object_class_get_name((ObjectClass *)b));
@@ -1200,8 +1200,9 @@ static gint object_class_cmp(gconstpointer a, gconstpointer b)
 GSList *object_class_get_list_sorted(const char *implements_type,
                                      bool include_abstract)
 {
-    return g_slist_sort(object_class_get_list(implements_type, include_abstract),
-                        object_class_cmp);
+    return g_slist_sort_with_data(
+        object_class_get_list(implements_type, include_abstract),
+        object_class_cmp, NULL);
 }
 
 Object *object_ref(void *objptr)