rtsol(8): Fix loop bug (aggressive-loop-optimizations)
authorJohn Marino <draco@marino.st>
Tue, 10 Feb 2015 21:15:00 +0000 (22:15 +0100)
committerJohn Marino <draco@marino.st>
Tue, 10 Feb 2015 21:15:00 +0000 (22:15 +0100)
The index was being checked for validity after the array was accessed,
putting the check first makes gcc 5.0 happy.

usr.sbin/rtsold/probe.c

index daf5f51..dce8d9f 100644 (file)
@@ -121,7 +121,7 @@ defrouter_probe(int ifindex)
                goto closeandend;
        }
 
-       for(i = 0; dr.defrouter[i].if_index && i < PRLSTSIZ; i++) {
+       for(i = 0; i < PRLSTSIZ && dr.defrouter[i].if_index; i++) {
                if (ifindex && dr.defrouter[i].if_index == ifindex) {
                        /* sanity check */
                        if (!IN6_IS_ADDR_LINKLOCAL(&dr.defrouter[i].rtaddr)) {