summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2017-06-21 15:24:35 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2017-06-21 15:24:35 +0000
commit1a1f7c4245e5e4087c61692e66a3f4d56be04160 (patch)
treea407fb613a4d8e4f50f760eb64355f204e861a9f
parent5b2bfa3464754cb42cb8c3c3a2e6380577a04cba (diff)
Consistently use time(&var) idiom rather than tossing in a few
var = time(NULL). Flip "struct interface *" to be the first parameter in set_timeout(), as in other functions taking the state info.
-rw-r--r--sbin/dhclient/dhclient.c24
-rw-r--r--sbin/dhclient/dhcpd.h6
-rw-r--r--sbin/dhclient/dispatch.c9
3 files changed, 20 insertions, 19 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 440d87a4762..95111d292c1 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.440 2017/06/21 12:37:24 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.441 2017/06/21 15:24:34 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -734,12 +734,12 @@ state_preboot(struct interface_info *ifi)
if (ifi->linkstat) {
ifi->state = S_REBOOTING;
- set_timeout(1, state_reboot, ifi);
+ set_timeout(ifi, 1, state_reboot);
} else {
if (interval > config->link_timeout)
go_daemon();
ifi->state = S_PREBOOT;
- set_timeout(1, state_preboot, ifi);
+ set_timeout(ifi, 1, state_preboot);
}
}
@@ -777,7 +777,7 @@ state_reboot(struct interface_info *ifi)
make_request(ifi, ifi->active);
ifi->destination.s_addr = INADDR_BROADCAST;
- ifi->first_sending = time(NULL);
+ time(&ifi->first_sending);
ifi->interval = 0;
send_request(ifi);
@@ -795,7 +795,7 @@ state_init(struct interface_info *ifi)
ifi->destination.s_addr = INADDR_BROADCAST;
ifi->state = S_SELECTING;
- ifi->first_sending = time(NULL);
+ time(&ifi->first_sending);
ifi->interval = 0;
send_discover(ifi);
@@ -856,7 +856,7 @@ state_selecting(struct interface_info *ifi)
ifi->destination.s_addr = INADDR_BROADCAST;
ifi->state = S_REQUESTING;
- ifi->first_sending = time(NULL);
+ time(&ifi->first_sending);
ifi->interval = 0;
@@ -909,7 +909,7 @@ dhcpoffer(struct interface_info *ifi, struct option_data *options, char *info)
if (stop_selecting <= time(NULL))
state_selecting(ifi);
else
- set_timeout(stop_selecting, state_selecting, ifi);
+ set_timeout(ifi, stop_selecting, state_selecting);
}
void
@@ -1128,7 +1128,7 @@ newlease:
ifi->state = S_BOUND;
/* Set timeout to start the renewal process. */
- set_timeout(ifi->active->renewal - cur_time, state_bound, ifi);
+ set_timeout(ifi, ifi->active->renewal - cur_time, state_bound);
}
/*
@@ -1153,7 +1153,7 @@ state_bound(struct interface_info *ifi)
else
dest->s_addr = INADDR_BROADCAST;
- ifi->first_sending = time(NULL);
+ time(&ifi->first_sending);
ifi->interval = 0;
ifi->state = S_RENEWING;
@@ -1392,7 +1392,7 @@ send_discover(struct interface_info *ifi)
log_warnx("dhclient cannot be used on %s", ifi->name);
quit = INTERNALSIG;
} else
- set_timeout(ifi->interval, send_discover, ifi);
+ set_timeout(ifi, ifi->interval, send_discover);
}
/*
@@ -1416,7 +1416,7 @@ state_panic(struct interface_info *ifi)
*/
log_info("No working leases in persistent database - sleeping.");
ifi->state = S_INIT;
- set_timeout(config->retry_interval, state_init, ifi);
+ set_timeout(ifi, config->retry_interval, state_init);
go_daemon();
}
@@ -1522,7 +1522,7 @@ send_request(struct interface_info *ifi)
send_packet(ifi, from, destination.sin_addr);
- set_timeout(ifi->interval, send_request, ifi);
+ set_timeout(ifi, ifi->interval, send_request);
}
void
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 890e01dd469..60a67d38528 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.189 2017/06/18 21:08:15 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.190 2017/06/21 15:24:34 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -210,8 +210,8 @@ ssize_t receive_packet(struct interface_info *, struct sockaddr_in *,
/* dispatch.c */
void dispatch(struct interface_info *);
-void set_timeout(time_t, void (*)(struct interface_info *),
- struct interface_info *);
+void set_timeout( struct interface_info *, time_t,
+ void (*)(struct interface_info *));
void cancel_timeout(struct interface_info *);
void interface_link_forceup(char *);
int interface_status(struct interface_info *);
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index 2cadceb3eaf..3e7a4bdbd98 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.125 2017/06/19 19:28:35 krw Exp $ */
+/* $OpenBSD: dispatch.c,v 1.126 2017/06/21 15:24:34 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -276,10 +276,11 @@ interface_status(struct interface_info *ifi)
}
void
-set_timeout(time_t secs, void (*where)(struct interface_info *),
- struct interface_info *ifi)
+set_timeout(struct interface_info *ifi, time_t secs,
+ void (*where)(struct interface_info *))
{
- ifi->timeout = time(NULL) + secs;
+ time(&ifi->timeout);
+ ifi->timeout += secs;
ifi->timeout_func = where;
}