Skip to content

Commit 178efb7

Browse files
committed
posix.cfg: Improved configuration for ffs().
1 parent 9259022 commit 178efb7

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

cfg/posix.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4966,7 +4966,8 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
49664966
<!-- http://man7.org/linux/man-pages/man3/ffs.3.html -->
49674967
<!-- int ffs(int i); -->
49684968
<function name="ffs">
4969-
<returnValue type="int"/>
4969+
<!-- It returns the position of the first bit set, or 0 if no bits are set in i. -->
4970+
<returnValue type="int">arg1==0 &amp;0</returnValue>
49704971
<use-retval/>
49714972
<noreturn>false</noreturn>
49724973
<leak-ignore/>

test/cfg/posix.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@
3232
#include <wchar.h>
3333
#include <string.h>
3434

35+
#include <strings.h>
36+
void knownConditionTrueFalse_ffs(int i)
37+
{
38+
// ffs() returns the position of the first bit set, or 0 if no bits are set in i.
39+
const int x = ffs(0);
40+
// cppcheck-suppress knownConditionTrueFalse
41+
if (x == 0) {}
42+
if (ffs(i) == 0) {}
43+
}
44+
3545
ssize_t nullPointer_readlink(const char *path, char *buf, size_t bufsiz)
3646
{
3747
// cppcheck-suppress nullPointer

0 commit comments

Comments
 (0)