I think it is because cppcheck doesn't know that get_time_ms() returns a different value everytime. Is there a way to fix this or should I ignore it? Or maybe I did a silly mistake that I overlooked.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
foo.cpp:26:20:style:Unsignedexpression'time_out'can't be negative so it is unnecessary to test it. [unsignedPositive] while (elapsed <= time_out) { ^foo.cpp:24:24: note: Assignment 'elapsed=0',assignedvalueis0uint32_telapsed=0;^foo.cpp:26:20:note:Unsignedpositivewhile(elapsed<=time_out){^
Hi, I have the following loop which gives me a [duplicateExpression] and a [unsignedPositive] false positives, which I think are related:
I think it is because cppcheck doesn't know that get_time_ms() returns a different value everytime. Is there a way to fix this or should I ignore it? Or maybe I did a silly mistake that I overlooked.
Can you post a minimal example which reproduces the problem?
Hi, apologies for the late reply. Here is a minimal example which reproduces the problem:
I only get one FP:
Ticket is here: https://trac.cppcheck.net/ticket/11982
Last edit: CHR 2023-09-12