From: Bartosz Golaszewski Date: Tue, 1 Oct 2024 12:54:17 +0000 (+0200) Subject: dbus: use correct types for edge events X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=2df6347c0859c12edd3cdd98f1611c72d9698a8f;p=qemu-gpiodev%2Flibgpiod.git dbus: use correct types for edge events On 32-bit architectures the size of a gulong will typically be 4 bytes while we try to package an 8-byte integer when creating the edge event variant. The client also expects wrong types and crashes. Use strict type sizes for sending the events. Closes: https://github.com/brgl/libgpiod/issues/103 Signed-off-by: Bartosz Golaszewski --- diff --git a/dbus/client/monitor.c b/dbus/client/monitor.c index 292b2bf..3bd25b8 100644 --- a/dbus/client/monitor.c +++ b/dbus/client/monitor.c @@ -16,14 +16,14 @@ static void on_edge_event(GpiodbusLine *line, GVariant *args, gpointer user_data G_GNUC_UNUSED) { const char *name = gpiodbus_line_get_name(line); - gulong global_seqno, line_seqno; - guint64 timestamp; - gint edge; + guint64 global_seqno, line_seqno, timestamp; + gint32 edge; g_variant_get(args, "(ittt)", &edge, ×tamp, &global_seqno, &line_seqno); - g_print("%lu %s ", timestamp, edge ? "rising " : "falling"); + g_print("%"G_GUINT64_FORMAT" %s ", + timestamp, edge ? "rising " : "falling"); if (strlen(name)) g_print("\"%s\"\n", name); else diff --git a/dbus/manager/daemon.c b/dbus/manager/daemon.c index 1bfc3cb..8e1de8a 100644 --- a/dbus/manager/daemon.c +++ b/dbus/manager/daemon.c @@ -520,12 +520,11 @@ gpiodbus_daemon_on_edge_event(GpiodglibLineRequest *request G_GNUC_UNUSED, GpiodglibEdgeEvent *event, gpointer user_data) { GpiodbusDaemonRequestData *req_data = user_data; + guint64 line_seqno, global_seqno, timestamp; GpiodbusDaemonLineData *line_data; - gulong line_seqno, global_seqno; GpiodglibEdgeEventType edge; - guint64 timestamp; guint offset; - gint val; + gint32 val; edge = gpiodglib_edge_event_get_event_type(event); offset = gpiodglib_edge_event_get_line_offset(event);