[OpenWrt-Devel] [PATCH] odhcpd: fix compilation with musl 1.2.0
Hans Dedecker
dedeckeh at gmail.com
Sat Mar 28 04:23:57 EDT 2020
Hi,
On Fri, Mar 27, 2020 at 12:07 AM Rosen Penev <rosenp at gmail.com> wrote:
>
> SYS_clock_gettime is gone with musl 1.2.0. Switched to the function.
>
> Also fixed two format strings that fail as time_t is 64-bit with 1.2.0.
>
> Signed-off-by: Rosen Penev <rosenp at gmail.com>
> ---
> src/dhcpv6-ia.c | 8 ++++----
> src/odhcpd.c | 2 +-
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c
> index 1a13945..9f5c77e 100644
> --- a/src/dhcpv6-ia.c
> +++ b/src/dhcpv6-ia.c
> @@ -338,12 +338,12 @@ void dhcpv6_ia_write_statefile(void)
> odhcpd_hexlify(duidbuf, ctxt.c->clid_data, ctxt.c->clid_len);
>
> /* iface DUID iaid hostname lifetime assigned length [addrs...] */
> - ctxt.buf_idx = snprintf(ctxt.buf, ctxt.buf_len, "# %s %s %x %s%s %ld %x %u ",
> + ctxt.buf_idx = snprintf(ctxt.buf, ctxt.buf_len, "# %s %s %x %s%s " PRId64 " %x %u ",
> ctxt.iface->ifname, duidbuf, ntohl(ctxt.c->iaid),
> (ctxt.c->flags & OAF_BROKEN_HOSTNAME) ? "broken\\x20" : "",
> (ctxt.c->hostname ? ctxt.c->hostname : "-"),
> (ctxt.c->valid_until > now ?
> - (ctxt.c->valid_until - now + wall_time) :
> + (int64_t)(ctxt.c->valid_until - now + wall_time) :
> (INFINITE_VALID(ctxt.c->valid_until) ? -1 : 0)),
> ctxt.c->assigned, (unsigned)ctxt.c->length);
This fails for me :
/home/dedeckeh/OpenWrt_staging/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/odhcpd-full/odhcpd-2020-03-14-6594c6b1/src/dhcpv6-ia.c:
In function 'dhcpv6_ia_write_statefile':
/home/dedeckeh/OpenWrt_staging/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/odhcpd-full/odhcpd-2020-03-14-6594c6b1/src/dhcpv6-ia.c:341:54:
error: format '%x' expects argument of type 'unsigned int', but
argument 9 has type 'long long int' [-Werror=format=]
ctxt.buf_idx = snprintf(ctxt.buf, ctxt.buf_len, "# %s %s %x %s%s
" PRId64 " %x %u ",
^~~~~~~~~~~~~~~~~~
/home/dedeckeh/OpenWrt_staging/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/odhcpd-full/odhcpd-2020-03-14-6594c6b1/src/dhcpv6-ia.c:345:9:
(ctxt.c->valid_until > now ?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(int64_t)(ctxt.c->valid_until - now + wall_time) :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(INFINITE_VALID(ctxt.c->valid_until) ? -1 : 0)),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dedeckeh/OpenWrt_staging/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/odhcpd-full/odhcpd-2020-03-14-6594c6b1/src/dhcpv6-ia.c:341:83:
note: format string is defined here
ctxt.buf_idx = snprintf(ctxt.buf, ctxt.buf_len, "# %s %s %x %s%s
" PRId64 " %x %u ",
~^
%llx
/home/dedeckeh/OpenWrt_staging/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/odhcpd-full/odhcpd-2020-03-14-6594c6b1/src/dhcpv6-ia.c:341:54:
error: too many arguments for format [-Werror=format-extra-args]
ctxt.buf_idx = snprintf(ctxt.buf, ctxt.buf_len, "# %s %s %x %s%s
" PRId64 " %x %u ",
>
> @@ -368,12 +368,12 @@ void dhcpv6_ia_write_statefile(void)
> odhcpd_hexlify(duidbuf, c->hwaddr, sizeof(c->hwaddr));
>
> /* iface DUID iaid hostname lifetime assigned length [addrs...] */
> - ctxt.buf_idx = snprintf(ctxt.buf, ctxt.buf_len, "# %s %s ipv4 %s%s %ld %x 32 ",
> + ctxt.buf_idx = snprintf(ctxt.buf, ctxt.buf_len, "# %s %s ipv4 %s%s " PRId64 " %x 32 ",
> ctxt.iface->ifname, duidbuf,
> (c->flags & OAF_BROKEN_HOSTNAME) ? "broken\\x20" : "",
> (c->hostname ? c->hostname : "-"),
> (c->valid_until > now ?
> - (c->valid_until - now + wall_time) :
> + (int64_t)(c->valid_until - now + wall_time) :
Same here :
/home/dedeckeh/OpenWrt_staging/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/odhcpd-full/odhcpd-2020-03-14-6594c6b1/src/dhcpv6-ia.c:371:54:
error: format '%x' expects argument of type 'unsigned int', but
argument 8 has type 'long long int' [-Werror=format=]
ctxt.buf_idx = snprintf(ctxt.buf, ctxt.buf_len, "# %s %s ipv4
%s%s " PRId64 " %x 32 ",
^~~~~~~~~~~~~~~~~~~~
/home/dedeckeh/OpenWrt_staging/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/odhcpd-full/odhcpd-2020-03-14-6594c6b1/src/dhcpv6-ia.c:375:9:
(c->valid_until > now ?
~~~~~~~~~~~~~~~~~~~~~~~
(int64_t)(c->valid_until - now + wall_time) :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(INFINITE_VALID(c->valid_until) ? -1 : 0)),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/dedeckeh/OpenWrt_staging/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/odhcpd-full/odhcpd-2020-03-14-6594c6b1/src/dhcpv6-ia.c:371:85:
note: format string is defined here
ctxt.buf_idx = snprintf(ctxt.buf, ctxt.buf_len, "# %s %s ipv4
%s%s " PRId64 " %x 32 ",
~^
%llx
/home/dedeckeh/OpenWrt_staging/build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/odhcpd-full/odhcpd-2020-03-14-6594c6b1/src/dhcpv6-ia.c:371:54:
error: too many arguments for format [-Werror=format-extra-args]
ctxt.buf_idx = snprintf(ctxt.buf, ctxt.buf_len, "# %s %s ipv4
%s%s " PRId64 " %x 32 ",
^~~~~~~~~~~~~~~~~~~~
Has this been compile tested ?
Hans
> (INFINITE_VALID(c->valid_until) ? -1 : 0)),
> ntohl(c->addr));
>
> diff --git a/src/odhcpd.c b/src/odhcpd.c
> index 4b8e589..26094b1 100644
> --- a/src/odhcpd.c
> +++ b/src/odhcpd.c
> @@ -440,7 +440,7 @@ int odhcpd_urandom(void *data, size_t len)
> time_t odhcpd_time(void)
> {
> struct timespec ts;
> - syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &ts);
> + clock_gettime(CLOCK_MONOTONIC, &ts);
> return ts.tv_sec;
> }
>
> --
> 2.25.1
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list