posix.cfg: Improved configuration for bzero() and added tests.

This commit is contained in:
orbitcowboy 2022-04-20 20:57:58 +02:00
parent 7c9b9a65b1
commit 1fb1b22bae
2 changed files with 24 additions and 0 deletions

View File

@ -3983,6 +3983,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<leak-ignore/>
<arg nr="1" direction="out">
<not-null/>
<minsize type="argvalue" arg="2"/>
</arg>
<arg nr="2" direction="in">
<not-uninit/>

View File

@ -249,6 +249,29 @@ int nullPointer_bcmp(const void *a, const void *b, size_t n)
return bcmp(NULL, b, n);
}
void nullPointer_bzero(void *s, size_t n)
{
// cppcheck-suppress nullPointer
// cppcheck-suppress bzeroCalled
bzero(NULL,n);
// No nullPointer-warning shall be shown:
// cppcheck-suppress bzeroCalled
bzero(s,n);
}
void bufferAccessOutOfBounds_bzero(void *s, size_t n)
{
char buf[42];
// cppcheck-suppress bufferAccessOutOfBounds
// cppcheck-suppress bzeroCalled
bzero(buf,43);
// cppcheck-suppress bzeroCalled
bzero(buf,42);
// No nullPointer-warning shall be shown:
// cppcheck-suppress bzeroCalled
bzero(s,n);
}
char * nullPointer_stpcpy(char *src, char *dest)
{
// No warning shall be shown: