From e04b2e87d65c23334f5479baa358dd500f42b9c3 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 20 Oct 2026 21:28:33 -0700 Subject: [PATCH] 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 --- ...tp-Use-time_t-for-the-stime-argument.patch | 42 +++++++++++++++++++ .../recipes-support/ntp/ntp_4.2.8p18.bb | 1 + 2 files changed, 43 insertions(+) create mode 100644 meta-networking/recipes-support/ntp/ntp/0001-libntp-Use-time_t-for-the-stime-argument.patch diff --git a/meta-networking/recipes-support/ntp/ntp/0001-libntp-Use-time_t-for-the-stime-argument.patch b/meta-networking/recipes-support/ntp/ntp/0001-libntp-Use-time_t-for-the-stime-argument.patch new file mode 100644 index 0000000000..0779663159 --- /dev/null +++ b/meta-networking/recipes-support/ntp/ntp/0001-libntp-Use-time_t-for-the-stime-argument.patch @@ -0,0 +1,42 @@ +From: Khem Raj +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 +--- + 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 */ diff --git a/meta-networking/recipes-support/ntp/ntp_4.2.8p18.bb b/meta-networking/recipes-support/ntp/ntp_4.2.8p18.bb index 8479b6ce12..6fd5e528bf 100644 --- a/meta-networking/recipes-support/ntp/ntp_4.2.8p18.bb +++ b/meta-networking/recipes-support/ntp/ntp_4.2.8p18.bb @@ -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 \