bsd.cfg: Added support for strlcat().

This commit is contained in:
orbitcowboy 2018-05-30 16:47:00 +02:00
parent d412c3908f
commit c7993c38b5
3 changed files with 53 additions and 0 deletions

View File

@ -135,6 +135,28 @@
</arg>
<leak-ignore/>
</function>
<!-- https://www.freebsd.org/cgi/man.cgi?query=strlcat
size_t strlcat(char *dst, const char *src, size_t size); -->
<function name="strlcat">
<returnValue type="size_t"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<not-null/>
<not-uninit/>
<strz/>
<minsize type="argvalue" arg="3"/>
</arg>
<arg nr="2">
<not-null/>
<not-uninit/>
</arg>
<arg nr="3">
<not-uninit/>
<not-bool/>
<valid>0:</valid>
</arg>
</function>
<podtype name="FTS"/>
<podtype name="FTSENT"/>
</def>

28
test/cfg/bsd.c Normal file
View File

@ -0,0 +1,28 @@
// Test library configuration for bsd.cfg
//
// Usage:
// $ cppcheck --library=bsd --check-library --enable=information --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr test/cfg/bsd.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
#include <string.h>
// size_t strlcat(char *dst, const char *src, size_t size);
void uninitvar_strlcat(char *Ct, const char *S, size_t N)
{
char *ct;
char *s;
size_t n;
// cppcheck-suppress uninitvar
(void)strlcat(ct,s,n);
// cppcheck-suppress uninitvar
(void)strlcat(ct,S,N);
// cppcheck-suppress uninitvar
(void)strlcat(Ct,s,N);
// cppcheck-suppress uninitvar
(void)strlcat(Ct,S,n);
// no warning is expected for
(void)strlcat(Ct,S,N);
}

View File

@ -31,6 +31,9 @@ ${CPPCHECK} ${CPPCHECK_OPT} --library=gnu ${DIR}gnu.c
${CXX} ${CXX_OPT} ${DIR}qt.cpp
${CPPCHECK} --enable=style --enable=information --inconclusive --inline-suppr --error-exitcode=1 --library=qt ${DIR}qt.cpp
# bsd.c
${CPPCHECK} ${CPPCHECK_OPT} --library=bsd ${DIR}bsd.c
# std.c
${CC} ${CC_OPT} ${DIR}std.c
${CPPCHECK} ${CPPCHECK_OPT} ${DIR}std.c