posix.cfg: Improved configuration for ffs().

This commit is contained in:
orbitcowboy 2022-05-01 15:24:57 +02:00
parent 925902245f
commit 178efb7058
2 changed files with 12 additions and 1 deletions

View File

@ -4966,7 +4966,8 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<!-- http://man7.org/linux/man-pages/man3/ffs.3.html -->
<!-- int ffs(int i); -->
<function name="ffs">
<returnValue type="int"/>
<!-- It returns the position of the first bit set, or 0 if no bits are set in i. -->
<returnValue type="int">arg1==0 &amp;0</returnValue>
<use-retval/>
<noreturn>false</noreturn>
<leak-ignore/>

View File

@ -32,6 +32,16 @@
#include <wchar.h>
#include <string.h>
#include <strings.h>
void knownConditionTrueFalse_ffs(int i)
{
// ffs() returns the position of the first bit set, or 0 if no bits are set in i.
const int x = ffs(0);
// cppcheck-suppress knownConditionTrueFalse
if (x == 0) {}
if (ffs(i) == 0) {}
}
ssize_t nullPointer_readlink(const char *path, char *buf, size_t bufsiz)
{
// cppcheck-suppress nullPointer