[glib: 1/2] Fix cast from pointer to integer of different size warning in gio/gwin32appinfo.c




commit 8444dc569508f384f8e2168540113aa9ba74b892
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date:   Tue Oct 26 11:48:48 2021 +0000

    Fix cast from pointer to integer of different size warning in gio/gwin32appinfo.c

 gio/gwin32appinfo.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gio/gwin32appinfo.c b/gio/gwin32appinfo.c
index 3468dfee0..6c1d35979 100644
--- a/gio/gwin32appinfo.c
+++ b/gio/gwin32appinfo.c
@@ -4853,7 +4853,13 @@ g_win32_app_info_launch_internal (GWin32AppInfo      *info,
           GVariant *platform_data;
 
           g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
-          g_variant_builder_add (&builder, "{sv}", "pid", g_variant_new_int32 ((gint32) pid));
+          /* pid handles are never bigger than 2^24 as per
+           * https://docs.microsoft.com/en-us/windows/win32/sysinfo/kernel-objects,
+           * so truncating to `int32` is valid.
+           * The gsize cast is to silence a compiler warning
+           * about conversion from pointer to integer of
+           * different size. */
+          g_variant_builder_add (&builder, "{sv}", "pid", g_variant_new_int32 ((gsize) pid));
 
           platform_data = g_variant_ref_sink (g_variant_builder_end (&builder));
           g_signal_emit_by_name (launch_context, "launched", info, platform_data);


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