summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomek Mrugalski <tomek@isc.org>2012-03-09 11:18:14 +0000
committerTomek Mrugalski <tomek@isc.org>2012-03-09 11:18:14 +0000
commitdd9237c309ac816268ec395f0d65a18a38a9aa2a (patch)
treef79ad87307715109fdf0886a70b2c4c5c50a7983
parent9a266235e6813d2565dc48949b222ba8e08078cb (diff)
downloadisc-dhcp-dd9237c309ac816268ec395f0d65a18a38a9aa2a.tar.gz
Fixed many compilation problems ("set, but not used" warnings) for
gcc 4.6 that may affect Ubuntu 11.10 users. [ISC-Bugs #27588]
-rw-r--r--RELNOTES3
-rw-r--r--client/clparse.c13
-rw-r--r--client/dhclient.c103
-rw-r--r--common/comapi.c59
-rw-r--r--common/options.c4
-rw-r--r--common/parse.c7
-rw-r--r--common/print.c5
-rw-r--r--common/socket.c3
-rw-r--r--dst/prandom.c7
-rw-r--r--includes/cdefs.h16
-rw-r--r--omapip/handle.c4
-rw-r--r--omapip/listener.c9
-rw-r--r--server/bootp.c29
-rw-r--r--server/db.c8
-rw-r--r--server/ddns.c7
-rw-r--r--server/dhcp.c78
-rw-r--r--server/dhcpv6.c6
-rw-r--r--server/failover.c20
-rw-r--r--server/omapi.c33
19 files changed, 257 insertions, 157 deletions
diff --git a/RELNOTES b/RELNOTES
index e0e7d604..9f52e7b3 100644
--- a/RELNOTES
+++ b/RELNOTES
@@ -94,6 +94,9 @@ work on other platforms. Please report any problems and suggested fixes to
checking programs to eliminate false positives.
[ISC-Bugs 27539]
+- Fixed many compilation problems ("set, but not used" warnings) for
+ gcc 4.6 that may affect Ubuntu 11.10 users. [ISC-Bugs #27588]
+
Changes since 4.2.2
- Fix the code that checks for an existing DDNS transaction to cancel
diff --git a/client/clparse.c b/client/clparse.c
index 9de4ce26..c535d7b4 100644
--- a/client/clparse.c
+++ b/client/clparse.c
@@ -3,7 +3,7 @@
Parser for dhclient config and lease files... */
/*
- * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -59,10 +59,18 @@ isc_result_t read_client_conf ()
{
struct client_config *config;
struct interface_info *ip;
- struct parse *parse;
isc_result_t status;
unsigned code;
+ /*
+ * TODO: LATER constant is very undescriptive. We should review it and
+ * change it to something more descriptive or even better remove it
+ * completely as it is currently not used.
+ */
+#ifdef LATER
+ struct parse *parse = NULL;
+#endif
+
/* Initialize the default request list. */
memset(default_requested_options, 0, sizeof(default_requested_options));
@@ -159,7 +167,6 @@ isc_result_t read_client_conf ()
(struct interface_info *)0,
&top_level_config);
- parse = NULL;
if (status != ISC_R_SUCCESS) {
;
#ifdef LATER
diff --git a/client/dhclient.c b/client/dhclient.c
index afe896fc..a68e8859 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -1899,11 +1899,14 @@ void send_discover (cpp)
ntohs (sockaddr_broadcast.sin_port), (long)(client -> interval));
/* Send out a packet. */
- result = send_packet (client -> interface, (struct packet *)0,
- &client -> packet,
- client -> packet_length,
- inaddr_any, &sockaddr_broadcast,
- (struct hardware *)0);
+ result = send_packet(client->interface, NULL, &client->packet,
+ client->packet_length, inaddr_any,
+ &sockaddr_broadcast, NULL);
+ if (result < 0) {
+ log_error("%s:%d: Failed to send %d byte long packet over %s "
+ "interface.", MDL, client->packet_length,
+ client->interface->name);
+ }
/*
* If we used 0 microseconds here, and there were other clients on the
@@ -2166,20 +2169,29 @@ void send_request (cpp)
ntohs (destination.sin_port));
if (destination.sin_addr.s_addr != INADDR_BROADCAST &&
- fallback_interface)
- result = send_packet (fallback_interface,
- (struct packet *)0,
- &client -> packet,
- client -> packet_length,
- from, &destination,
- (struct hardware *)0);
- else
+ fallback_interface) {
+ result = send_packet(fallback_interface, NULL, &client->packet,
+ client->packet_length, from, &destination,
+ NULL);
+ if (result < 0) {
+ log_error("%s:%d: Failed to send %d byte long packet "
+ "over %s interface.", MDL,
+ client->packet_length,
+ fallback_interface->name);
+ }
+ }
+ else {
/* Send out a packet. */
- result = send_packet (client -> interface, (struct packet *)0,
- &client -> packet,
- client -> packet_length,
- from, &destination,
- (struct hardware *)0);
+ result = send_packet(client->interface, NULL, &client->packet,
+ client->packet_length, from, &destination,
+ NULL);
+ if (result < 0) {
+ log_error("%s:%d: Failed to send %d byte long packet"
+ " over %s interface.", MDL,
+ client->packet_length,
+ client->interface->name);
+ }
+ }
tv.tv_sec = cur_tv.tv_sec + client->interval;
tv.tv_usec = ((tv.tv_sec - cur_tv.tv_sec) > 1) ?
@@ -2195,16 +2207,19 @@ void send_decline (cpp)
int result;
log_info ("DHCPDECLINE on %s to %s port %d",
- client -> name ? client -> name : client -> interface -> name,
- inet_ntoa (sockaddr_broadcast.sin_addr),
- ntohs (sockaddr_broadcast.sin_port));
+ client->name ? client->name : client->interface->name,
+ inet_ntoa(sockaddr_broadcast.sin_addr),
+ ntohs(sockaddr_broadcast.sin_port));
/* Send out a packet. */
- result = send_packet (client -> interface, (struct packet *)0,
- &client -> packet,
- client -> packet_length,
- inaddr_any, &sockaddr_broadcast,
- (struct hardware *)0);
+ result = send_packet(client->interface, NULL, &client->packet,
+ client->packet_length, inaddr_any,
+ &sockaddr_broadcast, NULL);
+ if (result < 0) {
+ log_error("%s:%d: Failed to send %d byte long packet over %s"
+ " interface.", MDL, client->packet_length,
+ client->interface->name);
+ }
}
void send_release (cpp)
@@ -2242,20 +2257,29 @@ void send_release (cpp)
inet_ntoa (destination.sin_addr),
ntohs (destination.sin_port));
- if (fallback_interface)
- result = send_packet (fallback_interface,
- (struct packet *)0,
- &client -> packet,
- client -> packet_length,
- from, &destination,
- (struct hardware *)0);
- else
+ if (fallback_interface) {
+ result = send_packet(fallback_interface, NULL, &client->packet,
+ client->packet_length, from, &destination,
+ NULL);
+ if (result < 0) {
+ log_error("%s:%d: Failed to send %d byte long packet"
+ " over %s interface.", MDL,
+ client->packet_length,
+ fallback_interface->name);
+ }
+ } else {
/* Send out a packet. */
- result = send_packet (client -> interface, (struct packet *)0,
- &client -> packet,
- client -> packet_length,
- from, &destination,
- (struct hardware *)0);
+ result = send_packet(client->interface, NULL, &client->packet,
+ client->packet_length, from, &destination,
+ NULL);
+ if (result < 0) {
+ log_error ("%s:%d: Failed to send %d byte long packet"
+ " over %s interface.", MDL,
+ client->packet_length,
+ client->interface->name);
+ }
+
+ }
}
void
@@ -3219,7 +3243,6 @@ void script_write_params (client, prefix, lease)
lease->server_name);
}
}
-
for (i = 0; i < lease -> options -> universe_count; i++) {
option_space_foreach ((struct packet *)0, (struct lease *)0,
diff --git a/common/comapi.c b/common/comapi.c
index c24b4a6a..90d2262c 100644
--- a/common/comapi.c
+++ b/common/comapi.c
@@ -3,6 +3,7 @@
OMAPI object interfaces for the DHCP server. */
/*
+ * Copyright (c) 2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
*
@@ -435,7 +436,7 @@ isc_result_t dhcp_group_remove (omapi_object_t *lp,
status = dhcp_group_destroy ((omapi_object_t *)group, MDL);
- return ISC_R_SUCCESS;
+ return status;
}
isc_result_t dhcp_control_set_value (omapi_object_t *h,
@@ -511,12 +512,12 @@ isc_result_t dhcp_control_destroy (omapi_object_t *h,
isc_result_t dhcp_control_signal_handler (omapi_object_t *h,
const char *name, va_list ap)
{
- dhcp_control_object_t *control;
+ /* In this function h should be a (dhcp_control_object_t *) */
+
isc_result_t status;
if (h -> type != dhcp_type_control)
return DHCP_R_INVALIDARG;
- control = (dhcp_control_object_t *)h;
/* Try to find some inner object that can take the value. */
if (h -> inner && h -> inner -> type -> get_value) {
@@ -572,11 +573,11 @@ isc_result_t dhcp_control_lookup (omapi_object_t **lp,
status = omapi_get_value_str (ref, id, "handle", &tv);
if (status == ISC_R_SUCCESS) {
status = omapi_handle_td_lookup (lp, tv -> value);
-
+
omapi_value_dereference (&tv, MDL);
if (status != ISC_R_SUCCESS)
return status;
-
+
/* Don't return the object if the type is wrong. */
if ((*lp) -> type != dhcp_type_control) {
omapi_object_dereference (lp, MDL);
@@ -612,12 +613,12 @@ isc_result_t dhcp_subnet_set_value (omapi_object_t *h,
omapi_data_string_t *name,
omapi_typed_data_t *value)
{
- struct subnet *subnet;
+ /* In this function h should be a (struct subnet *) */
+
isc_result_t status;
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
- subnet = (struct subnet *)h;
/* No values to set yet. */
@@ -628,7 +629,7 @@ isc_result_t dhcp_subnet_set_value (omapi_object_t *h,
if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
return status;
}
-
+
return ISC_R_NOTFOUND;
}
@@ -637,12 +638,12 @@ isc_result_t dhcp_subnet_get_value (omapi_object_t *h, omapi_object_t *id,
omapi_data_string_t *name,
omapi_value_t **value)
{
- struct subnet *subnet;
+ /* In this function h should be a (struct subnet *) */
+
isc_result_t status;
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
- subnet = (struct subnet *)h;
/* No values to get yet. */
@@ -658,14 +659,17 @@ isc_result_t dhcp_subnet_get_value (omapi_object_t *h, omapi_object_t *id,
isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line)
{
+#if defined (DEBUG_MEMORY_LEAKAGE) || \
+ defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
struct subnet *subnet;
+#endif
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
- subnet = (struct subnet *)h;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
+ subnet = (struct subnet *)h;
if (subnet -> next_subnet)
subnet_dereference (&subnet -> next_subnet, file, line);
if (subnet -> next_sibling)
@@ -685,13 +689,13 @@ isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line)
isc_result_t dhcp_subnet_signal_handler (omapi_object_t *h,
const char *name, va_list ap)
{
- struct subnet *subnet;
+ /* In this function h should be a (struct subnet *) */
+
isc_result_t status;
int updatep = 0;
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
- subnet = (struct subnet *)h;
/* Can't write subnets yet. */
@@ -711,12 +715,12 @@ isc_result_t dhcp_subnet_stuff_values (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *h)
{
- struct subnet *subnet;
+ /* In this function h should be a (struct subnet *) */
+
isc_result_t status;
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
- subnet = (struct subnet *)h;
/* Can't stuff subnet values yet. */
@@ -761,12 +765,12 @@ isc_result_t dhcp_shared_network_set_value (omapi_object_t *h,
omapi_data_string_t *name,
omapi_typed_data_t *value)
{
- struct shared_network *shared_network;
+ /* In this function h should be a (struct shared_network *) */
+
isc_result_t status;
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
- shared_network = (struct shared_network *)h;
/* No values to set yet. */
@@ -777,7 +781,7 @@ isc_result_t dhcp_shared_network_set_value (omapi_object_t *h,
if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
return status;
}
-
+
return ISC_R_NOTFOUND;
}
@@ -787,12 +791,12 @@ isc_result_t dhcp_shared_network_get_value (omapi_object_t *h,
omapi_data_string_t *name,
omapi_value_t **value)
{
- struct shared_network *shared_network;
+ /* In this function h should be a (struct shared_network *) */
+
isc_result_t status;
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
- shared_network = (struct shared_network *)h;
/* No values to get yet. */
@@ -809,14 +813,19 @@ isc_result_t dhcp_shared_network_get_value (omapi_object_t *h,
isc_result_t dhcp_shared_network_destroy (omapi_object_t *h,
const char *file, int line)
{
+ /* In this function h should be a (struct shared_network *) */
+
+#if defined (DEBUG_MEMORY_LEAKAGE) || \
+ defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
struct shared_network *shared_network;
+#endif
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
- shared_network = (struct shared_network *)h;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
+ shared_network = (struct shared_network *)h;
if (shared_network -> next)
shared_network_dereference (&shared_network -> next,
file, line);
@@ -849,13 +858,13 @@ isc_result_t dhcp_shared_network_signal_handler (omapi_object_t *h,
const char *name,
va_list ap)
{
- struct shared_network *shared_network;
+ /* In this function h should be a (struct shared_network *) */
+
isc_result_t status;
int updatep = 0;
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
- shared_network = (struct shared_network *)h;
/* Can't write shared_networks yet. */
@@ -875,12 +884,12 @@ isc_result_t dhcp_shared_network_stuff_values (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *h)
{
- struct shared_network *shared_network;
+ /* In this function h should be a (struct shared_network *) */
+
isc_result_t status;
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
- shared_network = (struct shared_network *)h;
/* Can't stuff shared_network values yet. */
diff --git a/common/options.c b/common/options.c
index e37fd3d8..3c08d33b 100644
--- a/common/options.c
+++ b/common/options.c
@@ -3,7 +3,7 @@
DHCP options parsing and reassembly. */
/*
- * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -2361,7 +2361,7 @@ prepare_option_buffer(struct universe *universe, struct buffer *bp,
cleanup:
option_dereference(&option, MDL);
- return 1;
+ return status;
}
static void
diff --git a/common/parse.c b/common/parse.c
index 0d3e7c60..434085a2 100644
--- a/common/parse.c
+++ b/common/parse.c
@@ -907,7 +907,7 @@ parse_date_core(cfile)
struct parse *cfile;
{
int guess;
- int tzoff, wday, year, mon, mday, hour, min, sec;
+ int tzoff, year, mon, mday, hour, min, sec;
const char *val;
enum dhcp_token token;
static int months[11] = { 31, 59, 90, 120, 151, 181,
@@ -945,7 +945,7 @@ parse_date_core(cfile)
return((TIME)0);
}
token = next_token(&val, NULL, cfile); /* consume day of week */
- wday = atoi(val);
+ /* we are not using this for anything */
/* Year... */
token = peek_token(&val, NULL, cfile);
@@ -3390,11 +3390,10 @@ int parse_boolean_expression (expr, cfile, lose)
int parse_boolean (cfile)
struct parse *cfile;
{
- enum dhcp_token token;
const char *val;
int rv;
- token = next_token (&val, (unsigned *)0, cfile);
+ (void)next_token(&val, NULL, cfile);
if (!strcasecmp (val, "true")
|| !strcasecmp (val, "on"))
rv = 1;
diff --git a/common/print.c b/common/print.c
index e8eac799..d5d0ae07 100644
--- a/common/print.c
+++ b/common/print.c
@@ -3,7 +3,7 @@
Turn data structures into printable text. */
/*
- * Copyright (c) 2009-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
@@ -479,10 +479,9 @@ char *print_dotted_quads (len, data)
{
static char dq_buf [DQLEN + 1];
int i;
- char *s, *last;
+ char *s;
s = &dq_buf [0];
- last = s;
i = 0;
diff --git a/common/socket.c b/common/socket.c
index 21e1f5f0..f95665c3 100644
--- a/common/socket.c
+++ b/common/socket.c
@@ -1000,6 +1000,9 @@ isc_result_t fallback_discard (object)
log_error ("fallback_discard: %m");
return ISC_R_UNEXPECTED;
}
+#else
+ /* ignore the fact that status value is never used */
+ IGNORE_UNUSED(status);
#endif
return ISC_R_SUCCESS;
}
diff --git a/dst/prandom.c b/dst/prandom.c
index 620d7140..d17aa3e1 100644
--- a/dst/prandom.c
+++ b/dst/prandom.c
@@ -1,9 +1,10 @@
#ifndef LINT
-static const char rcsid[] = "$Header: /tmp/cvstest/DHCP/dst/prandom.c,v 1.9 2009/11/24 02:06:56 sar Exp $";
+static const char rcsid[] = "$Header: /tmp/cvstest/DHCP/dst/prandom.c,v 1.10 2012/03/09 11:18:13 tomasz Exp $";
#endif
/*
- * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
+ * Portions Copyright (c) 2012 by Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (c) 2007,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
*
* Permission to use, copy modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -694,7 +695,6 @@ own_random(dst_work *work)
{
int dir = 0, b;
int bytes, n, cmd = 0, dig = 0;
- int start =0;
/*
* now get the initial seed to put into the quick random function from
* the address of the work structure
@@ -709,7 +709,6 @@ own_random(dst_work *work)
/* pick a random number in the range of 0..7 based on that random number
* perform some operations that yield random data
*/
- start = work->filled;
n = (dst_s_quick_random(bytes) >> DST_SHIFT) & 0x07;
switch (n) {
case 0:
diff --git a/includes/cdefs.h b/includes/cdefs.h
index b04e5b58..d5ef422e 100644
--- a/includes/cdefs.h
+++ b/includes/cdefs.h
@@ -4,7 +4,7 @@
/*
* Copyright (c) 1995 RadioMail Corporation. All rights reserved.
- * Copyright (c) 2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2011,2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004,2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
@@ -46,15 +46,25 @@
* the warning by the use of void. In conjunction with the use of -Werror
* these warnings prohibit the compilation of the package. This macro
* allows us to assign the return value to a variable and then ignore it.
+ *
+ * __attribute__((unused)) is added for avoiding another warning about set,
+ * but unused variable. This is produced by unused-but-set-variable switch
+ * that is enabled by default in gcc 4.6.
*/
#if !defined(__GNUC__) || (__GNUC__ < 4)
#define IGNORE_RET(x) (void) x
#else
#define IGNORE_RET(x) \
do { \
- int ignore_return; \
- ignore_return = x; \
+ int __attribute__((unused)) ignore_return ;\
+ ignore_return = x; \
} while (0)
#endif
+/* This macro is defined to avoid unused-but-set-variable warning
+ * that is enabled in gcc 4.6
+ */
+
+#define IGNORE_UNUSED(x) { x = x; }
+
#endif /* __ISC_DHCP_CDEFS_H__ */
diff --git a/omapip/handle.c b/omapip/handle.c
index b69ef126..8405acfd 100644
--- a/omapip/handle.c
+++ b/omapip/handle.c
@@ -3,7 +3,7 @@
Functions for maintaining handles on objects. */
/*
- * Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009-2010,2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
*
@@ -252,7 +252,6 @@ static isc_result_t omapi_handle_lookup_in (omapi_object_t **o,
omapi_handle_table_t *table,
int op)
{
- omapi_handle_table_t *inner;
omapi_handle_t scale, index;
if (!table || table->first > h || table->limit <= h)
@@ -282,7 +281,6 @@ static isc_result_t omapi_handle_lookup_in (omapi_object_t **o,
handle must be the subtable of this table whose index into this
table's array of children is the handle divided by the scale. */
index = (h - table->first) / scale;
- inner = table->children[index].table;
return(omapi_handle_lookup_in(o, h, table->children[index].table, op));
}
diff --git a/omapip/listener.c b/omapip/listener.c
index 0c4dcb13..30259eb6 100644
--- a/omapip/listener.c
+++ b/omapip/listener.c
@@ -3,6 +3,7 @@
Subroutines that support the generic listener object. */
/*
+ * Copyright (c) 2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004,2007,2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
*
@@ -124,7 +125,7 @@ isc_result_t omapi_listen_addr (omapi_object_t *h,
status = ISC_R_UNEXPECTED;
goto error_exit;
}
-
+
#if defined (HAVE_SETFD)
if (fcntl (obj -> socket, F_SETFD, 1) < 0) {
status = ISC_R_UNEXPECTED;
@@ -140,7 +141,7 @@ isc_result_t omapi_listen_addr (omapi_object_t *h,
status = ISC_R_UNEXPECTED;
goto error_exit;
}
-
+
/* Try to bind to the wildcard address using the port number
we were given. */
i = bind (obj -> socket,
@@ -369,6 +370,10 @@ static void trace_listener_accept_input (trace_type_t *ttype,
obj = (omapi_connection_object_t *)0;
status = omapi_listener_connect (&obj,
lp, 0, &remote_addr);
+ if (status != ISC_R_SUCCESS) {
+ log_error("%s:%d: OMAPI: Failed to connect "
+ "a listener.", MDL);
+ }
omapi_listener_dereference (&lp, MDL);
return;
}
diff --git a/server/bootp.c b/server/bootp.c
index c88fab84..477bb045 100644
--- a/server/bootp.c
+++ b/server/bootp.c
@@ -3,7 +3,8 @@
BOOTP Protocol support. */
/*
- * Copyright (c) 2004,2005,2007,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009,2012 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004,2005,2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -384,10 +385,16 @@ void bootp (packet)
to.sin_port = local_port;
if (fallback_interface) {
- result = send_packet (fallback_interface,
- (struct packet *)0,
- &raw, outgoing.packet_length,
- from, &to, &hto);
+ result = send_packet (fallback_interface, NULL, &raw,
+ outgoing.packet_length, from,
+ &to, &hto);
+ if (result < 0) {
+ log_error ("%s:%d: Failed to send %d byte long "
+ "packet over %s interface.", MDL,
+ outgoing.packet_length,
+ fallback_interface->name);
+ }
+
goto out;
}
@@ -407,10 +414,16 @@ void bootp (packet)
}
errno = 0;
- result = send_packet (packet -> interface,
- packet, &raw, outgoing.packet_length,
- from, &to, &hto);
+ result = send_packet(packet->interface, packet, &raw,
+ outgoing.packet_length, from, &to, &hto);
+ if (result < 0) {
+ log_error ("%s:%d: Failed to send %d byte long packet over %s"
+ " interface.", MDL, outgoing.packet_length,
+ packet->interface->name);
+ }
+
out:
+
if (options)
option_state_dereference (&options, MDL);
if (lease)
diff --git a/server/db.c b/server/db.c
index c30d0fbc..6cb84f71 100644
--- a/server/db.c
+++ b/server/db.c
@@ -3,7 +3,7 @@
Persistent database management routines for DHCPD... */
/*
- * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2010,2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -1021,7 +1021,11 @@ void db_startup (testp)
/* Read in the existing lease file... */
status = read_conf_file (path_dhcpd_db,
(struct group *)0, 0, 1);
- /* XXX ignore status? */
+ if (status != ISC_R_SUCCESS) {
+ /* XXX ignore status? */
+ ;
+ }
+
#if defined (TRACING)
}
#endif
diff --git a/server/ddns.c b/server/ddns.c
index 1f1017fe..cf2c044d 100644
--- a/server/ddns.c
+++ b/server/ddns.c
@@ -81,7 +81,6 @@ ddns_updates(struct packet *packet, struct lease *lease, struct lease *old,
struct option_cache *oc;
int s1, s2;
int result = 0;
- isc_result_t rcode1 = ISC_R_SUCCESS;
int server_updates_a = 1;
//int server_updates_ptr = 1;
struct buffer *bp = (struct buffer *)0;
@@ -536,7 +535,11 @@ ddns_updates(struct packet *packet, struct lease *lease, struct lease *old,
* the ddns messages. Currently we don't.
*/
if (do_remove) {
- rcode1 = ddns_removals(lease, lease6, ddns_cb, ISC_TRUE);
+ /*
+ * We should log a more specific error closer to the actual
+ * error if we want one. ddns_removal failure not logged here.
+ */
+ (void) ddns_removals(lease, lease6, ddns_cb, ISC_TRUE);
}
else {
ddns_fwd_srv_connector(lease, lease6, scope, ddns_cb,
diff --git a/server/dhcp.c b/server/dhcp.c
index 5875bb1b..6ef2e4ad 100644
--- a/server/dhcp.c
+++ b/server/dhcp.c
@@ -3,7 +3,7 @@
DHCP Protocol engine. */
/*
- * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -419,7 +419,6 @@ void dhcprequest (packet, ms_nulltp, ip_lease)
#if defined (FAILOVER_PROTOCOL)
dhcp_failover_state_t *peer;
#endif
- int have_server_identifier = 0;
int have_requested_addr = 0;
oc = lookup_option (&dhcp_universe, packet -> options,
@@ -473,7 +472,6 @@ void dhcprequest (packet, ms_nulltp, ip_lease)
* safe.
*/
sprintf (smbuf, " (%s)", piaddr (sip));
- have_server_identifier = 1;
} else
smbuf [0] = 0;
@@ -969,6 +967,8 @@ void dhcpinform (packet, ms_nulltp)
struct sockaddr_in to;
struct in_addr from;
isc_boolean_t zeroed_ciaddr;
+ struct interface_info *interface;
+ int result;
/* The client should set ciaddr to its IP address, but apparently
it's common for clients not to do this, so we'll use their IP
@@ -1169,7 +1169,7 @@ void dhcpinform (packet, ms_nulltp)
packet -> options, options,
&global_scope, oc, MDL)) {
struct universe *u = (struct universe *)0;
-
+
if (!universe_hash_lookup (&u, universe_hash,
(const char *)d1.data, d1.len,
MDL)) {
@@ -1314,10 +1314,17 @@ void dhcpinform (packet, ms_nulltp)
packet->interface->name);
errno = 0;
- send_packet ((fallback_interface
- ? fallback_interface : packet -> interface),
- &outgoing, &raw, outgoing.packet_length,
- from, &to, (struct hardware *)0);
+ interface = (fallback_interface ? fallback_interface
+ : packet -> interface);
+ result = send_packet(interface, &outgoing, &raw,
+ outgoing.packet_length, from, &to, NULL);
+ if (result < 0) {
+ log_error ("%s:%d: Failed to send %d byte long packet over %s "
+ "interface.", MDL, outgoing.packet_length,
+ interface->name);
+ }
+
+
if (subnet)
subnet_dereference (&subnet, MDL);
}
@@ -1464,6 +1471,13 @@ void nak_lease (packet, cip)
result = send_packet(fallback_interface, packet, &raw,
outgoing.packet_length, from, &to,
NULL);
+ if (result < 0) {
+ log_error ("%s:%d: Failed to send %d byte long "
+ "packet over %s interface.", MDL,
+ outgoing.packet_length,
+ fallback_interface->name);
+ }
+
return;
}
} else {
@@ -1474,6 +1488,12 @@ void nak_lease (packet, cip)
errno = 0;
result = send_packet(packet->interface, packet, &raw,
outgoing.packet_length, from, &to, NULL);
+ if (result < 0) {
+ log_error ("%s:%d: Failed to send %d byte long packet over %s "
+ "interface.", MDL, outgoing.packet_length,
+ packet->interface->name);
+ }
+
}
void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp)
@@ -3214,11 +3234,16 @@ void dhcp_reply (lease)
to.sin_port = remote_port; /* For debugging. */
if (fallback_interface) {
- result = send_packet (fallback_interface,
- (struct packet *)0,
- &raw, packet_length,
- raw.siaddr, &to,
- (struct hardware *)0);
+ result = send_packet(fallback_interface, NULL, &raw,
+ packet_length, raw.siaddr, &to,
+ NULL);
+ if (result < 0) {
+ log_error ("%s:%d: Failed to send %d byte long "
+ "packet over %s interface.", MDL,
+ packet_length,
+ fallback_interface->name);
+ }
+
free_lease_state (state, MDL);
lease -> state = (struct lease_state *)0;
@@ -3247,11 +3272,16 @@ void dhcp_reply (lease)
to.sin_port = remote_port;
if (fallback_interface) {
- result = send_packet (fallback_interface,
- (struct packet *)0,
- &raw, packet_length,
- raw.siaddr, &to,
- (struct hardware *)0);
+ result = send_packet(fallback_interface, NULL, &raw,
+ packet_length, raw.siaddr, &to,
+ NULL);
+ if (result < 0) {
+ log_error("%s:%d: Failed to send %d byte long"
+ " packet over %s interface.", MDL,
+ packet_length,
+ fallback_interface->name);
+ }
+
free_lease_state (state, MDL);
lease -> state = (struct lease_state *)0;
return;
@@ -3276,10 +3306,14 @@ void dhcp_reply (lease)
memcpy (&from, state -> from.iabuf, sizeof from);
- result = send_packet (state -> ip,
- (struct packet *)0, &raw, packet_length,
- from, &to,
- unicastp ? &hto : (struct hardware *)0);
+ result = send_packet(state->ip, NULL, &raw, packet_length,
+ from, &to, unicastp ? &hto : NULL);
+ if (result < 0) {
+ log_error ("%s:%d: Failed to send %d byte long "
+ "packet over %s interface.", MDL,
+ packet_length, state->ip->name);
+ }
+
/* Free all of the entries in the option_state structure
now that we're done with them. */
diff --git a/server/dhcpv6.c b/server/dhcpv6.c
index 2e88d7fb..3e7a9807 100644
--- a/server/dhcpv6.c
+++ b/server/dhcpv6.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2006-2012 by Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -4617,7 +4617,6 @@ iterate_over_ia_na(struct data_string *reply_ret,
struct option_state *host_opt_state;
struct data_string iaaddr;
struct data_string fixed_addr;
- int iaaddr_is_found;
char reply_data[65536];
struct dhcpv6_packet *reply = (struct dhcpv6_packet *)reply_data;
int reply_ofs = (int)(offsetof(struct dhcpv6_packet, options));
@@ -4724,7 +4723,6 @@ iterate_over_ia_na(struct data_string *reply_ret,
*/
for (ia = lookup_option(&dhcpv6_universe, packet->options, D6O_IA_NA);
ia != NULL; ia = ia->next) {
- iaaddr_is_found = 0;
if (!get_encapsulated_IA_state(&cli_enc_opt_state,
&cli_enc_opt_data,
@@ -5136,7 +5134,6 @@ iterate_over_ia_pd(struct data_string *reply_ret,
struct host_decl *host;
struct option_state *host_opt_state;
struct data_string iaprefix;
- int iaprefix_is_found;
char reply_data[65536];
int reply_ofs;
struct iasubopt *prefix;
@@ -5203,7 +5200,6 @@ iterate_over_ia_pd(struct data_string *reply_ret,
*/
for (ia = lookup_option(&dhcpv6_universe, packet->options, D6O_IA_PD);
ia != NULL; ia = ia->next) {
- iaprefix_is_found = 0;
if (!get_encapsulated_IA_state(&cli_enc_opt_state,
&cli_enc_opt_data,
diff --git a/server/failover.c b/server/failover.c
index 26be290c..8d7fe789 100644
--- a/server/failover.c
+++ b/server/failover.c
@@ -3,7 +3,7 @@
Failover protocol support code... */
/*
- * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -32,6 +32,7 @@
* ``http://www.nominum.com''.
*/
+#include "cdefs.h"
#include "dhcpd.h"
#include <omapip/omapip_p.h>
@@ -2412,7 +2413,8 @@ dhcp_failover_pool_dobalance(dhcp_failover_state_t *state,
struct shared_network *s;
struct pool *p;
binding_state_t peer_lease_state;
- binding_state_t my_lease_state;
+ /* binding_state_t my_lease_state; */
+ /* XXX Why is this my_lease_state never used? */
struct lease **lq;
int (*log_func)(const char *, ...);
const char *result, *reqlog;
@@ -2436,12 +2438,12 @@ dhcp_failover_pool_dobalance(dhcp_failover_state_t *state,
if (p->failover_peer->i_am == primary) {
lts = (p->free_leases - p->backup_leases) / 2;
peer_lease_state = FTS_BACKUP;
- my_lease_state = FTS_FREE;
+ /* my_lease_state = FTS_FREE; */
lq = &p->free;
} else {
lts = (p->backup_leases - p->free_leases) / 2;
peer_lease_state = FTS_FREE;
- my_lease_state = FTS_BACKUP;
+ /* my_lease_state = FTS_BACKUP; */
lq = &p->backup;
}
@@ -3257,13 +3259,13 @@ isc_result_t dhcp_failover_state_stuff (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *h)
{
+ /* In this function c should be a (omapi_connection_object_t *) */
+
dhcp_failover_state_t *s;
- omapi_connection_object_t *conn;
isc_result_t status;
if (c -> type != omapi_type_connection)
return DHCP_R_INVALIDARG;
- conn = (omapi_connection_object_t *)c;
if (h -> type != dhcp_type_failover_state)
return DHCP_R_INVALIDARG;
@@ -4306,6 +4308,8 @@ void dhcp_failover_send_contact (void *vstate)
if (obufix) {
log_debug ("%s", obuf);
}
+#else
+ IGNORE_UNUSED(status);
#endif
return;
}
@@ -4354,6 +4358,8 @@ isc_result_t dhcp_failover_send_state (dhcp_failover_state_t *state)
if (obufix) {
log_debug ("%s", obuf);
}
+#else
+ IGNORE_UNUSED(status);
#endif
return ISC_R_SUCCESS;
}
@@ -4490,7 +4496,6 @@ isc_result_t dhcp_failover_send_disconnect (omapi_object_t *l,
const char *message)
{
dhcp_failover_link_t *link;
- dhcp_failover_state_t *state;
isc_result_t status;
#if defined (DEBUG_FAILOVER_MESSAGES)
char obuf [64];
@@ -4505,7 +4510,6 @@ isc_result_t dhcp_failover_send_disconnect (omapi_object_t *l,
if (!l || l -> type != dhcp_type_failover_link)
return DHCP_R_INVALIDARG;
link = (dhcp_failover_link_t *)l;
- state = link -> state_object;
if (!l -> outer || l -> outer -> type != omapi_type_connection)
return DHCP_R_INVALIDARG;
diff --git a/server/omapi.c b/server/omapi.c
index 26294352..22b5358a 100644
--- a/server/omapi.c
+++ b/server/omapi.c
@@ -3,7 +3,7 @@
OMAPI object interfaces for the DHCP server. */
/*
- * Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2009,2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -480,12 +480,11 @@ isc_result_t dhcp_lease_destroy (omapi_object_t *h, const char *file, int line)
isc_result_t dhcp_lease_signal_handler (omapi_object_t *h,
const char *name, va_list ap)
{
- struct lease *lease;
+ /* h should point to (struct lease *) */
isc_result_t status;
if (h -> type != dhcp_type_lease)
return DHCP_R_INVALIDARG;
- lease = (struct lease *)h;
if (!strcmp (name, "updated"))
return ISC_R_SUCCESS;
@@ -1175,14 +1174,13 @@ isc_result_t dhcp_host_get_value (omapi_object_t *h, omapi_object_t *id,
isc_result_t dhcp_host_destroy (omapi_object_t *h, const char *file, int line)
{
- struct host_decl *host;
if (h -> type != dhcp_type_host)
return DHCP_R_INVALIDARG;
- host = (struct host_decl *)h;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
+ struct host_decl *host = (struct host_decl *)h;
if (host -> n_ipaddr)
host_dereference (&host -> n_ipaddr, file, line);
if (host -> n_dynamic)
@@ -1388,7 +1386,7 @@ isc_result_t dhcp_host_lookup (omapi_object_t **lp,
tv -> value -> u.buffer.value,
tv -> value -> u.buffer.len, MDL);
omapi_value_dereference (&tv, MDL);
-
+
if (*lp && *lp != (omapi_object_t *)host) {
omapi_object_dereference (lp, MDL);
if (host)
@@ -1594,12 +1592,11 @@ isc_result_t dhcp_pool_set_value (omapi_object_t *h,
omapi_data_string_t *name,
omapi_typed_data_t *value)
{
- struct pool *pool;
+ /* h should point to (struct pool *) */
isc_result_t status;
if (h -> type != dhcp_type_pool)
return DHCP_R_INVALIDARG;
- pool = (struct pool *)h;
/* No values to set yet. */
@@ -1619,12 +1616,11 @@ isc_result_t dhcp_pool_get_value (omapi_object_t *h, omapi_object_t *id,
omapi_data_string_t *name,
omapi_value_t **value)
{
- struct pool *pool;
+ /* h should point to (struct pool *) */
isc_result_t status;
if (h -> type != dhcp_type_pool)
return DHCP_R_INVALIDARG;
- pool = (struct pool *)h;
/* No values to get yet. */
@@ -1640,7 +1636,6 @@ isc_result_t dhcp_pool_get_value (omapi_object_t *h, omapi_object_t *id,
isc_result_t dhcp_pool_destroy (omapi_object_t *h, const char *file, int line)
{
- struct pool *pool;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
struct permit *pc, *pn;
@@ -1648,10 +1643,10 @@ isc_result_t dhcp_pool_destroy (omapi_object_t *h, const char *file, int line)
if (h -> type != dhcp_type_pool)
return DHCP_R_INVALIDARG;
- pool = (struct pool *)h;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
+ struct pool *pool = (struct pool *)h;
if (pool -> next)
pool_dereference (&pool -> next, file, line);
if (pool -> group)
@@ -1692,13 +1687,12 @@ isc_result_t dhcp_pool_destroy (omapi_object_t *h, const char *file, int line)
isc_result_t dhcp_pool_signal_handler (omapi_object_t *h,
const char *name, va_list ap)
{
- struct pool *pool;
+ /* h should point to (struct pool *) */
isc_result_t status;
int updatep = 0;
if (h -> type != dhcp_type_pool)
return DHCP_R_INVALIDARG;
- pool = (struct pool *)h;
/* Can't write pools yet. */
@@ -1718,12 +1712,11 @@ isc_result_t dhcp_pool_stuff_values (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *h)
{
- struct pool *pool;
+ /* h should point to (struct pool *) */
isc_result_t status;
if (h -> type != dhcp_type_pool)
return DHCP_R_INVALIDARG;
- pool = (struct pool *)h;
/* Can't stuff pool values yet. */
@@ -1951,14 +1944,13 @@ isc_result_t dhcp_class_get_value (omapi_object_t *h, omapi_object_t *id,
isc_result_t dhcp_class_destroy (omapi_object_t *h, const char *file, int line)
{
- struct class *class;
if (h -> type != dhcp_type_class && h -> type != dhcp_type_subclass)
return DHCP_R_INVALIDARG;
- class = (struct class *)h;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
+ struct class *class = (struct class *)h;
if (class -> nic)
class_dereference (&class -> nic, file, line);
if (class -> superclass)
@@ -2065,7 +2057,7 @@ class_signal_handler(omapi_object_t *h,
if (updatep)
return ISC_R_SUCCESS;
-
+
return ISC_R_NOTFOUND;
}
@@ -2083,12 +2075,11 @@ isc_result_t dhcp_class_stuff_values (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *h)
{
- struct class *class;
+ /* h should point to (struct class *) */
isc_result_t status;
if (h -> type != dhcp_type_class)
return DHCP_R_INVALIDARG;
- class = (struct class *)h;
/* Can't stuff class values yet. */