Fix a number of incorrect assumptions regarding the size of time_t.

The code has its own TIME type, which is actually defined to time_t,
but it still used u_int32_t in some places.

In addition, dhclient not only had two separate global cur_time
variables, one of which was defined as u_int32_t and the other as
TIME, but cur_time was sometimes shadowed by local variables, leading
to widespread confusion as to which of these variable was being
referenced.

There is a lesson in here somewhere: a decent compiler with warnings
enabled should have caught all of this long before it became a
problem.

This patch has been submitted to the vendor, but it will likely be
some time before they release a version that includes it.

Approved by:	mbr
This commit is contained in:
des 2004-07-06 15:15:14 +00:00
parent ea0ce2336d
commit c1e7532eb5
5 changed files with 10 additions and 7 deletions

View File

@ -46,7 +46,7 @@ static char ocopyright[] =
#include <net80211/ieee80211.h>
#endif
TIME cur_time;
extern TIME cur_time;
TIME default_lease_time = 43200; /* 12 hours... */
TIME max_lease_time = 86400; /* 24 hours... */

View File

@ -47,7 +47,7 @@ static struct timeout *free_timeouts;
extern int polling_interval;
#endif
void set_time (u_int32_t t)
void set_time (TIME t)
{
/* Do any outstanding timeouts. */
if (cur_time != t) {
@ -95,7 +95,6 @@ void dispatch ()
struct timeval *tvp_new;
#endif
isc_result_t status;
TIME cur_time;
tvp = NULL;
#ifdef ENABLE_POLLING_MODE

View File

@ -335,7 +335,7 @@ struct lease_state {
struct option_state *options;
struct data_string parameter_request_list;
int max_message_size;
u_int32_t expiry, renewal, rebind;
TIME expiry, renewal, rebind;
struct data_string filename, server_name;
int got_requested_address;
int got_server_identifier;
@ -1764,7 +1764,7 @@ int if_readsocket PROTO ((omapi_object_t *));
void reinitialize_interfaces PROTO ((void));
/* dispatch.c */
void set_time (u_int32_t);
void set_time (TIME);
struct timeval *process_outstanding_timeouts (struct timeval *);
void dispatch PROTO ((void));
isc_result_t got_one PROTO ((omapi_object_t *));

View File

@ -30,12 +30,14 @@
* ``http://www.isc.org/''. To learn more about Vixie Enterprises,
* see ``http://www.vix.com''. To learn more about Nominum, Inc., see
* ``http://www.nominum.com''.
*
* $FreeBSD$
*/
#include <omapip/omapip_p.h>
static omapi_io_object_t omapi_io_states;
u_int32_t cur_time;
TIME cur_time;
OMAPI_OBJECT_ALLOC (omapi_io,
omapi_io_object_t, omapi_type_io_object)

View File

@ -28,6 +28,8 @@
* by Ted Lemon, as part of a project for Nominum, Inc. To learn more
* about Internet Systems Consortium, see http://www.isc.org/. To
* learn more about Nominum, Inc., see ``http://www.nominum.com''.
*
* $FreeBSD$
*/
#include <omapip/omapip_p.h>
@ -61,7 +63,7 @@ time_t trace_mr_time (time_t *);
int trace_mr_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
unsigned int trace_mr_res_randomid (unsigned int);
extern time_t cur_time;
extern TIME cur_time;
#if defined (TRACING)
void trace_mr_init ()