]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Compare tv_sec to uint32_t correctly.
authorRoy Marples <roy@marples.name>
Tue, 3 Oct 2017 22:40:50 +0000 (23:40 +0100)
committerRoy Marples <roy@marples.name>
Tue, 3 Oct 2017 22:40:50 +0000 (23:40 +0100)
src/dhcp6.c

index 4ebc331fcc1156c974167dcb1af3471d2869a638..7505ce0c6d408e17bd3675c3527e5619c7f79f4b 100644 (file)
@@ -2941,24 +2941,26 @@ dhcp6_bind(struct interface *ifp, const char *op)
        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))