Skip to content

Commit 508496f

Browse files
pabigotjukkar
authored andcommitted
net: dhcp: rename variable for clarity
A variable named "timeout" is used to represent the current time in comparisons against timeouts calculated from a start time and an interval. Since this current time is not the timeout change its name to "now" to reduce maintainer confusion. Signed-off-by: Peter Bigot <[email protected]>
1 parent 07c5d2f commit 508496f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

subsys/net/ip/dhcpv4.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -445,29 +445,29 @@ static void dhcpv4_enter_selecting(struct net_if *iface)
445445
net_dhcpv4_state_name(iface->config.dhcpv4.state));
446446
}
447447

448-
static bool dhcpv4_check_timeout(int64_t start, uint32_t time, int64_t timeout)
448+
static bool dhcpv4_check_timeout(int64_t start, uint32_t time, int64_t now)
449449
{
450-
start += MSEC_PER_SEC * time;
450+
int64_t deadline = start + MSEC_PER_SEC * time;
451451

452-
if (start > timeout) {
452+
if (deadline > now) {
453453
return false;
454454
}
455455

456456
return true;
457457
}
458458

459-
static bool dhcpv4_request_timedout(struct net_if *iface, int64_t timeout)
459+
static bool dhcpv4_request_timedout(struct net_if *iface, int64_t now)
460460
{
461461
return dhcpv4_check_timeout(iface->config.dhcpv4.timer_start,
462462
iface->config.dhcpv4.request_time,
463-
timeout);
463+
now);
464464
}
465465

466-
static bool dhcpv4_renewal_timedout(struct net_if *iface, int64_t timeout)
466+
static bool dhcpv4_renewal_timedout(struct net_if *iface, int64_t now)
467467
{
468468
if (!dhcpv4_check_timeout(iface->config.dhcpv4.timer_start,
469469
iface->config.dhcpv4.renewal_time,
470-
timeout)) {
470+
now)) {
471471
return false;
472472
}
473473

@@ -479,11 +479,11 @@ static bool dhcpv4_renewal_timedout(struct net_if *iface, int64_t timeout)
479479
return true;
480480
}
481481

482-
static bool dhcpv4_rebinding_timedout(struct net_if *iface, int64_t timeout)
482+
static bool dhcpv4_rebinding_timedout(struct net_if *iface, int64_t now)
483483
{
484484
if (!dhcpv4_check_timeout(iface->config.dhcpv4.timer_start,
485485
iface->config.dhcpv4.rebinding_time,
486-
timeout)) {
486+
now)) {
487487
return false;
488488
}
489489

@@ -539,12 +539,12 @@ static void dhcpv4_enter_bound(struct net_if *iface)
539539
sizeof(iface->config.dhcpv4));
540540
}
541541

542-
static uint32_t dhcph4_manage_timers(struct net_if *iface, int64_t timeout)
542+
static uint32_t dhcpv4_manage_timers(struct net_if *iface, int64_t now)
543543
{
544544
NET_DBG("iface %p state=%s", iface,
545545
net_dhcpv4_state_name(iface->config.dhcpv4.state));
546546

547-
if (!dhcpv4_request_timedout(iface, timeout)) {
547+
if (!dhcpv4_request_timedout(iface, now)) {
548548
return iface->config.dhcpv4.request_time;
549549
}
550550

@@ -570,8 +570,8 @@ static uint32_t dhcph4_manage_timers(struct net_if *iface, int64_t timeout)
570570

571571
return dhcpv4_send_request(iface);
572572
case NET_DHCPV4_BOUND:
573-
if (dhcpv4_renewal_timedout(iface, timeout) ||
574-
dhcpv4_rebinding_timedout(iface, timeout)) {
573+
if (dhcpv4_renewal_timedout(iface, now) ||
574+
dhcpv4_rebinding_timedout(iface, now)) {
575575
return dhcpv4_send_request(iface);
576576
}
577577

@@ -604,7 +604,7 @@ static uint32_t dhcph4_manage_timers(struct net_if *iface, int64_t timeout)
604604
static void dhcpv4_timeout(struct k_work *work)
605605
{
606606
uint32_t timeout_update = UINT32_MAX;
607-
int64_t timeout = k_uptime_get();
607+
int64_t now = k_uptime_get();
608608
struct net_if_dhcpv4 *current, *next;
609609

610610
ARG_UNUSED(work);
@@ -615,7 +615,7 @@ static void dhcpv4_timeout(struct k_work *work)
615615
struct net_if, config);
616616
uint32_t next_timeout;
617617

618-
next_timeout = dhcph4_manage_timers(iface, timeout);
618+
next_timeout = dhcpv4_manage_timers(iface, now);
619619
if (next_timeout < timeout_update) {
620620
timeout_update = next_timeout;
621621
}

0 commit comments

Comments
 (0)