From c7993c38b5a15b4f3bd5abba8452297e37dc14ee Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Wed, 30 May 2018 16:47:00 +0200 Subject: [PATCH] bsd.cfg: Added support for strlcat(). --- cfg/bsd.cfg | 22 ++++++++++++++++++++++ test/cfg/bsd.c | 28 ++++++++++++++++++++++++++++ test/cfg/runtests.sh | 3 +++ 3 files changed, 53 insertions(+) create mode 100644 test/cfg/bsd.c diff --git a/cfg/bsd.cfg b/cfg/bsd.cfg index 98e8db603..68e932c69 100644 --- a/cfg/bsd.cfg +++ b/cfg/bsd.cfg @@ -135,6 +135,28 @@ + + + + false + + + + + + + + + + + + + + + 0: + + diff --git a/test/cfg/bsd.c b/test/cfg/bsd.c new file mode 100644 index 000000000..44227b71a --- /dev/null +++ b/test/cfg/bsd.c @@ -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 + +// 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); +} diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index bdc6175d5..042af9fed 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -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