gnu.cfg: Added support for '__builtin_memset'.

This commit is contained in:
orbitcowboy 2018-10-27 18:25:05 +02:00
parent adbbadec7f
commit b998dcb5aa
2 changed files with 42 additions and 0 deletions

View File

@ -24,6 +24,24 @@
</arg>
<leak-ignore/>
</function>
<!-- void *__builtin_memset(void *s, int c, size_t n); -->
<function name="__builtin_memset">
<returnValue type="void *"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<not-null/>
<minsize type="argvalue" arg="3"/>
</arg>
<arg nr="2">
<not-uninit/>
</arg>
<arg nr="3">
<not-uninit/>
<not-bool/>
<valid>0:</valid>
</arg>
</function>
<!-- long long atoq(const char *nptr); -->
<function name="atoq">
<returnValue type="long long"/>

View File

@ -8,10 +8,34 @@
//
#include <string.h>
#include <stdlib.h>
#ifndef __CYGWIN__
#include <sys/epoll.h>
#endif
void ignoreleak(void)
{
char *p = (char *)malloc(10);
__builtin_memset(&(p[0]), 0, 10);
// cppcheck-suppress memleak
}
void uninitvar__builtin_memset(void)
{
void *s;
int c;
size_t n;
// cppcheck-suppress uninitvar
(void)__builtin_memset(s,c,n);
}
void bufferAccessOutOfBounds__builtin_memset(void)
{
uint8_t buf[42];
// cppcheck-suppress bufferAccessOutOfBounds
(void)__builtin_memset(buf,0,1000);
}
void bufferAccessOutOfBounds()
{
char buf[2];