generate cfg tests: updated NULL pointer testing

This commit is contained in:
Daniel Marjamäki 2018-03-18 19:04:17 +01:00
parent f7d537ea26
commit e932c44ae6
12 changed files with 59625 additions and 42861 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8,254 +8,324 @@
// => 'unmatched suppression' warnings are false negatives.
//
void test__fts_open__noreturn() {
int x = 1;
if (cond) { x=100; fts_open(arg1, arg2, arg3); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__fts_open__noreturn()
{
int x = 1;
if (cond) {
x=100;
fts_open(arg1, arg2, arg3);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__fts_open__arg1__notuninit() {
int x;
// cppcheck-suppress uninitvar
fts_open(x, arg2, arg3);
void test__fts_open__arg1__notuninit()
{
int x;
// cppcheck-suppress uninitvar
fts_open(x, arg2, arg3);
}
void test__fts_open__arg2__notuninit() {
int x;
// cppcheck-suppress uninitvar
fts_open(arg1, x, arg3);
void test__fts_open__arg2__notuninit()
{
int x;
// cppcheck-suppress uninitvar
fts_open(arg1, x, arg3);
}
void test__fts_open__arg3__notnull() {
const char *p = NULL;
// cppcheck-suppress nullPointer
fts_open(arg1, arg2, p);
void test__fts_open__arg3__notnull()
{
// cppcheck-suppress nullPointer
fts_open(arg1, arg2, NULL);
}
void test__fts_open__arg3__notuninit() {
int x[10];
// cppcheck-suppress uninitvar
fts_open(arg1, arg2, x);
void test__fts_open__arg3__notuninit()
{
int x[10];
// cppcheck-suppress uninitvar
fts_open(arg1, arg2, x);
}
void test__fts_read__noreturn() {
int x = 1;
if (cond) { x=100; fts_read(arg1); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__fts_read__noreturn()
{
int x = 1;
if (cond) {
x=100;
fts_read(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__fts_read__arg1__notnull() {
const char *p = NULL;
// cppcheck-suppress nullPointer
fts_read(p);
void test__fts_read__arg1__notnull()
{
// cppcheck-suppress nullPointer
fts_read(NULL);
}
void test__fts_read__arg1__notuninit() {
int x[10];
// cppcheck-suppress uninitvar
fts_read(x);
void test__fts_read__arg1__notuninit()
{
int x[10];
// cppcheck-suppress uninitvar
fts_read(x);
}
void test__readpassphrase__noreturn() {
int x = 1;
if (cond) { x=100; readpassphrase(arg1, arg2); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__readpassphrase__noreturn()
{
int x = 1;
if (cond) {
x=100;
readpassphrase(arg1, arg2);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__readpassphrase__arg1__notuninit() {
int x;
// cppcheck-suppress uninitvar
readpassphrase(x, arg2);
void test__readpassphrase__arg1__notuninit()
{
int x;
// cppcheck-suppress uninitvar
readpassphrase(x, arg2);
}
void test__readpassphrase__arg2__notuninit() {
int x;
// cppcheck-suppress uninitvar
readpassphrase(arg1, x);
void test__readpassphrase__arg2__notuninit()
{
int x;
// cppcheck-suppress uninitvar
readpassphrase(arg1, x);
}
void test__fts_set__noreturn() {
int x = 1;
if (cond) { x=100; fts_set(arg1, arg2, arg3); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__fts_set__noreturn()
{
int x = 1;
if (cond) {
x=100;
fts_set(arg1, arg2, arg3);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__fts_set__arg1__notuninit() {
int x;
// cppcheck-suppress uninitvar
fts_set(x, arg2, arg3);
void test__fts_set__arg1__notuninit()
{
int x;
// cppcheck-suppress uninitvar
fts_set(x, arg2, arg3);
}
void test__fts_set__arg2__notuninit() {
int x;
// cppcheck-suppress uninitvar
fts_set(arg1, x, arg3);
void test__fts_set__arg2__notuninit()
{
int x;
// cppcheck-suppress uninitvar
fts_set(arg1, x, arg3);
}
void test__fts_set__arg3__notuninit() {
int x;
// cppcheck-suppress uninitvar
fts_set(arg1, arg2, x);
void test__fts_set__arg3__notuninit()
{
int x;
// cppcheck-suppress uninitvar
fts_set(arg1, arg2, x);
}
void test__fts_set_clientptr__noreturn() {
int x = 1;
if (cond) { x=100; fts_set_clientptr(arg1, arg2); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__fts_set_clientptr__noreturn()
{
int x = 1;
if (cond) {
x=100;
fts_set_clientptr(arg1, arg2);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__fts_set_clientptr__arg1__notuninit() {
int x;
// cppcheck-suppress uninitvar
fts_set_clientptr(x, arg2);
void test__fts_set_clientptr__arg1__notuninit()
{
int x;
// cppcheck-suppress uninitvar
fts_set_clientptr(x, arg2);
}
void test__fts_set_clientptr__arg2__notuninit() {
int x;
// cppcheck-suppress uninitvar
fts_set_clientptr(arg1, x);
void test__fts_set_clientptr__arg2__notuninit()
{
int x;
// cppcheck-suppress uninitvar
fts_set_clientptr(arg1, x);
}
void test__fts_get_clientptr__noreturn() {
int x = 1;
if (cond) { x=100; fts_get_clientptr(arg1); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__fts_get_clientptr__noreturn()
{
int x = 1;
if (cond) {
x=100;
fts_get_clientptr(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__fts_get_clientptr__arg1__notuninit() {
int x;
// cppcheck-suppress uninitvar
fts_get_clientptr(x);
void test__fts_get_clientptr__arg1__notuninit()
{
int x;
// cppcheck-suppress uninitvar
fts_get_clientptr(x);
}
void test__fts_get_stream__noreturn() {
int x = 1;
if (cond) { x=100; fts_get_stream(arg1); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__fts_get_stream__noreturn()
{
int x = 1;
if (cond) {
x=100;
fts_get_stream(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__fts_get_stream__arg1__notuninit() {
int x;
// cppcheck-suppress uninitvar
fts_get_stream(x);
void test__fts_get_stream__arg1__notuninit()
{
int x;
// cppcheck-suppress uninitvar
fts_get_stream(x);
}
void test__fts_close__noreturn() {
int x = 1;
if (cond) { x=100; fts_close(arg1); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__fts_close__noreturn()
{
int x = 1;
if (cond) {
x=100;
fts_close(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__fts_close__arg1__notuninit() {
int x;
// cppcheck-suppress uninitvar
fts_close(x);
void test__fts_close__arg1__notuninit()
{
int x;
// cppcheck-suppress uninitvar
fts_close(x);
}
void test__readpassphrase__noreturn() {
int x = 1;
if (cond) { x=100; readpassphrase(arg1, arg2, arg3, arg4); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__readpassphrase__noreturn()
{
int x = 1;
if (cond) {
x=100;
readpassphrase(arg1, arg2, arg3, arg4);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__readpassphrase__leakignore() {
char *p = malloc(10); *p=0;
readpassphrase(p, arg2, arg3, arg4);
// cppcheck-suppress memleak
void test__readpassphrase__leakignore()
{
char *p = malloc(10);
*p=0;
readpassphrase(p, arg2, arg3, arg4);
// cppcheck-suppress memleak
}
void test__readpassphrase__arg1__notuninit() {
int x;
// cppcheck-suppress uninitvar
readpassphrase(x, arg2, arg3, arg4);
void test__readpassphrase__arg1__notuninit()
{
int x;
// cppcheck-suppress uninitvar
readpassphrase(x, arg2, arg3, arg4);
}
void test__readpassphrase__arg2__notnull() {
const char *p = NULL;
// cppcheck-suppress nullPointer
readpassphrase(arg1, p, arg3, arg4);
void test__readpassphrase__arg2__notnull()
{
// cppcheck-suppress nullPointer
readpassphrase(arg1, NULL, arg3, arg4);
}
void test__readpassphrase__arg3__notnull() {
const char *p = NULL;
// cppcheck-suppress nullPointer
readpassphrase(arg1, arg2, p, arg4);
void test__readpassphrase__arg3__notnull()
{
// cppcheck-suppress nullPointer
readpassphrase(arg1, arg2, NULL, arg4);
}
void test__readpassphrase__arg3__notuninit() {
int x[10];
// cppcheck-suppress uninitvar
readpassphrase(arg1, arg2, x, arg4);
void test__readpassphrase__arg3__notuninit()
{
int x[10];
// cppcheck-suppress uninitvar
readpassphrase(arg1, arg2, x, arg4);
}
void test__readpassphrase__arg4__notuninit() {
int x;
// cppcheck-suppress uninitvar
readpassphrase(arg1, arg2, arg3, x);
void test__readpassphrase__arg4__notuninit()
{
int x;
// cppcheck-suppress uninitvar
readpassphrase(arg1, arg2, arg3, x);
}
void test__setfib__noreturn() {
int x = 1;
if (cond) { x=100; setfib(arg1); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__setfib__noreturn()
{
int x = 1;
if (cond) {
x=100;
setfib(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__setfib__arg1__notuninit() {
int x;
// cppcheck-suppress uninitvar
setfib(x);
void test__setfib__arg1__notuninit()
{
int x;
// cppcheck-suppress uninitvar
setfib(x);
}
void test__strtonum__noreturn() {
int x = 1;
if (cond) { x=100; strtonum(arg1, arg2, arg3, arg4); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__strtonum__noreturn()
{
int x = 1;
if (cond) {
x=100;
strtonum(arg1, arg2, arg3, arg4);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__strtonum__leakignore() {
char *p = malloc(10); *p=0;
strtonum(p, arg2, arg3, arg4);
// cppcheck-suppress memleak
void test__strtonum__leakignore()
{
char *p = malloc(10);
*p=0;
strtonum(p, arg2, arg3, arg4);
// cppcheck-suppress memleak
}
void test__strtonum__arg1__notnull() {
const char *p = NULL;
// cppcheck-suppress nullPointer
strtonum(p, arg2, arg3, arg4);
void test__strtonum__arg1__notnull()
{
// cppcheck-suppress nullPointer
strtonum(NULL, arg2, arg3, arg4);
}
void test__strtonum__arg1__notuninit() {
int x[10];
// cppcheck-suppress uninitvar
strtonum(x, arg2, arg3, arg4);
void test__strtonum__arg1__notuninit()
{
int x[10];
// cppcheck-suppress uninitvar
strtonum(x, arg2, arg3, arg4);
}
void test__strtonum__arg2__notuninit() {
int x;
// cppcheck-suppress uninitvar
strtonum(arg1, x, arg3, arg4);
void test__strtonum__arg2__notuninit()
{
int x;
// cppcheck-suppress uninitvar
strtonum(arg1, x, arg3, arg4);
}
void test__strtonum__arg3__notuninit() {
int x;
// cppcheck-suppress uninitvar
strtonum(arg1, arg2, x, arg4);
void test__strtonum__arg3__notuninit()
{
int x;
// cppcheck-suppress uninitvar
strtonum(arg1, arg2, x, arg4);
}
void test__strtonum__arg4__notuninit() {
int x;
// cppcheck-suppress uninitvar
strtonum(arg1, arg2, arg3, x);
void test__strtonum__arg4__notuninit()
{
int x;
// cppcheck-suppress uninitvar
strtonum(arg1, arg2, arg3, x);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,122 +8,153 @@
// => 'unmatched suppression' warnings are false negatives.
//
void test__SDL_mutexP__noreturn() {
int x = 1;
if (cond) { x=100; SDL_mutexP(arg1); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__SDL_mutexP__noreturn()
{
int x = 1;
if (cond) {
x=100;
SDL_mutexP(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__SDL_mutexP__arg1__notbool() {
// cppcheck-suppress invalidFunctionArgBool
SDL_mutexP(!x);
void test__SDL_mutexP__arg1__notbool()
{
// cppcheck-suppress invalidFunctionArgBool
SDL_mutexP(!x);
}
void test__SDL_mutexP__arg1__notnull() {
const char *p = NULL;
// cppcheck-suppress nullPointer
SDL_mutexP(p);
void test__SDL_mutexP__arg1__notnull()
{
// cppcheck-suppress nullPointer
SDL_mutexP(NULL);
}
void test__SDL_mutexV__noreturn() {
int x = 1;
if (cond) { x=100; SDL_mutexV(arg1); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__SDL_mutexV__noreturn()
{
int x = 1;
if (cond) {
x=100;
SDL_mutexV(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__SDL_mutexV__arg1__notbool() {
// cppcheck-suppress invalidFunctionArgBool
SDL_mutexV(!x);
void test__SDL_mutexV__arg1__notbool()
{
// cppcheck-suppress invalidFunctionArgBool
SDL_mutexV(!x);
}
void test__SDL_mutexV__arg1__notnull() {
const char *p = NULL;
// cppcheck-suppress nullPointer
SDL_mutexV(p);
void test__SDL_mutexV__arg1__notnull()
{
// cppcheck-suppress nullPointer
SDL_mutexV(NULL);
}
void test__SDL_RWsize__noreturn() {
int x = 1;
if (cond) { x=100; SDL_RWsize(arg1); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__SDL_RWsize__noreturn()
{
int x = 1;
if (cond) {
x=100;
SDL_RWsize(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__SDL_RWsize__arg1__notbool() {
// cppcheck-suppress invalidFunctionArgBool
SDL_RWsize(!x);
void test__SDL_RWsize__arg1__notbool()
{
// cppcheck-suppress invalidFunctionArgBool
SDL_RWsize(!x);
}
void test__SDL_RWsize__arg1__notnull() {
const char *p = NULL;
// cppcheck-suppress nullPointer
SDL_RWsize(p);
void test__SDL_RWsize__arg1__notnull()
{
// cppcheck-suppress nullPointer
SDL_RWsize(NULL);
}
void test__SDL_RWread__noreturn() {
int x = 1;
if (cond) { x=100; SDL_RWread(arg1, arg2); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__SDL_RWread__noreturn()
{
int x = 1;
if (cond) {
x=100;
SDL_RWread(arg1, arg2);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__SDL_RWread__arg1__notbool() {
// cppcheck-suppress invalidFunctionArgBool
SDL_RWread(!x, arg2);
void test__SDL_RWread__arg1__notbool()
{
// cppcheck-suppress invalidFunctionArgBool
SDL_RWread(!x, arg2);
}
void test__SDL_RWread__arg1__notnull() {
const char *p = NULL;
// cppcheck-suppress nullPointer
SDL_RWread(p, arg2);
void test__SDL_RWread__arg1__notnull()
{
// cppcheck-suppress nullPointer
SDL_RWread(NULL, arg2);
}
void test__SDL_RWread__arg2__notbool() {
// cppcheck-suppress invalidFunctionArgBool
SDL_RWread(arg1, !x);
void test__SDL_RWread__arg2__notbool()
{
// cppcheck-suppress invalidFunctionArgBool
SDL_RWread(arg1, !x);
}
void test__SDL_RWread__arg2__notnull() {
const char *p = NULL;
// cppcheck-suppress nullPointer
SDL_RWread(arg1, p);
void test__SDL_RWread__arg2__notnull()
{
// cppcheck-suppress nullPointer
SDL_RWread(arg1, NULL);
}
void test__IMG_isPNG__noreturn() {
int x = 1;
if (cond) { x=100; IMG_isPNG(arg1); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__IMG_isPNG__noreturn()
{
int x = 1;
if (cond) {
x=100;
IMG_isPNG(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__IMG_isPNG__arg1__notbool() {
// cppcheck-suppress invalidFunctionArgBool
IMG_isPNG(!x);
void test__IMG_isPNG__arg1__notbool()
{
// cppcheck-suppress invalidFunctionArgBool
IMG_isPNG(!x);
}
void test__IMG_isPNG__arg1__notnull() {
const char *p = NULL;
// cppcheck-suppress nullPointer
IMG_isPNG(p);
void test__IMG_isPNG__arg1__notnull()
{
// cppcheck-suppress nullPointer
IMG_isPNG(NULL);
}
void test__IMG_isJPG__noreturn() {
int x = 1;
if (cond) { x=100; IMG_isJPG(arg1); }
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
void test__IMG_isJPG__noreturn()
{
int x = 1;
if (cond) {
x=100;
IMG_isJPG(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
}
void test__IMG_isJPG__arg1__notbool() {
// cppcheck-suppress invalidFunctionArgBool
IMG_isJPG(!x);
void test__IMG_isJPG__arg1__notbool()
{
// cppcheck-suppress invalidFunctionArgBool
IMG_isJPG(!x);
}
void test__IMG_isJPG__arg1__notnull() {
const char *p = NULL;
// cppcheck-suppress nullPointer
IMG_isJPG(p);
void test__IMG_isJPG__arg1__notnull()
{
// cppcheck-suppress nullPointer
IMG_isJPG(NULL);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -43,10 +43,10 @@ int main(int argc, char **argv)
return 1;
}
std::string testfile(cfgfile);
if (testfile.find('/') != std::string::npos)
testfile = testfile.substr(testfile.rfind('/')+1);
testfile = "generated-cfg-tests-" + testfile.substr(0,testfile.find('.')) + ".cpp";
std::string testfile(cfgfile);
if (testfile.find('/') != std::string::npos)
testfile = testfile.substr(testfile.rfind('/')+1);
testfile = "generated-cfg-tests-" + testfile.substr(0,testfile.find('.')) + ".cpp";
std::cout << "// auto generated tests from " << cfgfile << std::endl;
std::cout << "//" << std::endl;
@ -192,7 +192,7 @@ static void testfunction(const tinyxml2::XMLElement *node, const std::string &fu
}
if (notnull) {
std::cout << testFunctionArg(functionName, useretval, "notnull", argNr, numberOfArgs, "const char *p = NULL;", "nullPointer", "p") << std::endl << std::endl;
std::cout << testFunctionArg(functionName, useretval, "notnull", argNr, numberOfArgs, "", "nullPointer", "NULL") << std::endl << std::endl;
}
if (notuninit) {