Commit dd9237c3 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

Fixed many compilation problems ("set, but not used" warnings) for

gcc 4.6 that may affect Ubuntu 11.10 users. [ISC-Bugs #27588]
parent 9a266235
......@@ -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
......
......@@ -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
......
......@@ -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,
......
......@@ -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. */
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
}
......
#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:
......
......@@ -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__ */
......@@ -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));
}
......
......@@ -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;
}
......
......@@ -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,