From 115cefc8fbdd07544296d811a68940b9adc61450 Mon Sep 17 00:00:00 2001 From: Alexander Mai Date: Mon, 16 Feb 2015 22:06:08 +0100 Subject: [PATCH] #6181 Drop redundantGetAndSetUserId. Ensure (style-) warnings are issued if setuid()/getuid() and some related functions are ignored. Move strdupa()/strndupa() from posix.cfg to gnu.cfg --- test/cfg/gnu.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/cfg/gnu.c diff --git a/test/cfg/gnu.c b/test/cfg/gnu.c new file mode 100644 index 000000000..f21711dbb --- /dev/null +++ b/test/cfg/gnu.c @@ -0,0 +1,22 @@ + +// Test library configuration for gnu.cfg +// +// Usage: +// $ cppcheck --check-library --library=gnu --enable=information --enable=style --error-exitcode=1 --inline-suppr test/cfg/gnu.c +// => +// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 +// + +#include +#include + +void leakReturnValNotUsed() { + // cppcheck-suppress unreadVariable + char* ptr = strdupa("test"); + // cppcheck-suppress ignoredReturnValue + strdupa("test"); + // cppcheck-suppress unreadVariable + char* ptr2 = strndupa("test", 1); + // cppcheck-suppress ignoredReturnValue + strndupa("test", 1); +}