odhcpd: fix compilation with musl 1.2.0
authorRosen Penev <rosenp@gmail.com>
Thu, 26 Mar 2020 23:07:12 +0000 (16:07 -0700)
committerHans Dedecker <dedeckeh@gmail.com>
Sat, 28 Mar 2020 08:19:37 +0000 (09:19 +0100)
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@gmail.com>
src/dhcpv6-ia.c
src/odhcpd.c

index 1a139458a4c45a6756f559aa1f0bb9262d90a1ea..b51649c19f153f7b62bbad7da95236e41a5fa30a 100644 (file)
@@ -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);
 
@@ -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) :
                                                                        (INFINITE_VALID(c->valid_until) ? -1 : 0)),
                                                                ntohl(c->addr));
 
index 4b8e5898d450bc661e0f4d29b48dfff1f35a101c..26094b1143c4ca18f785969d54648eaa0734b9d1 100644 (file)
@@ -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;
 }