diff options
| author | Christian Eggers <ceggers@arri.de> | 2020-06-19 15:20:57 +0200 |
|---|---|---|
| committer | Armin Kuster <akuster808@gmail.com> | 2020-07-01 08:01:41 -0700 |
| commit | 63844270a32fa26de50dd96be0e3d272eaa1df16 (patch) | |
| tree | 290e589bb640560025c8a8678d35eadbf46f2593 | |
| parent | 1f145080dde143f1b5cbcc21aa4299c585849408 (diff) | |
| download | meta-openembedded-63844270a32fa26de50dd96be0e3d272eaa1df16.tar.gz | |
linuxptp: Fix segmentation fault on 32 bit platforms with 64 bit time_t
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>
| -rw-r--r-- | meta-oe/recipes-connectivity/linuxptp/linuxptp/time_t_maybe_long_long.patch | 135 | ||||
| -rw-r--r-- | meta-oe/recipes-connectivity/linuxptp/linuxptp_2.0.bb | 1 |
2 files changed, 136 insertions, 0 deletions
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 @@ | |||
| 1 | Fix printf if time_t is long long | ||
| 2 | |||
| 3 | On some platforms, time_t has recently switched from "long" to "long | ||
| 4 | long" [1]. For these platforms it is necessary to use "%lld" as printf | ||
| 5 | format specifier because the ABI differs between "long" and "long long". | ||
| 6 | |||
| 7 | I found no way for creating something similar to PRId64 for time_t. No | ||
| 8 | idea how to determine whether it's "long" or "long long". So I cast | ||
| 9 | everything to "long long" instead. | ||
| 10 | |||
| 11 | [1] https://git.musl-libc.org/cgit/musl/commit/?id=38143339646a4ccce8afe298c34467767c899f51 | ||
| 12 | |||
| 13 | Upstream-Status: Accepted [next version is after 2.0] | ||
| 14 | Upstream-Patch: https://github.com/richardcochran/linuxptp/commit/7de73fefc378cc42b9ed1115b3afa409d0250a48 | ||
| 15 | |||
| 16 | Signed-off-by: Christian Eggers <ceggers@arri.de> | ||
| 17 | --- | ||
| 18 | diff -Naur linuxptp-2.0.org/phc_ctl.c linuxptp-2.0/phc_ctl.c | ||
| 19 | --- linuxptp-2.0.org/phc_ctl.c 2018-08-12 23:08:43.000000000 +0200 | ||
| 20 | +++ linuxptp-2.0/phc_ctl.c 2020-05-29 21:34:26.166519963 +0200 | ||
| 21 | @@ -230,8 +230,8 @@ | ||
| 22 | strerror(errno)); | ||
| 23 | return -1; | ||
| 24 | } else { | ||
| 25 | - pr_notice("set clock time to %ld.%09ld or %s", | ||
| 26 | - ts.tv_sec, ts.tv_nsec, ctime(&ts.tv_sec)); | ||
| 27 | + pr_notice("set clock time to %lld.%09ld or %s", | ||
| 28 | + (long long)ts.tv_sec, ts.tv_nsec, ctime(&ts.tv_sec)); | ||
| 29 | } | ||
| 30 | |||
| 31 | return args_to_eat; | ||
| 32 | @@ -248,8 +248,8 @@ | ||
| 33 | |||
| 34 | return -1; | ||
| 35 | } else { | ||
| 36 | - pr_notice("clock time is %ld.%09lu or %s", | ||
| 37 | - ts.tv_sec, ts.tv_nsec, ctime(&ts.tv_sec)); | ||
| 38 | + pr_notice("clock time is %lld.%09lu or %s", | ||
| 39 | + (long long)ts.tv_sec, ts.tv_nsec, ctime(&ts.tv_sec)); | ||
| 40 | } | ||
| 41 | |||
| 42 | /* get operation does not require any arguments */ | ||
| 43 | diff -Naur linuxptp-2.0.org/print.c linuxptp-2.0/print.c | ||
| 44 | --- linuxptp-2.0.org/print.c 2018-08-12 23:08:43.000000000 +0200 | ||
| 45 | +++ linuxptp-2.0/print.c 2020-05-29 21:34:26.166519963 +0200 | ||
| 46 | @@ -73,16 +73,16 @@ | ||
| 47 | |||
| 48 | if (verbose) { | ||
| 49 | f = level >= LOG_NOTICE ? stdout : stderr; | ||
| 50 | - fprintf(f, "%s[%ld.%03ld]: %s%s%s\n", | ||
| 51 | + fprintf(f, "%s[%lld.%03ld]: %s%s%s\n", | ||
| 52 | progname ? progname : "", | ||
| 53 | - ts.tv_sec, ts.tv_nsec / 1000000, | ||
| 54 | + (long long)ts.tv_sec, ts.tv_nsec / 1000000, | ||
| 55 | message_tag ? message_tag : "", message_tag ? " " : "", | ||
| 56 | buf); | ||
| 57 | fflush(f); | ||
| 58 | } | ||
| 59 | if (use_syslog) { | ||
| 60 | - syslog(level, "[%ld.%03ld] %s%s%s", | ||
| 61 | - ts.tv_sec, ts.tv_nsec / 1000000, | ||
| 62 | + syslog(level, "[%lld.%03ld] %s%s%s", | ||
| 63 | + (long long)ts.tv_sec, ts.tv_nsec / 1000000, | ||
| 64 | message_tag ? message_tag : "", message_tag ? " " : "", | ||
| 65 | buf); | ||
| 66 | } | ||
| 67 | diff -Naur linuxptp-2.0.org/unicast_service.c linuxptp-2.0/unicast_service.c | ||
| 68 | --- linuxptp-2.0.org/unicast_service.c 2018-08-12 23:08:43.000000000 +0200 | ||
| 69 | +++ linuxptp-2.0/unicast_service.c 2020-05-29 21:36:23.170497415 +0200 | ||
| 70 | @@ -209,9 +209,9 @@ | ||
| 71 | tmo = now.tv_sec + req->durationField; | ||
| 72 | if (tmo > client->grant_tmo) { | ||
| 73 | client->grant_tmo = tmo; | ||
| 74 | - pr_debug("%s grant of 0x%x extended to %ld", | ||
| 75 | + pr_debug("%s grant of 0x%x extended to %lld", | ||
| 76 | pid2str(&client->portIdentity), | ||
| 77 | - client->message_types, tmo); | ||
| 78 | + client->message_types, (long long)tmo); | ||
| 79 | } | ||
| 80 | } | ||
| 81 | |||
| 82 | @@ -226,8 +226,8 @@ | ||
| 83 | interval = pqueue_peek(p->unicast_service->queue); | ||
| 84 | if (interval) { | ||
| 85 | tmo.it_value = interval->tmo; | ||
| 86 | - pr_debug("arming timer tmo={%ld,%ld}", | ||
| 87 | - interval->tmo.tv_sec, interval->tmo.tv_nsec); | ||
| 88 | + pr_debug("arming timer tmo={%lld,%ld}", | ||
| 89 | + (long long)interval->tmo.tv_sec, interval->tmo.tv_nsec); | ||
| 90 | } else { | ||
| 91 | pr_debug("stopping unicast service timer"); | ||
| 92 | } | ||
| 93 | @@ -499,8 +499,8 @@ | ||
| 94 | |||
| 95 | while ((interval = pqueue_peek(p->unicast_service->queue)) != NULL) { | ||
| 96 | |||
| 97 | - pr_debug("peek i={2^%d} tmo={%ld,%ld}", interval->log_period, | ||
| 98 | - interval->tmo.tv_sec, interval->tmo.tv_nsec); | ||
| 99 | + pr_debug("peek i={2^%d} tmo={%lld,%ld}", interval->log_period, | ||
| 100 | + (long long)interval->tmo.tv_sec, interval->tmo.tv_nsec); | ||
| 101 | |||
| 102 | if (timespec_compare(&now, &interval->tmo) >= 0) { | ||
| 103 | break; | ||
| 104 | @@ -519,8 +519,8 @@ | ||
| 105 | } | ||
| 106 | |||
| 107 | interval_increment(interval); | ||
| 108 | - pr_debug("next i={2^%d} tmo={%ld,%ld}", interval->log_period, | ||
| 109 | - interval->tmo.tv_sec, interval->tmo.tv_nsec); | ||
| 110 | + pr_debug("next i={2^%d} tmo={%lld,%ld}", interval->log_period, | ||
| 111 | + (long long)interval->tmo.tv_sec, interval->tmo.tv_nsec); | ||
| 112 | pqueue_insert(p->unicast_service->queue, interval); | ||
| 113 | } | ||
| 114 | |||
| 115 | diff -Naur linuxptp-2.0.org/unicast_client.c linuxptp-2.0/unicast_client.c | ||
| 116 | --- linuxptp-2.0.org/unicast_client.c 2018-08-12 23:08:43.000000000 +0200 | ||
| 117 | +++ linuxptp-2.0/unicast_client.c 2020-06-02 11:13:06.922997844 +0200 | ||
| 118 | @@ -216,7 +216,7 @@ | ||
| 119 | long duration) | ||
| 120 | { | ||
| 121 | struct timespec now; | ||
| 122 | - long tmo; | ||
| 123 | + time_t tmo; | ||
| 124 | |||
| 125 | if (clock_gettime(CLOCK_MONOTONIC, &now)) { | ||
| 126 | pr_err("clock_gettime failed: %m"); | ||
| 127 | @@ -226,7 +226,7 @@ | ||
| 128 | tmo = now.tv_sec + duration; | ||
| 129 | if (!master->renewal_tmo || tmo < master->renewal_tmo) { | ||
| 130 | master->renewal_tmo = tmo; | ||
| 131 | - pr_debug("port %d: renewal timeout at %ld", portnum(p), tmo); | ||
| 132 | + pr_debug("port %d: renewal timeout at %lld", portnum(p), (long long)tmo); | ||
| 133 | } | ||
| 134 | } | ||
| 135 | |||
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" | |||
| 5 | SRC_URI = "http://sourceforge.net/projects/linuxptp/files/v${PV}/linuxptp-${PV}.tgz \ | 5 | SRC_URI = "http://sourceforge.net/projects/linuxptp/files/v${PV}/linuxptp-${PV}.tgz \ |
| 6 | file://build-Allow-CC-and-prefix-to-be-overriden.patch \ | 6 | file://build-Allow-CC-and-prefix-to-be-overriden.patch \ |
| 7 | file://no-incdefs-using-host-headers.patch \ | 7 | file://no-incdefs-using-host-headers.patch \ |
| 8 | file://time_t_maybe_long_long.patch \ | ||
| 8 | " | 9 | " |
| 9 | 10 | ||
| 10 | SRC_URI[md5sum] = "d8bb7374943bb747db7786ac26f17f11" | 11 | SRC_URI[md5sum] = "d8bb7374943bb747db7786ac26f17f11" |
