udhcpc: add -o "do not request options by default" switch
(by L. Gabriel Somlo <somlo AT cmu.edu>)
function old new delta
udhcpc_main 2513 2554 +41
static.udhcpc_longopts 226 247 +21
add_param_req_option 119 132 +13
packed_usage 23952 23964 +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 87/0) Total: 87 bytes
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index 6a93bd0..043a95b 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -396,6 +396,7 @@
close(fp);
if (server_config.notify_file) {
+// TODO: vfork-based child creation
char *cmd = xasprintf("%s %s", server_config.notify_file, server_config.lease_file);
system(cmd);
free(cmd);
@@ -406,7 +407,7 @@
void read_leases(const char *file)
{
int fp;
- unsigned int i = 0;
+ unsigned i;
struct dhcpOfferedAddr lease;
fp = open_or_warn(file, O_RDONLY);
@@ -414,6 +415,7 @@
return;
}
+ i = 0;
while (i < server_config.max_leases
&& full_read(fp, &lease, sizeof(lease)) == sizeof(lease)
) {
@@ -422,7 +424,7 @@
if (y >= server_config.start_ip && y <= server_config.end_ip) {
lease.expires = ntohl(lease.expires);
if (!server_config.remaining)
- lease.expires -= time(0);
+ lease.expires -= time(NULL);
if (!(add_lease(lease.chaddr, lease.yiaddr, lease.expires))) {
bb_error_msg("too many leases while loading %s", file);
break;