[Babel-users] route.c:1071: possible coding error ?

David Binderman dcb314 at hotmail.com
Thu Apr 21 10:37:28 UTC 2016


Hello there,

route.c:1071:9: warning: variable 'i' is incremented both in the loop header and in the loop body [-Wfor-loop-analysis]

Source code is

    for(i = 0; i < route_slots; i++) {
        struct babel_route *r = routes[i];
        while(r) {
            if(r->neigh == neigh) {
                if(r->refmetric != INFINITY) {
                    unsigned short oldmetric = route_metric(r);
                    retract_route(r);
                    if(oldmetric != INFINITY)
                        route_changed(r, r->src, oldmetric);
                }
            }
            r = r->next;
        }
        i++;
    }

So the for loop in i only does even numbered slots. I am not sure if this is
intentional or not. If it is, a comment might be a good idea.


Regards

David Binderman

 		 	   		  


More information about the Babel-users mailing list