Skip to content

Commit e0ccfea

Browse files
committed
gnu.cfg: Improved configuration of ffsl() and ffsll()
1 parent 178efb7 commit e0ccfea

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

cfg/gnu.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,8 @@
11611161
int ffsll(long long int i); -->
11621162
<function name="ffsl,ffsll">
11631163
<use-retval/>
1164-
<returnValue type="int"/>
1164+
<!-- It returns the position of the first bit set, or 0 if no bits are set in i. -->
1165+
<returnValue type="int">arg1==0 &amp;0</returnValue>
11651166
<noreturn>false</noreturn>
11661167
<leak-ignore/>
11671168
<arg nr="1" direction="in">

test/cfg/gnu.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@
2222
#include <sys/epoll.h>
2323
#endif
2424

25+
#include <strings.h>
26+
27+
void knownConditionTrueFalse_ffsl(long i)
28+
{
29+
// ffs() returns the position of the first bit set, or 0 if no bits are set in i.
30+
const int x = ffsl(0);
31+
// cppcheck-suppress knownConditionTrueFalse
32+
if (x == 0) {}
33+
if (ffsl(i) == 0) {}
34+
}
35+
36+
void knownConditionTrueFalse_ffsll(long long 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 = ffsll(0);
40+
// cppcheck-suppress knownConditionTrueFalse
41+
if (x == 0) {}
42+
if (ffsll(i) == 0) {}
43+
}
44+
2545
int nullPointer_semtimedop(int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout)
2646
{
2747
(void) semtimedop(semid, sops, nsops, NULL); // If the timeout argument is NULL, then semtimedop() behaves exactly like semop().

test/cfg/posix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
#define _XOPEN_SOURCE
3232
#include <wchar.h>
3333
#include <string.h>
34-
3534
#include <strings.h>
35+
3636
void knownConditionTrueFalse_ffs(int i)
3737
{
3838
// ffs() returns the position of the first bit set, or 0 if no bits are set in i.

0 commit comments

Comments
 (0)