udhcpc: get rid of client_data.fqdn field
function old new delta
attach_option 253 276 +23
udhcpc_main 2582 2588 +6
udhcpc6_main 2579 2571 -8
add_client_options 175 158 -17
udhcp_insert_new_option 169 138 -31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/3 up/down: 29/-56) Total: -27 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c
index 7929950..b325c41 100644
--- a/networking/udhcp/common.c
+++ b/networking/udhcp/common.c
@@ -424,7 +424,6 @@
void* FAST_FUNC udhcp_insert_new_option(
struct option_set **opt_list,
unsigned code,
- const void *buffer,
unsigned length,
bool dhcpv6)
{
@@ -434,17 +433,15 @@
log2("attaching option %02x to list", code);
new = xmalloc(sizeof(*new));
if (!dhcpv6) {
- new->data = xmalloc(length + OPT_DATA);
+ new->data = xzalloc(length + OPT_DATA);
new->data[OPT_CODE] = code;
new->data[OPT_LEN] = length;
- memcpy(new->data + OPT_DATA, buffer, length);
} else {
- new->data = xmalloc(length + D6_OPT_DATA);
+ new->data = xzalloc(length + D6_OPT_DATA);
new->data[D6_OPT_CODE] = code >> 8;
new->data[D6_OPT_CODE + 1] = code & 0xff;
new->data[D6_OPT_LEN] = length >> 8;
new->data[D6_OPT_LEN + 1] = length & 0xff;
- memcpy(new->data + D6_OPT_DATA, buffer, length);
}
curr = opt_list;
@@ -498,7 +495,11 @@
existing = udhcp_find_option(*opt_list, optflag->code);
if (!existing) {
/* make a new option */
- udhcp_insert_new_option(opt_list, optflag->code, buffer, length, dhcpv6);
+ uint8_t *p = udhcp_insert_new_option(opt_list, optflag->code, length, dhcpv6);
+ if (!dhcpv6)
+ memcpy(p + OPT_DATA, buffer, length);
+ else
+ memcpy(p + D6_OPT_DATA, buffer, length);
goto ret;
}