Commit 28868515 authored by Shane Kerr's avatar Shane Kerr

Code cleanup to remove warnings from "gcc -Wall".

See RT ticket #16988 for more.
parent 763cba6b
......@@ -55,12 +55,12 @@ suggested fixes to <dhcp-users@isc.org>.
- Fixed file descriptor leak on listen failure. Thanks to Tom Clark.
Changes since 4.0.0a2
- Bug in server configuration parser caused server to get stuck on
startup for certain bad pool declarations. Thanks to Guillaume
Knispel for the bug report and fix.
- Code cleaned to remove warnings reported by "gcc -Wall".
Changes since 4.0.0a1
- Bug in octal parsing fixed. Thanks to Bernd Fuhrmann for the report
......
......@@ -32,16 +32,9 @@
* ``http://www.nominum.com''.
*/
#ifndef lint
static char copyright[] =
"$Id: clparse.c,v 1.71 2007/05/19 19:16:23 dhankins Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
#include <errno.h>
static TIME parsed_time;
struct client_config top_level_config;
u_int32_t default_requested_options [] = {
......@@ -57,8 +50,10 @@ u_int32_t default_requested_options [] = {
static void parse_client_default_duid(struct parse *cfile);
static void parse_client6_lease_statement(struct parse *cfile);
#ifdef DHCPv6
static struct dhc6_ia *parse_client6_ia_statement(struct parse *cfile);
static struct dhc6_addr *parse_client6_iaaddr_statement(struct parse *cfile);
#endif /* DHCPv6 */
/* client-conf-file :== client-declarations END_OF_FILE
client-declarations :== <nil>
......@@ -68,7 +63,6 @@ static struct dhc6_addr *parse_client6_iaaddr_statement(struct parse *cfile);
isc_result_t read_client_conf ()
{
struct client_config *config;
struct client_state *state;
struct interface_info *ip;
isc_result_t status;
......@@ -258,11 +252,9 @@ void parse_client_statement (cfile, ip, config)
int token;
const char *val;
struct option *option = NULL;
struct executable_statement *stmt, **p;
enum statement_op op;
struct executable_statement *stmt;
int lose;
char *name;
struct data_string key_id;
enum policy policy;
int known;
int tmp, i;
......@@ -988,11 +980,9 @@ void parse_client_lease_declaration (cfile, lease, ipp, clientp)
{
int token;
const char *val;
char *t, *n;
struct interface_info *ip;
struct option_cache *oc;
struct client_state *client = (struct client_state *)0;
struct data_string key_id;
switch (next_token (&val, (unsigned *)0, cfile)) {
case KEY:
......@@ -1142,6 +1132,10 @@ parse_client_default_duid(struct parse *cfile)
static void
parse_client6_lease_statement(struct parse *cfile)
{
#if !defined(DHCPv6)
parse_warn(cfile, "No DHCPv6 support.");
skip_to_semi(cfile);
#else /* defined(DHCPv6) */
struct option_cache *oc = NULL;
struct dhc6_lease *lease;
struct dhc6_ia **ia;
......@@ -1152,10 +1146,6 @@ parse_client6_lease_statement(struct parse *cfile)
unsigned len;
int token, has_ia, no_semi, has_name;
#if !defined(DHCPv6)
parse_warn(cfile, "No DHCPv6 support.");
skip_to_semi(cfile);
#else /* defined(DHCPv6) */
token = next_token(NULL, NULL, cfile);
if (token != LBRACE) {
parse_warn(cfile, "Expecting open curly brace.");
......@@ -1354,6 +1344,7 @@ parse_client6_lease_statement(struct parse *cfile)
/* Parse an ia_na object from the client lease.
*/
#ifdef DHCPv6
static struct dhc6_ia *
parse_client6_ia_statement(struct parse *cfile)
{
......@@ -1362,7 +1353,6 @@ parse_client6_ia_statement(struct parse *cfile)
struct dhc6_ia *ia;
struct dhc6_addr **addr;
const char *val;
unsigned len;
int token, no_semi;
ia = dmalloc(sizeof(*ia), MDL);
......@@ -1486,8 +1476,10 @@ parse_client6_ia_statement(struct parse *cfile)
return ia;
}
#endif /* DHCPv6 */
/* Parse an iaaddr {} structure. */
#ifdef DHCPv6
static struct dhc6_addr *
parse_client6_iaaddr_statement(struct parse *cfile)
{
......@@ -1592,6 +1584,7 @@ parse_client6_iaaddr_statement(struct parse *cfile)
return addr;
}
#endif /* DHCPv6 */
void parse_string_list (cfile, lp, multiple)
struct parse *cfile;
......@@ -1712,12 +1705,6 @@ int parse_allow_deny (oc, cfile, flag)
struct parse *cfile;
int flag;
{
enum dhcp_token token;
const char *val;
unsigned char rf = flag;
struct expression *data = (struct expression *)0;
int status;
parse_warn (cfile, "allow/deny/ignore not permitted here.");
skip_to_semi (cfile);
return 0;
......
......@@ -22,11 +22,6 @@
* http://www.isc.org/
*/
#ifndef lint
static char ocopyright[] =
"$Id: dhc6.c,v 1.6 2007/06/06 22:57:31 each Exp $ Copyright (c) 2006-2007 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
#ifdef DHCPv6
......@@ -906,10 +901,9 @@ do_init6(void *input)
struct data_string ds;
struct data_string ia;
struct data_string addr;
struct option_cache *oc;
TIME elapsed;
u_int32_t t1, t2;
int idx, len, send_ret, code;
int idx, len, send_ret;
client = input;
......@@ -998,7 +992,7 @@ do_init6(void *input)
if ((client->active_lease != NULL) &&
((old_ia = find_ia(client->active_lease->bindings,
ia.data)) != NULL)) {
(char *)ia.data)) != NULL)) {
/* For each address in the old IA, request a binding. */
memset(&addr, 0, sizeof(addr));
for (old_addr = old_ia->addrs ; old_addr != NULL ;
......@@ -1071,11 +1065,7 @@ void
do_confirm6(void *input)
{
struct client_state *client;
struct dhc6_ia *ia;
struct dhc6_addr *addr;
struct data_string ds;
struct data_string ia_data;
struct data_string addr_data;
int send_ret;
TIME elapsed;
......@@ -1175,8 +1165,6 @@ do_confirm6(void *input)
void
start_release6(struct client_state *client)
{
struct data_string packet;
/* Cancel any pending transmissions */
cancel_timeout(do_confirm6, client);
cancel_timeout(do_select6, client);
......@@ -1214,11 +1202,7 @@ do_release6(void *input)
{
struct sockaddr_in6 unicast, *dest_addr = &DHCPv6DestAddr;
struct client_state *client;
struct dhc6_ia *ia;
struct dhc6_addr *addr;
struct data_string ds;
struct data_string ia_data;
struct data_string addr_data;
struct option_cache *oc;
struct dhc6_lease *lease;
int send_ret;
......@@ -1336,7 +1320,7 @@ status_log(int code, char *scope, const char *additional, int len)
if (len > 0)
log_info("%s status code %s: %s", scope, msg,
print_hex_1(len, additional, 50));
print_hex_1(len, (unsigned char *)additional, 50));
else
log_info("%s status code %s.", scope, msg);
}
......@@ -1406,7 +1390,7 @@ dhc6_check_status(isc_result_t rval, struct option_state *options,
status = dhc6_get_status_code(options, code, &msg);
if (status == ISC_R_SUCCESS) {
status_log(*code, scope, msg.data, msg.len);
status_log(*code, scope, (char *)msg.data, msg.len);
data_string_forget(&msg, MDL);
if (*code != STATUS_Success)
......@@ -1554,7 +1538,6 @@ dhc6_withdraw_lease(struct client_state *client)
{
struct dhc6_ia *ia;
struct dhc6_addr *addr;
TIME future;
if ((client == NULL) || (client->active_lease == NULL))
return;
......@@ -1671,7 +1654,7 @@ dhc6_check_reply(struct client_state *client, struct dhc6_lease *new)
isc_boolean_t (*action)(struct client_state *, isc_result_t, unsigned);
struct dhc6_ia *ia;
struct dhc6_addr *addr;
isc_result_t rval = ISC_R_SUCCESS, status;
isc_result_t rval = ISC_R_SUCCESS;
unsigned code;
int nscore, sscore;
......@@ -1776,7 +1759,7 @@ dhc6_check_reply(struct client_state *client, struct dhc6_lease *new)
void
init_handler(struct packet *packet, struct client_state *client)
{
struct dhc6_lease *lease, **idx;
struct dhc6_lease *lease;
/* In INIT state, we send solicits, we only expect to get
* advertises (we don't support rapid commit yet).
......@@ -1946,7 +1929,6 @@ void
start_selecting6(struct client_state *client)
{
struct dhc6_lease *lease;
struct data_string packet;
if (client->advertised_leases == NULL) {
log_error("Can not enter DHCPv6 SELECTING state with no "
......@@ -1990,13 +1972,10 @@ do_select6(void *input)
{
struct client_state *client;
struct dhc6_lease *lease;
struct dhc6_ia *ia;
struct dhc6_addr *addr;
struct option_cache *oc;
struct data_string ds;
TIME elapsed, t1, t2;
TIME elapsed;
int abort = ISC_FALSE;
int code, send_ret;
int send_ret;
client = input;
......@@ -2261,7 +2240,7 @@ dhc6_add_ia(struct client_state *client, struct data_string *packet,
void
reply_handler(struct packet *packet, struct client_state *client)
{
struct dhc6_lease *lease, *old;
struct dhc6_lease *lease;
isc_result_t check_status;
if (packet->dhcpv6_msg_type != DHCPV6_REPLY)
......@@ -2621,7 +2600,7 @@ dhc6_merge_lease(struct dhc6_lease *src, struct dhc6_lease *dst)
return;
for (sia = src->bindings ; sia != NULL ; sia = sia->next) {
dia = find_ia(dst->bindings, sia->iaid);
dia = find_ia(dst->bindings, (char *)sia->iaid);
if (dia == NULL) {
tia = dhc6_dup_ia(sia, MDL);
......@@ -2720,7 +2699,7 @@ start_bound(struct client_state *client)
oldia = NULL;
for (ia = lease->bindings ; ia != NULL ; ia = ia->next) {
if (old != NULL)
oldia = find_ia(old->bindings, ia->iaid);
oldia = find_ia(old->bindings, (char *)ia->iaid);
else
oldia = NULL;
......@@ -2843,7 +2822,7 @@ do_refresh6(void *input)
struct data_string ds;
struct client_state *client;
struct dhc6_lease *lease;
TIME elapsed, next;
TIME elapsed;
int send_ret;
client = (struct client_state *)input;
......@@ -3137,7 +3116,6 @@ static void
make_client6_options(struct client_state *client, struct option_state **op,
struct dhc6_lease *lease, u_int8_t message)
{
int code;
struct option_cache *oc;
if ((op == NULL) || (client == NULL))
......
......@@ -30,11 +30,6 @@
* fault and not Elliot's.
*/
#ifndef lint
static char ocopyright[] =
"$Id: dhclient.c,v 1.154 2007/06/15 15:02:05 shane Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
#include <syslog.h>
#include <signal.h>
......@@ -99,7 +94,6 @@ main(int argc, char **argv) {
omapi_object_t *listener;
isc_result_t result;
int persist = 0;
int omapi_port;
int no_dhclient_conf = 0;
int no_dhclient_db = 0;
int no_dhclient_pid = 0;
......@@ -451,8 +445,6 @@ main(int argc, char **argv) {
/* Start a configuration state machine for each interface. */
#ifdef DHCPv6
if (local_family == AF_INET6) {
struct option_cache *oc;
/* Establish a default DUID. This may be moved to the
* DHCPv4 area later.
*/
......@@ -721,7 +713,6 @@ void state_selecting (cpp)
picked = lp;
picked -> next = (struct client_lease *)0;
} else {
freeit:
destroy_client_lease (lp);
}
}
......@@ -780,7 +771,6 @@ void dhcpack (packet)
struct client_lease *lease;
struct option_cache *oc;
struct data_string ds;
int i;
/* If we're not receptive to an offer right now, or if the offer
has an unrecognizable transaction id, then just drop it. */
......@@ -932,8 +922,6 @@ void dhcpack (packet)
void bind_lease (client)
struct client_state *client;
{
struct interface_info *ip = client -> interface;
/* Remember the medium. */
client -> new -> medium = client -> medium;
......@@ -996,7 +984,6 @@ void state_bound (cpp)
void *cpp;
{
struct client_state *client = cpp;
int i;
struct option_cache *oc;
struct data_string ds;
......@@ -1223,8 +1210,6 @@ void dhcpoffer (packet)
int i;
int stop_selecting;
const char *name = packet -> packet_type ? "DHCPOFFER" : "BOOTREPLY";
struct iaddrlist *ap;
struct option_cache *oc;
char obuf [1024];
#ifdef DEBUG_PACKET
......@@ -2069,7 +2054,6 @@ void make_discover (client, lease)
struct client_lease *lease;
{
unsigned char discover = DHCPDISCOVER;
int i;
struct option_state *options = (struct option_state *)0;
memset (&client -> packet, 0, sizeof (client -> packet));
......@@ -2133,9 +2117,6 @@ void make_request (client, lease)
struct client_lease *lease;
{
unsigned char request = DHCPREQUEST;
int i, j;
unsigned char *tmp, *digest;
unsigned char *old_digest_loc;
struct option_cache *oc;
memset (&client -> packet, 0, sizeof (client -> packet));
......@@ -2223,7 +2204,6 @@ void make_decline (client, lease)
struct client_lease *lease;
{
unsigned char decline = DHCPDECLINE;
int i;
struct option_cache *oc;
struct option_state *options = (struct option_state *)0;
......@@ -2279,7 +2259,6 @@ void make_release (client, lease)
struct client_lease *lease;
{
unsigned char request = DHCPRELEASE;
int i;
struct option_cache *oc;
struct option_state *options = (struct option_state *)0;
......@@ -2336,8 +2315,6 @@ void make_release (client, lease)
void destroy_client_lease (lease)
struct client_lease *lease;
{
int i;
if (lease -> server_name)
dfree (lease -> server_name, MDL);
if (lease -> filename)
......@@ -2415,8 +2392,6 @@ void write_lease_option (struct option_cache *oc,
{
const char *name, *dot;
struct data_string ds;
int status;
struct client_state *client;
char *preamble = stuff;
memset (&ds, 0, sizeof ds);
......@@ -2595,11 +2570,7 @@ int write_client_lease (client, lease, rewrite, makesure)
int rewrite;
int makesure;
{
int i;
struct tm *t;
struct option_cache *oc;
struct data_string ds;
pair *hash;
int errors = 0;
char *s;
const char *tval;
......@@ -2803,8 +2774,6 @@ void script_write_params (client, prefix, lease)
int i;
struct data_string data;
struct option_cache *oc;
pair *hash;
char *s, *t;
struct envadd_state es;
es.client = client;
......@@ -2881,11 +2850,9 @@ void script_write_params (client, prefix, lease)
int script_go (client)
struct client_state *client;
{
int rval;
char *scriptName;
char *argv [2];
char **envp;
char *epp [3];
char reason [] = "REASON=NBI";
static char client_path [] = CLIENT_PATH;
int i;
......@@ -2966,7 +2933,7 @@ void client_envadd (struct client_state *client,
{
char spbuf [1024];
char *s;
unsigned len, i;
unsigned len;
struct string_list *val;
va_list list;
......@@ -3423,8 +3390,7 @@ void client_dns_update_timeout (void *cp)
isc_result_t client_dns_update (struct client_state *client, int addp,
int ttl, struct iaddr *address)
{
struct data_string ddns_fqdn, ddns_fwd_name,
ddns_dhcid, client_identifier;
struct data_string ddns_fwd_name, ddns_dhcid, client_identifier;
struct option_cache *oc;
int ignorep;
int result;
......
......@@ -32,11 +32,6 @@
* ``http://www.nominum.com''.
*/
#ifndef lint
static char copyright[] =
"$Id: alloc.c,v 1.60 2007/05/19 19:16:23 dhankins Exp $ Copyright (c) 2004-2007 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
#include <omapip/omapip_p.h>
......@@ -48,7 +43,6 @@ int option_chain_head_allocate (ptr, file, line)
const char *file;
int line;
{
int size;
struct option_chain_head *h;
if (!ptr) {
......@@ -109,7 +103,6 @@ int option_chain_head_dereference (ptr, file, line)
const char *file;
int line;
{
int i;
struct option_chain_head *option_chain_head;
pair car, cdr;
......@@ -161,7 +154,6 @@ int group_allocate (ptr, file, line)
const char *file;
int line;
{
int size;
struct group *g;
if (!ptr) {
......@@ -222,7 +214,6 @@ int group_dereference (ptr, file, line)
const char *file;
int line;
{
int i;
struct group *group;
if (!ptr || !*ptr) {
......@@ -744,8 +735,6 @@ int buffer_dereference (ptr, file, line)
const char *file;
int line;
{
struct buffer *bp;
if (!ptr) {
log_error ("%s(%d): null pointer", file, line);
#if defined (POINTER_DEBUG)
......@@ -833,8 +822,6 @@ int dns_host_entry_dereference (ptr, file, line)
const char *file;
int line;
{
struct dns_host_entry *bp;
if (!ptr || !*ptr) {
log_error ("%s(%d): null pointer", file, line);
#if defined (POINTER_DEBUG)
......@@ -1037,7 +1024,6 @@ int packet_allocate (ptr, file, line)
const char *file;
int line;
{
int size;
struct packet *p;
if (!ptr) {
......@@ -1157,7 +1143,6 @@ int dns_zone_allocate (ptr, file, line)
const char *file;
int line;
{
int size;
struct dns_zone *d;
if (!ptr) {
......
......@@ -32,11 +32,6 @@
* managed to get me to integrate them.
*/
#ifndef lint
static char copyright[] =
"$Id: bpf.c,v 1.57 2007/05/19 23:39:51 dhankins Exp $ Copyright (c) 2004,2007 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
#if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE) \
|| defined (USE_LPF_RECEIVE)
......
......@@ -39,11 +39,6 @@
useful, you have Brian and BCtel to thank. Any limitations in the
code are a result of mistakes on my part. -- Ted Lemon */
#ifndef lint
static char copyright[] =
"$Id: comapi.c,v 1.12 2006/02/24 23:16:28 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
#include <omapip/omapip_p.h>
......@@ -143,7 +138,6 @@ isc_result_t dhcp_group_set_value (omapi_object_t *h,
{
struct group_object *group;
isc_result_t status;
int foo;
if (h -> type != dhcp_type_group)
return ISC_R_INVALIDARG;
......@@ -217,7 +211,6 @@ isc_result_t dhcp_group_get_value (omapi_object_t *h, omapi_object_t *id,
{
struct group_object *group;
isc_result_t status;
struct data_string ip_addrs;
if (h -> type != dhcp_type_group)
return ISC_R_INVALIDARG;
......@@ -240,7 +233,6 @@ isc_result_t dhcp_group_get_value (omapi_object_t *h, omapi_object_t *id,
isc_result_t dhcp_group_destroy (omapi_object_t *h, const char *file, int line)
{
struct group_object *group, *t;
isc_result_t status;
if (h -> type != dhcp_type_group)
return ISC_R_INVALIDARG;
......@@ -271,7 +263,7 @@ isc_result_t dhcp_group_destroy (omapi_object_t *h, const char *file, int line)
isc_result_t dhcp_group_signal_handler (omapi_object_t *h,
const char *name, va_list ap)
{
struct group_object *group, *t;
struct group_object *group;
isc_result_t status;
int updatep = 0;
......@@ -453,7 +445,6 @@ isc_result_t dhcp_control_set_value (omapi_object_t *h,
{
dhcp_control_object_t *control;
isc_result_t status;
int foo;
unsigned long newstate;
if (h -> type != dhcp_type_control)
......@@ -488,7 +479,6 @@ isc_result_t dhcp_control_get_value (omapi_object_t *h, omapi_object_t *id,
{
dhcp_control_object_t *control;
isc_result_t status;
struct data_string ip_addrs;
if (h -> type != dhcp_type_control)
return ISC_R_INVALIDARG;
......@@ -511,9 +501,6 @@ isc_result_t dhcp_control_get_value (omapi_object_t *h, omapi_object_t *id,