From 8b58ecddd39a62b4c90fdda2dfebba5cacc2a30c Mon Sep 17 00:00:00 2001
From: mio <miyopan@e.email>
Date: Fri, 22 Nov 2024 07:10:04 +0000
Subject: [PATCH] community/telepathy-logger: fix build with gcc 14 on 32-bit
 arches

Fix -Wincompatible-pointer-types error with gcc 14 on 32-bit arches.

```
telepathy-logger.c: In function 'log_handler':
telepathy-logger.c:70:20: error: passing argument 1 of 'localtime_r' from incompatible pointer type [-Wincompatible-pointer-types]
   70 |       localtime_r (&(now.tv_sec), &tm);
      |                    ^~~~~~~~~~~~~
      |                    |
      |                    glong * {aka long int *}
In file included from /usr/include/glib-2.0/glib/gtypes.h:41,
                 from /usr/include/glib-2.0/glib/galloca.h:34,
                 from /usr/include/glib-2.0/glib.h:32,
                 from telepathy-logger.c:23:
/usr/include/time.h:76:25: note: expected 'const time_t * restrict' {aka 'const long long int * restrict'} but argument is of type 'glong *' {aka 'long int *'}
   76 | struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
      |                         ^
```
---
 community/telepathy-logger/APKBUILD           |  4 ++-
 community/telepathy-logger/gcc14-time-t.patch | 36 +++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 community/telepathy-logger/gcc14-time-t.patch

diff --git a/community/telepathy-logger/APKBUILD b/community/telepathy-logger/APKBUILD
index cac2f8b64696..974537d0fcda 100644
--- a/community/telepathy-logger/APKBUILD
+++ b/community/telepathy-logger/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Natanael Copa <ncopa@alpinelinux.org>
 pkgname=telepathy-logger
 pkgver=0.8.2
-pkgrel=6
+pkgrel=7
 pkgdesc="Telepathy framework logging daemon"
 url="https://telepathy.freedesktop.org/components/telepathy-logger/"
 arch="all"
@@ -23,6 +23,7 @@ subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
 source="https://telepathy.freedesktop.org/releases/telepathy-logger/telepathy-logger-$pkgver.tar.bz2
 	python3.patch
 	gcc14.patch
+	gcc14-time-t.patch
 	"
 
 prepare() {
@@ -58,4 +59,5 @@ sha512sums="
 f3eda26133a4c38eeb79b01cbe3b7801a5eb773e8b4e6ce621c47d3ca701025364c6b2b890caea00104f01ba85ae891a6fad82d7a9dc487fd7a980221cede451  telepathy-logger-0.8.2.tar.bz2
 54e8accf12572245e3d02c971d3b2945a52b9e1eb124310ac3ceb80a30f18748ebd80e0cd8a363256e054380182bcd490e4fe6d2dfb68f7effb98f85747341c5  python3.patch
 4110056b029db419992135b4e00ba861d2ad023752275d2dbafc71d8ef9a815fa4b4161230e3976cd4e209906f9f1e77a1c562ece92b6d033ef774084f5d5d0f  gcc14.patch
+656e367a5b139d902678deb678e459867679f298e1dc52a267bfd184f2f411144291c720db2b62aec345ccee97cf2c34ce5376fee5051634c16db4be9367a652  gcc14-time-t.patch
 "
diff --git a/community/telepathy-logger/gcc14-time-t.patch b/community/telepathy-logger/gcc14-time-t.patch
new file mode 100644
index 000000000000..f2c38f7f202d
--- /dev/null
+++ b/community/telepathy-logger/gcc14-time-t.patch
@@ -0,0 +1,36 @@
+--- a/src/telepathy-logger.c
++++ b/src/telepathy-logger.c
+@@ -67,7 +67,8 @@
+       struct tm tm;
+ 
+       g_get_current_time (&now);
+-      localtime_r (&(now.tv_sec), &tm);
++      time_t tmp_t = now.tv_sec;
++      localtime_r (&tmp_t, &tm);
+       strftime (now_str, 32, "%Y-%m-%d %H:%M:%S", &tm);
+       tmp = g_strdup_printf ("%s.%06ld: %s",
+         now_str, now.tv_usec, message);
+--- a/tests/dbus/test-log-manager.c
++++ b/tests/dbus/test-log-manager.c
+@@ -70,7 +70,8 @@
+       struct tm tm;
+ 
+       g_get_current_time (&now);
+-      localtime_r (&(now.tv_sec), &tm);
++      time_t tmp_t = now.tv_sec;
++      localtime_r (&tmp_t, &tm);
+       strftime (now_str, 32, "%Y-%m-%d %H:%M:%S", &tm);
+       tmp = g_strdup_printf ("%s.%06ld: %s",
+           now_str, now.tv_usec, message);
+--- a/tests/dbus/test-tpl-log-store-pidgin.c
++++ b/tests/dbus/test-tpl-log-store-pidgin.c
+@@ -76,7 +76,8 @@
+       struct tm tm;
+ 
+       g_get_current_time (&now);
+-      localtime_r (&(now.tv_sec), &tm);
++      time_t tmp_t = now.tv_sec;
++      localtime_r (&tmp_t, &tm);
+       strftime (now_str, 32, "%Y-%m-%d %H:%M:%S", &tm);
+       tmp = g_strdup_printf ("%s.%06ld: %s",
+         now_str, now.tv_usec, message);
-- 
GitLab