From ebe0b83db6a98792229f25b020ea146efe874702 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20H=C3=A4rdeman?= Date: Sat, 8 Nov 2025 16:17:56 +0100 Subject: [PATCH] statefiles: correct some comments/variable names MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Correct some comments and variable names in statefiles_write_state[46]. Signed-off-by: David Härdeman Link: https://github.com/openwrt/odhcpd/pull/302 Signed-off-by: Álvaro Fernández Rojas --- src/statefiles.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/statefiles.c b/src/statefiles.c index 44151c9..c392e34 100644 --- a/src/statefiles.c +++ b/src/statefiles.c @@ -179,8 +179,9 @@ static void statefiles_write_state6(struct write_ctxt *ctxt, struct dhcpv6_lease odhcpd_hexlify(duidbuf, lease->clid_data, lease->clid_len); - /* iface DUID iaid hostname lifetime assigned_host_id length [addrs...] */ - ctxt->buf_idx = snprintf(ctxt->buf, ctxt->buf_len, "# %s %s %x %s%s %"PRId64" ", + /* # [ ...] */ + ctxt->buf_idx = snprintf(ctxt->buf, ctxt->buf_len, + "# %s %s %x %s%s %" PRId64 " ", ctxt->iface->ifname, duidbuf, ntohl(lease->iaid), (lease->flags & OAF_BROKEN_HOSTNAME) ? "broken\\x20" : "", (lease->hostname ? lease->hostname : "-"), @@ -191,7 +192,7 @@ static void statefiles_write_state6(struct write_ctxt *ctxt, struct dhcpv6_lease if (lease->flags & OAF_DHCPV6_NA) ctxt->buf_idx += snprintf(ctxt->buf + ctxt->buf_idx, ctxt->buf_len - ctxt->buf_idx, - "%" PRIx64" %" PRIu8 " ", + "%" PRIx64 " %" PRIu8 " ", lease->assigned_host_id, lease->length); else ctxt->buf_idx += snprintf(ctxt->buf + ctxt->buf_idx, @@ -208,16 +209,17 @@ static void statefiles_write_state6(struct write_ctxt *ctxt, struct dhcpv6_lease static void statefiles_write_state4(struct write_ctxt *ctxt, struct dhcpv4_lease *lease) { - char ipbuf[INET6_ADDRSTRLEN]; - char duidbuf[16]; + char hexhwaddr[sizeof(lease->hwaddr) * 2 + 1]; struct in_addr addr = { .s_addr = lease->addr }; + char ipbuf[INET6_ADDRSTRLEN]; - odhcpd_hexlify(duidbuf, lease->hwaddr, sizeof(lease->hwaddr)); + odhcpd_hexlify(hexhwaddr, lease->hwaddr, sizeof(lease->hwaddr)); inet_ntop(AF_INET, &addr, ipbuf, sizeof(ipbuf)); - /* iface DUID iaid hostname lifetime assigned length [addrs...] */ - ctxt->buf_idx = snprintf(ctxt->buf, ctxt->buf_len, "# %s %s ipv4 %s%s %"PRId64" %x 32 %s/32\n", - ctxt->iface->ifname, duidbuf, + /* # "ipv4" "32" "/32" */ + ctxt->buf_idx = snprintf(ctxt->buf, ctxt->buf_len, + "# %s %s ipv4 %s%s %" PRId64 " %x 32 %s/32\n", + ctxt->iface->ifname, hexhwaddr, (lease->flags & OAF_BROKEN_HOSTNAME) ? "broken\\x20" : "", (lease->hostname ? lease->hostname : "-"), (lease->valid_until > ctxt->now ? -- 2.30.2