Aaron Danen - 3 hours ago
void f() {
    const int y = ffs(5);
    if (y == 0) {}
}

analyzing with ./cppcheck --enable=all --library=posix throws

Checking examples/ffs.c ...
examples/ffs.c:3:11: style: Condition 'y==0' is always true [knownConditionTrueFalse]
    if (y == 0) {}
          ^
examples/ffs.c:2:22: note: Assignment 'y=ffs(5)', assigned value is 0
    const int y = ffs(5);
                     ^
examples/ffs.c:3:11: note: Condition 'y==0' is always true
    if (y == 0) {}
          ^

it is because in cfg/posix.cfg the return value is calculated as

    <returnValue type="int">arg1==0 &amp;0</returnValue>

which is always 0.

Also, in cfg/gnu.cfg, we have the same implementation for ffsl(x) and ffsll(x) which causes the same bug.

Maybe we could replace the implementation with something like this:

arg1==0?0:__cppcheck_unknown()