The static analysis tool seems to expect a normal case, for example:
int i = 0; while(i < get_size(var)) { do_something(var[i]); i++; }
However, in your case, the loop control variable is the result of getTime() , and t is the limit.
You can use the real loop control variable. The compiler is probably optimizing it.
void delay(int time_in_ms) { int t = get_time() + time_in_ms; int current_time; do { current_time = getTime(); } while(current_time < t); }
Or you can try to figure out what makes your static analysis tool think that t is a loop control variable. This might help declaring const int t .
source share