[oe,meta-multimedia,2/3] tvheadend: Fix build with 64bit time_t

Message ID 20191112205738.725884-2-raj.khem@gmail.com
State New
Headers show
Series
  • [oe,meta-oe,1/3] open-vm-tools: Enable tirpc explicitly, fix build with 64bit time_t
Related show

Commit Message

Khem Raj Nov. 12, 2019, 8:57 p.m.
use intmax_t to print time_t, makes it portable across musl/glibc

Signed-off-by: Khem Raj <raj.khem@gmail.com>

---
 .../0001-adjust-for-64bit-time_t.patch        | 107 ++++++++++++++++++
 .../recipes-dvb/tvheadend/tvheadend_git.bb    |   4 +-
 2 files changed, 110 insertions(+), 1 deletion(-)
 create mode 100644 meta-multimedia/recipes-dvb/tvheadend/tvheadend/0001-adjust-for-64bit-time_t.patch

-- 
2.24.0

-- 
_______________________________________________
Openembedded-devel mailing list
Openembedded-devel@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-devel

Patch

diff --git a/meta-multimedia/recipes-dvb/tvheadend/tvheadend/0001-adjust-for-64bit-time_t.patch b/meta-multimedia/recipes-dvb/tvheadend/tvheadend/0001-adjust-for-64bit-time_t.patch
new file mode 100644
index 0000000000..9c7294aefb
--- /dev/null
+++ b/meta-multimedia/recipes-dvb/tvheadend/tvheadend/0001-adjust-for-64bit-time_t.patch
@@ -0,0 +1,107 @@ 
+From 81f29b028473a3d8ac0aaeb126fc0336a98bb077 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 12 Nov 2019 11:03:16 -0800
+Subject: [PATCH] adjust for 64bit time_t
+
+Break assumption about time_t being of certain size, and use intmax_t to
+print it where needed
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/cron.c                    | 4 ++--
+ src/epggrab/module/psip.c     | 2 +-
+ src/epggrab/otamux.c          | 2 +-
+ src/parsers/parser_teletext.c | 2 +-
+ src/tvheadend.h               | 6 +-----
+ src/webui/webui.c             | 4 ++--
+ 6 files changed, 8 insertions(+), 12 deletions(-)
+
+diff --git a/src/cron.c b/src/cron.c
+index b2484070f..4f7f54ba3 100644
+--- a/src/cron.c
++++ b/src/cron.c
+@@ -329,9 +329,9 @@ cron_next ( cron_t *c, const time_t now, time_t *ret )
+     *ret = mktime(&tmp);
+   if (*ret <= now) {
+ #ifndef CRON_TEST
+-    tvherror(LS_CRON, "invalid time, now %"PRItime_t", result %"PRItime_t, now, *ret);
++    tvherror(LS_CRON, "invalid time, now %"PRItime_t", result %"PRItime_t, (intmax_t)now, (intmax_t)*ret);
+ #else
+-    printf("ERROR: invalid time, now %"PRItime_t", result %"PRItime_t"\n", now, *ret);
++    printf("ERROR: invalid time, now %"PRItime_t", result %"PRItime_t"\n", (intmax_t)now, (intmax_t)*ret);
+ #endif
+     *ret = now + 600;
+   }
+diff --git a/src/epggrab/module/psip.c b/src/epggrab/module/psip.c
+index d979ba12c..4f8e41642 100644
+--- a/src/epggrab/module/psip.c
++++ b/src/epggrab/module/psip.c
+@@ -390,7 +390,7 @@ _psip_eit_callback_channel
+ 
+     ebc = epg_broadcast_find_by_time(ch, mod, start, stop, 1, &save2, &changes2);
+     tvhtrace(LS_PSIP, "  eid=%5d, start=%"PRItime_t", stop=%"PRItime_t", ebc=%p",
+-             eventid, start, stop, ebc);
++             eventid, (intmax_t)start, (intmax_t)stop, ebc);
+     if (!ebc) goto next;
+ 
+     save2 |= epg_broadcast_set_dvb_eid(ebc, eventid, &changes2);
+diff --git a/src/epggrab/otamux.c b/src/epggrab/otamux.c
+index 495354390..cdabb0cd7 100644
+--- a/src/epggrab/otamux.c
++++ b/src/epggrab/otamux.c
+@@ -719,7 +719,7 @@ epggrab_ota_start_cb ( void *p );
+ static void
+ epggrab_ota_next_arm( time_t next )
+ {
+-  tvhtrace(LS_EPGGRAB, "next ota start event in %li seconds", next - time(NULL));
++  tvhtrace(LS_EPGGRAB, "next ota start event in %jd seconds", (intmax_t)(next - time(NULL)));
+   gtimer_arm_absn(&epggrab_ota_start_timer, epggrab_ota_start_cb, NULL, next);
+   dbus_emit_signal_s64("/epggrab/ota", "next", next);
+ }
+diff --git a/src/parsers/parser_teletext.c b/src/parsers/parser_teletext.c
+index ff39eb6ac..5a07299c4 100644
+--- a/src/parsers/parser_teletext.c
++++ b/src/parsers/parser_teletext.c
+@@ -625,7 +625,7 @@ tt_construct_unix_time(uint8_t *buf)
+   r[2] = mktime(&tm);
+ 
+   for(i = 0; i < 3; i++)
+-    v[i] = labs(r[i] - t);
++    v[i] = (time_t)llabs((long long)(r[i] - t));
+   
+   if(v[0] < v[1] && v[0] < v[2])
+     return r[0];
+diff --git a/src/tvheadend.h b/src/tvheadend.h
+index 072391d3e..504c42253 100644
+--- a/src/tvheadend.h
++++ b/src/tvheadend.h
+@@ -332,11 +332,7 @@ void tvh_qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void
+ # endif /* ULONG_MAX */
+ #endif /* __WORDSIZE */
+ 
+-#if __WORDSIZE == 32 && defined(PLATFORM_FREEBSD)
+-#define PRItime_t       "d"
+-#else
+-#define PRItime_t       "ld"
+-#endif
++#define PRItime_t       "jd"
+ 
+ /* transcoding */
+ #define TVH_NAME_LEN 32
+diff --git a/src/webui/webui.c b/src/webui/webui.c
+index 3e63aeacc..fb429acd3 100644
+--- a/src/webui/webui.c
++++ b/src/webui/webui.c
+@@ -944,9 +944,9 @@ http_dvr_playlist(http_connection_t *hc, int pltype, int urlauth, dvr_entry_t *d
+     strftime(buf, sizeof(buf), "%FT%T%z", localtime_r(&(de->de_start), &tm));
+ 
+     htsbuf_append_str(hq, "#EXTM3U\n");
+-    htsbuf_qprintf(hq, "#EXTINF:%"PRItime_t",%s\n", durration, lang_str_get(de->de_title, NULL));
++    htsbuf_qprintf(hq, "#EXTINF:%"PRItime_t",%s\n", (intmax_t)durration, lang_str_get(de->de_title, NULL));
+     
+-    htsbuf_qprintf(hq, "#EXT-X-TARGETDURATION:%"PRItime_t"\n", durration);
++    htsbuf_qprintf(hq, "#EXT-X-TARGETDURATION:%"PRItime_t"\n", (intmax_t)durration);
+     uuid = idnode_uuid_as_str(&de->de_id, ubuf);
+     htsbuf_qprintf(hq, "#EXT-X-STREAM-INF:PROGRAM-ID=%s,BANDWIDTH=%d\n", uuid, bandwidth);
+     htsbuf_qprintf(hq, "#EXT-X-PROGRAM-DATE-TIME:%s\n", buf);
diff --git a/meta-multimedia/recipes-dvb/tvheadend/tvheadend_git.bb b/meta-multimedia/recipes-dvb/tvheadend/tvheadend_git.bb
index 5b3c469793..d7f749b647 100644
--- a/meta-multimedia/recipes-dvb/tvheadend/tvheadend_git.bb
+++ b/meta-multimedia/recipes-dvb/tvheadend/tvheadend_git.bb
@@ -8,7 +8,9 @@  DEPENDS = "avahi cmake-native dvb-apps libdvbcsa libpcre2 openssl uriparser zlib
 LICENSE = "GPLv3+"
 LIC_FILES_CHKSUM = "file://LICENSE.md;md5=9cae5acac2e9ee2fc3aec01ac88ce5db"
 
-SRC_URI = "git://github.com/tvheadend/tvheadend.git"
+SRC_URI = "git://github.com/tvheadend/tvheadend.git \
+           file://0001-adjust-for-64bit-time_t.patch \
+           "
 
 SRCREV = "fda89e85e0b6ae796d8a09e178d3937aa7869270"
 PV = "4.3+git${SRCPV}"