mirror of
https://github.com/openembedded/meta-openembedded.git
synced 2026-10-22 08:28:21 +00:00
ntp: Use time_t for the stime() argument
ntp_set_tod() passes a long to stime(), which fails to build on 32-bit targets with a 64-bit time_t, e.g. riscv32 with clang: libntp/machines.c:483:14: error: incompatible pointer types passing 'long *' to parameter of type 'const time_t *' Add a patch to use time_t unless the system declares stime() with a long (DECL_STIME_1), so the argument matches the prototype in use on every architecture. AI-Generated: Uses Claude Code Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
2 files changed
+43
No files matched your search
+42
@@ -0,0 +1,42 @@
|
||||
From: Khem Raj <khem.raj@oss.qualcomm.com>
|
||||
Date: Tue, 20 Oct 2026 21:30:00 -0700
|
||||
Subject: [PATCH] libntp: Use time_t for the stime() argument
|
||||
|
||||
ntp_set_tod() passes a long to stime(), which is declared as
|
||||
stime(const time_t *) everywhere except on systems where configure sets
|
||||
DECL_STIME_1 (stime(long *)). That only works when time_t and long have
|
||||
the same size. 32-bit targets with a 64-bit time_t, such as riscv32 or
|
||||
any 32-bit target built with _TIME_BITS=64, break:
|
||||
|
||||
libntp/machines.c:483:14: error: incompatible pointer types passing
|
||||
'long *' to parameter of type 'const time_t *' (aka 'const long long *')
|
||||
|
||||
Use time_t unless the system declares stime() with a long, so the
|
||||
argument always matches the prototype in use.
|
||||
|
||||
Upstream-Status: Submitted [https://github.com/ntp-project/ntp/pull/35]
|
||||
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
|
||||
---
|
||||
libntp/machines.c | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
--- a/libntp/machines.c
|
||||
+++ b/libntp/machines.c
|
||||
@@ -477,7 +477,17 @@
|
||||
#endif /* HAVE_SETTIMEOFDAY */
|
||||
#ifdef HAVE_STIME
|
||||
if (rc && (SET_TOD_STIME == tod || !tod)) {
|
||||
+ /*
|
||||
+ * stime() takes a time_t pointer except on systems
|
||||
+ * that declare it with a long (DECL_STIME_1). time_t
|
||||
+ * may be wider than long, e.g. on 32-bit targets with
|
||||
+ * 64-bit time_t, so match the prototype in use.
|
||||
+ */
|
||||
+#ifdef DECL_STIME_1
|
||||
long tp = tvp->tv_sec;
|
||||
+#else
|
||||
+ time_t tp = tvp->tv_sec;
|
||||
+#endif
|
||||
|
||||
errno = 0;
|
||||
rc = stime(&tp); /* lie as bad as SysVR4 */
|
||||
@@ -21,6 +21,7 @@ SRC_URI = "http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-${PV}.tar.g
|
||||
file://0001-colcomp-sntp-libpkgver-colcomp.c-Convert-K-R-functio.patch \
|
||||
file://0001-Makefile.am-Don-t-build-deprecated-ntpdate.patch \
|
||||
file://0001-ntp_crypto-use-the-ASN1_STRING-accessors.patch \
|
||||
file://0001-libntp-Use-time_t-for-the-stime-argument.patch \
|
||||
file://ntpd \
|
||||
file://ntp.conf \
|
||||
file://ntpd.service \
|
||||
|
||||
Reference in new issue
Block a user