Skip to content

Commit 051512d

Browse files
committed
bsd.cfg: Added support for pwritev(), preadv(), writev() and writev().
1 parent b315e8a commit 051512d

2 files changed

Lines changed: 115 additions & 0 deletions

File tree

cfg/bsd.cfg

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,92 @@
218218
<valid>0:</valid>
219219
</arg>
220220
</function>
221+
<!-- https://linux.die.net/man/2/writev -->
222+
<!-- ssize_t readv(int fd, const struct iovec *iov, int iovcnt); -->
223+
<function name="readv">
224+
<leak-ignore/>
225+
<returnValue type="ssize_t"/>
226+
<arg nr="1" direction="in">
227+
<not-uninit/>
228+
<not-bool/>
229+
<valid>0:</valid>
230+
</arg>
231+
<arg nr="2" direction="out">
232+
<not-null/>
233+
</arg>
234+
<arg nr="3" direction="in">
235+
<not-uninit/>
236+
<not-bool/>
237+
<valid>0:</valid>
238+
</arg>
239+
</function>
240+
<!-- https://linux.die.net/man/2/writev -->
241+
<!-- ssize_t writev(int fd, const struct iovec *iov, int iovcnt); -->
242+
<function name="writev">
243+
<leak-ignore/>
244+
<returnValue type="ssize_t"/>
245+
<arg nr="1" direction="in">
246+
<not-uninit/>
247+
<not-bool/>
248+
<valid>0:</valid>
249+
</arg>
250+
<arg nr="2" direction="in">
251+
<not-null/>
252+
</arg>
253+
<arg nr="3" direction="in">
254+
<not-uninit/>
255+
<not-bool/>
256+
<valid>0:</valid>
257+
</arg>
258+
</function>
259+
<!-- https://linux.die.net/man/2/writev -->
260+
<!-- ssize_t preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset); -->
261+
<function name="preadv">
262+
<leak-ignore/>
263+
<returnValue type="ssize_t"/>
264+
<arg nr="1" direction="in">
265+
<not-uninit/>
266+
<not-bool/>
267+
<valid>0:</valid>
268+
</arg>
269+
<arg nr="2" direction="out">
270+
<not-null/>
271+
</arg>
272+
<arg nr="3" direction="in">
273+
<not-uninit/>
274+
<not-bool/>
275+
<valid>0:</valid>
276+
</arg>
277+
<arg nr="4" direction="in">
278+
<not-uninit/>
279+
<not-bool/>
280+
<valid>0:</valid>
281+
</arg>
282+
</function>
283+
<!-- https://linux.die.net/man/2/writev -->
284+
<!-- ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset); -->
285+
<function name="pwritev">
286+
<leak-ignore/>
287+
<returnValue type="ssize_t"/>
288+
<arg nr="1" direction="in">
289+
<not-uninit/>
290+
<not-bool/>
291+
<valid>0:</valid>
292+
</arg>
293+
<arg nr="2" direction="in">
294+
<not-null/>
295+
</arg>
296+
<arg nr="3" direction="in">
297+
<not-uninit/>
298+
<not-bool/>
299+
<valid>0:</valid>
300+
</arg>
301+
<arg nr="4" direction="in">
302+
<not-uninit/>
303+
<not-bool/>
304+
<valid>0:</valid>
305+
</arg>
306+
</function>
221307
<!-- https://www.freebsd.org/cgi/man.cgi?query=arc4random -->
222308
<!-- uint32_t arc4random(void); -->
223309
<function name="arc4random">

test/cfg/bsd.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <stdlib.h>
1111
#include <stdint.h>
1212
#include <sys/time.h>
13+
#include <sys/uio.h>
1314

1415
// #9323, #9331
1516
void verify_timercmp(struct timeval t)
@@ -22,6 +23,34 @@ void verify_timercmp(struct timeval t)
2223
(void)timercmp(&t, &t, >);
2324
}
2425

26+
ssize_t nullPointer_readv(int fd, const struct iovec *iov, int iovcnt)
27+
{
28+
// cppcheck-suppress nullPointer
29+
(void)readv(fd,NULL,iovcnt);
30+
return readv(fd,iov,iovcnt);
31+
}
32+
33+
ssize_t nullPointer_writev(int fd, const struct iovec *iov, int iovcnt)
34+
{
35+
// cppcheck-suppress nullPointer
36+
(void)writev(fd,NULL,iovcnt);
37+
return writev(fd,iov,iovcnt);
38+
}
39+
40+
ssize_t nullPointer_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
41+
{
42+
// cppcheck-suppress nullPointer
43+
(void)preadv(fd,NULL,iovcnt,offset);
44+
return preadv(fd,iov,iovcnt,offset);
45+
}
46+
47+
ssize_t nullPointer_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
48+
{
49+
// cppcheck-suppress nullPointer
50+
(void)pwritev(fd,NULL,iovcnt,offset);
51+
return pwritev(fd,iov,iovcnt,offset);
52+
}
53+
2554
// False negative: #9346
2655
void uninitvar_timercmp(struct timeval t)
2756
{

0 commit comments

Comments
 (0)