diff options
author | Rob Landley | 2006-05-21 18:30:35 +0000 |
---|---|---|
committer | Rob Landley | 2006-05-21 18:30:35 +0000 |
commit | 9ffd42317b5a53c2236268808e34c90601f286c1 (patch) | |
tree | b126ca6ff7d2db91fa3525c6e5d3978932137fa3 /networking | |
parent | c020f5f518714af603488c7d9e6cc72543fabc49 (diff) | |
download | busybox-9ffd42317b5a53c2236268808e34c90601f286c1.zip busybox-9ffd42317b5a53c2236268808e34c90601f286c1.tar.gz |
Minor cleanups: Convert a few calloc() calls to xzalloc, remove unnecessary
memset, collate variable declarations...
Diffstat (limited to 'networking')
-rw-r--r-- | networking/udhcp/dhcpd.c | 24 | ||||
-rw-r--r-- | networking/udhcp/script.c | 2 |
2 files changed, 7 insertions, 19 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index 0dfc0b5..28acb6b 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c @@ -52,30 +52,18 @@ struct dhcpOfferedAddr *leases; struct server_config_t server_config; -#ifdef COMBINED_BINARY int udhcpd_main(int argc, char *argv[]) -#else -int main(int argc, char *argv[]) -#endif { fd_set rfds; struct timeval tv; - int server_socket = -1; - int bytes, retval; + int server_socket = -1, bytes, retval, max_sock; struct dhcpMessage packet; - uint8_t *state; - uint8_t *server_id, *requested; - uint32_t server_id_align, requested_align; - unsigned long timeout_end; + uint8_t *state, *server_id, *requested; + uint32_t server_id_align, requested_align, static_lease_ip; + unsigned long timeout_end, num_ips; struct option_set *option; - struct dhcpOfferedAddr *lease; - struct dhcpOfferedAddr static_lease; - int max_sock; - unsigned long num_ips; - - uint32_t static_lease_ip; + struct dhcpOfferedAddr *lease, static_lease; - memset(&server_config, 0, sizeof(struct server_config_t)); read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]); /* Start the log, sanitize fd's, and write a pid file */ @@ -96,7 +84,7 @@ int main(int argc, char *argv[]) server_config.max_leases = num_ips; } - leases = xcalloc(server_config.max_leases, sizeof(struct dhcpOfferedAddr)); + leases = xzalloc(server_config.max_leases * sizeof(struct dhcpOfferedAddr)); read_leases(server_config.lease_file); if (read_interface(server_config.interface, &server_config.ifindex, diff --git a/networking/udhcp/script.c b/networking/udhcp/script.c index b6b0e0d..2a47321 100644 --- a/networking/udhcp/script.c +++ b/networking/udhcp/script.c @@ -159,7 +159,7 @@ static char **fill_envp(struct dhcpMessage *packet) if (!(over & SNAME_FIELD) && packet->sname[0]) num_options++; } - envp = xcalloc(sizeof(char *), num_options + 5); + envp = xzalloc(sizeof(char *) * (num_options + 5)); j = 0; asprintf(&envp[j++], "interface=%s", client_config.interface); asprintf(&envp[j++], "%s=%s", "PATH", |