int get_delta() { clock_t now_ms = (clock() / (CLOCKS_PER_SEC / 1000)); static clock_t last_clock_ms = now_ms; clock_t delta = now_ms - last_clock_ms; last_clock_ms = now_ms; if (delta > 50) delta = 50; return delta; }
gives
fp.c:7:15: style: Condition 'delta>50' is always false [knownConditionTrueFalse] if (delta > 50) ^ fp.c:3:34: note: last_clock_ms is assigned 'now_ms' here. static clock_t last_clock_ms = now_ms; ^ fp.c:4:28: note: Assignment 'delta=now_ms-last_clock_ms', assigned value is 0 clock_t delta = now_ms - last_clock_ms; ^ fp.c:7:15: note: Condition 'delta>50' is always false if (delta > 50)
which is only true for the first call. this warning was not thrown with 2.5.
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/10534
Log in to post a comment.
gives
which is only true for the first call. this warning was not thrown with 2.5.
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/10534