From e12703da0b3c338984bd4b175b225e877a9cfad3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= <frederic.danis@collabora.com>
Date: Wed, 26 Jan 2022 09:38:43 +0100
Subject: [PATCH] Import where-am-i demo app fix
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Call to where-am-i on 32bits platform ends up with following error:
*** stack smashing detected ***: terminated

GTimeVal parameters are glong, which depends on the platform, but
timestamp returned by geoclue is guint64 for both seconds and useconds.
Furthermore GTimeVal is marked as deprecated.

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
---
 ...TimeVal-and-g_date_time_new_from_tim.patch | 36 +++++++++++++++++++
 debian/patches/series                         |  1 +
 2 files changed, 37 insertions(+)
 create mode 100644 debian/patches/0007-demo-Don-t-use-GTimeVal-and-g_date_time_new_from_tim.patch

diff --git a/debian/patches/0007-demo-Don-t-use-GTimeVal-and-g_date_time_new_from_tim.patch b/debian/patches/0007-demo-Don-t-use-GTimeVal-and-g_date_time_new_from_tim.patch
new file mode 100644
index 0000000..6c6bce8
--- /dev/null
+++ b/debian/patches/0007-demo-Don-t-use-GTimeVal-and-g_date_time_new_from_tim.patch
@@ -0,0 +1,36 @@
+From 9ffb0cae3d3d32b60ec226818bb24582a3c0f5e4 Mon Sep 17 00:00:00 2001
+From: Teemu Ikonen <tpikonen@mailbox.org>
+Date: Wed, 20 Oct 2021 17:54:08 +0300
+Subject: demo: Don't use GTimeVal and g_date_time_new_from_timeval_local
+
+They have been deprecated since GLib version 2.62.
+
+diff --git a/demo/where-am-i.c b/demo/where-am-i.c
+index 4c1c2c3..eaf0f65 100644
+--- a/demo/where-am-i.c
++++ b/demo/where-am-i.c
+@@ -84,7 +84,6 @@ print_location (GClueSimple *simple)
+         GClueLocation *location;
+         gdouble altitude, speed, heading;
+         GVariant *timestamp;
+-        GTimeVal tv = { 0 };
+         const char *desc;
+ 
+         location = gclue_simple_get_location (simple);
+@@ -111,11 +110,13 @@ print_location (GClueSimple *simple)
+         timestamp = gclue_location_get_timestamp (location);
+         if (timestamp) {
+                 GDateTime *date_time;
++                guint64 sec, usec;
+                 gchar *str;
+ 
+-                g_variant_get (timestamp, "(tt)", &tv.tv_sec, &tv.tv_usec);
++                g_variant_get (timestamp, "(tt)", &sec, &usec);
+ 
+-                date_time = g_date_time_new_from_timeval_local (&tv);
++                /* Ignore usec, since it is not in the output format */
++                date_time = g_date_time_new_from_unix_local ((gint64) sec);
+                 str = g_date_time_format
+                       (date_time,
+                        "%c (%s seconds since the Epoch)");
+
diff --git a/debian/patches/series b/debian/patches/series
index a63e750..47784ef 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -3,3 +3,4 @@
 0002-config-Make-the-Mozilla-API-key-configurable.patch
 0003-service-Sync-in_use-property-when-apps-get-connected.patch
 0005-config-Clear-error-after-submission-URL-lookup-fails.patch
+0007-demo-Don-t-use-GTimeVal-and-g_date_time_new_from_tim.patch
-- 
GitLab