#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

This commit is contained in:
Alexander Mai 2015-02-16 22:06:08 +01:00
parent 42b40b0c85
commit 115cefc8fb
1 changed files with 22 additions and 0 deletions

22
test/cfg/gnu.c Normal file
View File

@ -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 <string.h>
#include <unistd.h>
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);
}