changeset 4145:7e27559d009a draft

Compare tv_sec to uint32_t correctly.
author Roy Marples <roy@marples.name>
date Tue, 03 Oct 2017 23:40:50 +0100
parents 5df571e59e25
children 94da5b69f87c
files src/dhcp6.c
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/dhcp6.c	Tue Oct 03 15:50:27 2017 +0100
+++ b/src/dhcp6.c	Tue Oct 03 23:40:50 2017 +0100
@@ -2941,24 +2941,26 @@
 	clock_gettime(CLOCK_MONOTONIC, &now);
 	if (state->state == DH6S_TIMEDOUT || state->state == DH6S_ITIMEDOUT) {
 		struct timespec diff;
+		uint32_t diffsec;
 
 		/* Reduce timers */
 		timespecsub(&now, &state->acquired, &diff);
+		diffsec = (uint32_t)diff.tv_sec;
 		if (state->renew && state->renew != ND6_INFINITE_LIFETIME) {
-			if (state->renew > diff.tv_sec)
-				state->renew -= (uint32_t)diff.tv_sec;
+			if (state->renew > diffsec)
+				state->renew -= diffsec;
 			else
 				state->renew = 0;
 		}
 		if (state->rebind && state->rebind != ND6_INFINITE_LIFETIME) {
-			if (state->rebind > diff.tv_sec)
-				state->rebind -= (uint32_t)diff.tv_sec;
+			if (state->rebind > diffsec)
+				state->rebind -= diffsec;
 			else
 				state->rebind = 0;
 		}
 		if (state->expire && state->expire != ND6_INFINITE_LIFETIME) {
-			if (state->expire > diff.tv_sec)
-				state->expire -= (uint32_t)diff.tv_sec;
+			if (state->expire > diffsec)
+				state->expire -= diffsec;
 			else {
 				if (!(ifp->options->options &
 				    DHCPCD_LASTLEASE_EXTEND))