All of lore.kernel.org
 help / color / mirror / Atom feed
From: "akuster" <akuster808@gmail.com>
To: openembedded-devel@lists.openembedded.org
Subject: [dunfel 28/32] linuxptp: Fix segmentation fault on 32 bit platforms with 64 bit time_t
Date: Tue, 30 Jun 2020 17:07:13 -0700	[thread overview]
Message-ID: <c88e8dceeb52688139cfd12f0ccfac1760dfd023.1593561840.git.akuster808@gmail.com> (raw)
In-Reply-To: <cover.1593561840.git.akuster808@gmail.com>

From: Christian Eggers <ceggers@arri.de>

Back ported upstream patch:
https://github.com/richardcochran/linuxptp/commit/7de73fefc378cc42b9ed1115b3afa409d0250a48

Signed-off-by: Christian Eggers <ceggers@arri.de>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
(cherry picked from commit 924bd4dd084cb86704c52fecee5bd147186a6efb)
Signed-off-by: Armin Kuster <akuster808@gmail.com>
---
 .../linuxptp/time_t_maybe_long_long.patch     | 135 ++++++++++++++++++
 .../linuxptp/linuxptp_2.0.bb                  |   1 +
 2 files changed, 136 insertions(+)
 create mode 100644 meta-oe/recipes-connectivity/linuxptp/linuxptp/time_t_maybe_long_long.patch

diff --git a/meta-oe/recipes-connectivity/linuxptp/linuxptp/time_t_maybe_long_long.patch b/meta-oe/recipes-connectivity/linuxptp/linuxptp/time_t_maybe_long_long.patch
new file mode 100644
index 0000000000..af99d2b7f9
--- /dev/null
+++ b/meta-oe/recipes-connectivity/linuxptp/linuxptp/time_t_maybe_long_long.patch
@@ -0,0 +1,135 @@
+Fix printf if time_t is long long
+
+On some platforms, time_t has recently switched from "long" to "long
+long" [1]. For these platforms it is necessary to use "%lld" as printf
+format specifier because the ABI differs between "long" and "long long".
+
+I found no way for creating something similar to PRId64 for time_t. No
+idea how to determine whether it's "long" or "long long". So I cast
+everything to "long long" instead.
+
+[1] https://git.musl-libc.org/cgit/musl/commit/?id=38143339646a4ccce8afe298c34467767c899f51
+
+Upstream-Status: Accepted [next version is after 2.0]
+Upstream-Patch: https://github.com/richardcochran/linuxptp/commit/7de73fefc378cc42b9ed1115b3afa409d0250a48
+
+Signed-off-by: Christian Eggers <ceggers@arri.de>
+---
+diff -Naur linuxptp-2.0.org/phc_ctl.c linuxptp-2.0/phc_ctl.c
+--- linuxptp-2.0.org/phc_ctl.c	2018-08-12 23:08:43.000000000 +0200
++++ linuxptp-2.0/phc_ctl.c	2020-05-29 21:34:26.166519963 +0200
+@@ -230,8 +230,8 @@
+ 			strerror(errno));
+ 		return -1;
+ 	} else {
+-		pr_notice("set clock time to %ld.%09ld or %s",
+-			ts.tv_sec, ts.tv_nsec, ctime(&ts.tv_sec));
++		pr_notice("set clock time to %lld.%09ld or %s",
++			(long long)ts.tv_sec, ts.tv_nsec, ctime(&ts.tv_sec));
+ 	}
+ 
+ 	return args_to_eat;
+@@ -248,8 +248,8 @@
+ 
+ 		return -1;
+ 	} else {
+-		pr_notice("clock time is %ld.%09lu or %s",
+-			ts.tv_sec, ts.tv_nsec, ctime(&ts.tv_sec));
++		pr_notice("clock time is %lld.%09lu or %s",
++			(long long)ts.tv_sec, ts.tv_nsec, ctime(&ts.tv_sec));
+ 	}
+ 
+ 	/* get operation does not require any arguments */
+diff -Naur linuxptp-2.0.org/print.c linuxptp-2.0/print.c
+--- linuxptp-2.0.org/print.c	2018-08-12 23:08:43.000000000 +0200
++++ linuxptp-2.0/print.c	2020-05-29 21:34:26.166519963 +0200
+@@ -73,16 +73,16 @@
+ 
+ 	if (verbose) {
+ 		f = level >= LOG_NOTICE ? stdout : stderr;
+-		fprintf(f, "%s[%ld.%03ld]: %s%s%s\n",
++		fprintf(f, "%s[%lld.%03ld]: %s%s%s\n",
+ 			progname ? progname : "",
+-			ts.tv_sec, ts.tv_nsec / 1000000,
++			(long long)ts.tv_sec, ts.tv_nsec / 1000000,
+ 			message_tag ? message_tag : "", message_tag ? " " : "",
+ 			buf);
+ 		fflush(f);
+ 	}
+ 	if (use_syslog) {
+-		syslog(level, "[%ld.%03ld] %s%s%s",
+-		       ts.tv_sec, ts.tv_nsec / 1000000,
++		syslog(level, "[%lld.%03ld] %s%s%s",
++		       (long long)ts.tv_sec, ts.tv_nsec / 1000000,
+ 		       message_tag ? message_tag : "", message_tag ? " " : "",
+ 		       buf);
+ 	}
+diff -Naur linuxptp-2.0.org/unicast_service.c linuxptp-2.0/unicast_service.c
+--- linuxptp-2.0.org/unicast_service.c	2018-08-12 23:08:43.000000000 +0200
++++ linuxptp-2.0/unicast_service.c	2020-05-29 21:36:23.170497415 +0200
+@@ -209,9 +209,9 @@
+ 	tmo = now.tv_sec + req->durationField;
+ 	if (tmo > client->grant_tmo) {
+ 		client->grant_tmo = tmo;
+-		pr_debug("%s grant of 0x%x extended to %ld",
++		pr_debug("%s grant of 0x%x extended to %lld",
+ 			 pid2str(&client->portIdentity),
+-			 client->message_types, tmo);
++			 client->message_types, (long long)tmo);
+ 	}
+ }
+ 
+@@ -226,8 +226,8 @@
+ 	interval = pqueue_peek(p->unicast_service->queue);
+ 	if (interval) {
+ 		tmo.it_value = interval->tmo;
+-		pr_debug("arming timer tmo={%ld,%ld}",
+-			 interval->tmo.tv_sec, interval->tmo.tv_nsec);
++		pr_debug("arming timer tmo={%lld,%ld}",
++			 (long long)interval->tmo.tv_sec, interval->tmo.tv_nsec);
+ 	} else {
+ 		pr_debug("stopping unicast service timer");
+ 	}
+@@ -499,8 +499,8 @@
+ 
+ 	while ((interval = pqueue_peek(p->unicast_service->queue)) != NULL) {
+ 
+-		pr_debug("peek i={2^%d} tmo={%ld,%ld}", interval->log_period,
+-			 interval->tmo.tv_sec, interval->tmo.tv_nsec);
++		pr_debug("peek i={2^%d} tmo={%lld,%ld}", interval->log_period,
++			 (long long)interval->tmo.tv_sec, interval->tmo.tv_nsec);
+ 
+ 		if (timespec_compare(&now, &interval->tmo) >= 0) {
+ 			break;
+@@ -519,8 +519,8 @@
+ 		}
+ 
+ 		interval_increment(interval);
+-		pr_debug("next i={2^%d} tmo={%ld,%ld}", interval->log_period,
+-			 interval->tmo.tv_sec, interval->tmo.tv_nsec);
++		pr_debug("next i={2^%d} tmo={%lld,%ld}", interval->log_period,
++			 (long long)interval->tmo.tv_sec, interval->tmo.tv_nsec);
+ 		pqueue_insert(p->unicast_service->queue, interval);
+ 	}
+ 
+diff -Naur linuxptp-2.0.org/unicast_client.c linuxptp-2.0/unicast_client.c
+--- linuxptp-2.0.org/unicast_client.c	2018-08-12 23:08:43.000000000 +0200
++++ linuxptp-2.0/unicast_client.c	2020-06-02 11:13:06.922997844 +0200
+@@ -216,7 +216,7 @@
+ 				       long duration)
+ {
+ 	struct timespec now;
+-	long tmo;
++	time_t tmo;
+ 
+ 	if (clock_gettime(CLOCK_MONOTONIC, &now)) {
+ 		pr_err("clock_gettime failed: %m");
+@@ -226,7 +226,7 @@
+ 	tmo = now.tv_sec + duration;
+ 	if (!master->renewal_tmo || tmo < master->renewal_tmo) {
+ 		master->renewal_tmo = tmo;
+-		pr_debug("port %d: renewal timeout at %ld", portnum(p), tmo);
++		pr_debug("port %d: renewal timeout at %lld", portnum(p), (long long)tmo);
+ 	}
+ }
+ 
diff --git a/meta-oe/recipes-connectivity/linuxptp/linuxptp_2.0.bb b/meta-oe/recipes-connectivity/linuxptp/linuxptp_2.0.bb
index eb262d36b2..930c6673dc 100644
--- a/meta-oe/recipes-connectivity/linuxptp/linuxptp_2.0.bb
+++ b/meta-oe/recipes-connectivity/linuxptp/linuxptp_2.0.bb
@@ -5,6 +5,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
 SRC_URI = "http://sourceforge.net/projects/linuxptp/files/v${PV}/linuxptp-${PV}.tgz \
            file://build-Allow-CC-and-prefix-to-be-overriden.patch \
            file://no-incdefs-using-host-headers.patch \
+           file://time_t_maybe_long_long.patch \
            "
 
 SRC_URI[md5sum] = "d8bb7374943bb747db7786ac26f17f11"
-- 
2.17.1


  parent reply	other threads:[~2020-07-01  0:07 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-01  0:06 [dunfel 00/32] Patch review akuster
2020-07-01  0:06 ` [dunfel 01/32] zchunk: upgrade 1.1.5 -> 1.1.6 akuster
2020-07-01  0:06 ` [dunfel 02/32] uriparser: upgrade 0.9.3 -> 0.9.4 akuster
2020-07-01  0:06 ` [dunfel 03/32] jsoncpp: upgrade 1.9.2 -> 1.9.3 akuster
2020-07-09 15:21   ` [oe] " Martin Jansa
2020-07-09 16:06     ` akuster
2020-07-09 16:48       ` Martin Jansa
2020-07-10  1:08         ` Khem Raj
2020-07-10  7:37           ` Mikko Rapeli
2020-07-12 18:41             ` akuster
2020-07-13  8:25               ` Mikko Rapeli
2020-07-13 15:46                 ` Khem Raj
2020-07-15  3:52                   ` akuster
2020-07-10 15:55           ` akuster
2020-07-10 16:18             ` Khem Raj
2020-07-01  0:06 ` [dunfel 04/32] proj: upgrade 7.0.0 -> 7.0.1 akuster
2020-07-01  0:06 ` [dunfel 05/32] netkit-rsh: properly append PACKAGECONFIG akuster
2020-07-01  0:06 ` [dunfel 06/32] zile: " akuster
2020-07-01  0:06 ` [dunfel 07/32] postgresql: 12.2 -> 12.3 akuster
2020-07-01  0:06 ` [dunfel 08/32] multipath-tools: Fix build with json-c 0.14 and newer akuster
2020-07-01  8:48   ` [oe] " Adrian Bunk
2020-07-01 16:56     ` akuster
2020-07-01  0:06 ` [dunfel 09/32] libblockdev: upgrade 2.23 -> 2.24 akuster
2020-07-01  0:06 ` [dunfel 10/32] libvpx: upgrade 1.8.1 -> 1.8.2 akuster
2020-07-01  0:06 ` [dunfel 11/32] vlc: Fix build with qt5 in PACKAGECONFIG and Qt >= 5.15 / renumber patches akuster
2020-07-01  0:28   ` [oe] " Martin Jansa
2020-07-01  2:07     ` akuster
2020-07-01  0:06 ` [dunfel 12/32] jpnevulator: upgrade 2.3.4 -> 2.3.5 akuster
2020-07-01  0:06 ` [dunfel 13/32] libnftnl: upgrade 1.1.6 -> 1.1.7 akuster
2020-07-01  0:06 ` [dunfel 14/32] nftables: upgrade 0.9.4 -> 0.9.5 akuster
2020-07-01  0:07 ` [dunfel 15/32] haveged: upgrade 1.9.8 -> 1.9.9 akuster
2020-07-01  0:07 ` [dunfel 16/32] mm-common: upgrade 1.0..0 -> 1.0.1 akuster
2020-07-01  0:07 ` [dunfel 17/32] python-django: add RDEPENDS akuster
2020-07-01  0:07 ` [dunfel 18/32] python-m2crypto: Add RDEPENDS akuster
2020-07-01  0:07 ` [dunfel 19/32] python-django: set CVE_PRODUCT to be django akuster
2020-07-01  0:07 ` [dunfel 20/32] python3-m2crypto: add the missing rdepends akuster
2020-07-01  0:07 ` [dunfel 21/32] zstd: Upgrade 1.4.4 -> 1.4.5 akuster
2020-07-01  0:07 ` [dunfel 22/32] rsnapshot: upgrade 1.4.2 -> 1.4.3 akuster
2020-07-01  0:07 ` [dunfel 23/32] fuse3: upgrade 3.9.1 -> 3.9.2 akuster
2020-07-01  0:07 ` [dunfel 24/32] protobuf-c: disable parallelism to avoid race condition akuster
2020-07-01  0:07 ` [dunfel 25/32] openipmi: upgrade 2.0.28 -> 2.0.29 akuster
2020-07-01  0:07 ` [dunfel 26/32] twm: upgrade 1.0.10 -> 1.0.11 akuster
2020-07-01  0:07 ` [dunfel 27/32] libtalloc: fix upstream url akuster
2020-07-01  0:07 ` akuster [this message]
2020-07-01  0:07 ` [dunfel 29/32] openh264: upgrade 2.1.0 -> 2.1.1 akuster
2020-07-01  0:07 ` [dunfel 30/32] tcpreplay: upgrade 4.3.2 -> 4.3.3 akuster
2020-07-01  0:07 ` [dunfel 31/32] python3-sqlalchemy: Upgrade 1.3.12 -> 1.3.17 akuster
2020-07-01  0:07 ` [dunfel 32/32] ntp: update 4.2.8p15 akuster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c88e8dceeb52688139cfd12f0ccfac1760dfd023.1593561840.git.akuster808@gmail.com \
    --to=akuster808@gmail.com \
    --cc=openembedded-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.