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. // => 'unmatched suppression' warnings are false negatives.
// //
void test__fts_open__noreturn() { void test__fts_open__noreturn()
int x = 1; {
if (cond) { x=100; fts_open(arg1, arg2, arg3); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
fts_open(arg1, arg2, arg3);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__fts_open__arg1__notuninit() { void test__fts_open__arg1__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
fts_open(x, arg2, arg3); // cppcheck-suppress uninitvar
fts_open(x, arg2, arg3);
} }
void test__fts_open__arg2__notuninit() { void test__fts_open__arg2__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
fts_open(arg1, x, arg3); // cppcheck-suppress uninitvar
fts_open(arg1, x, arg3);
} }
void test__fts_open__arg3__notnull() { void test__fts_open__arg3__notnull()
const char *p = NULL; {
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
fts_open(arg1, arg2, p); fts_open(arg1, arg2, NULL);
} }
void test__fts_open__arg3__notuninit() { void test__fts_open__arg3__notuninit()
int x[10]; {
// cppcheck-suppress uninitvar int x[10];
fts_open(arg1, arg2, x); // cppcheck-suppress uninitvar
fts_open(arg1, arg2, x);
} }
void test__fts_read__noreturn() { void test__fts_read__noreturn()
int x = 1; {
if (cond) { x=100; fts_read(arg1); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
fts_read(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__fts_read__arg1__notnull() { void test__fts_read__arg1__notnull()
const char *p = NULL; {
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
fts_read(p); fts_read(NULL);
} }
void test__fts_read__arg1__notuninit() { void test__fts_read__arg1__notuninit()
int x[10]; {
// cppcheck-suppress uninitvar int x[10];
fts_read(x); // cppcheck-suppress uninitvar
fts_read(x);
} }
void test__readpassphrase__noreturn() { void test__readpassphrase__noreturn()
int x = 1; {
if (cond) { x=100; readpassphrase(arg1, arg2); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
readpassphrase(arg1, arg2);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__readpassphrase__arg1__notuninit() { void test__readpassphrase__arg1__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
readpassphrase(x, arg2); // cppcheck-suppress uninitvar
readpassphrase(x, arg2);
} }
void test__readpassphrase__arg2__notuninit() { void test__readpassphrase__arg2__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
readpassphrase(arg1, x); // cppcheck-suppress uninitvar
readpassphrase(arg1, x);
} }
void test__fts_set__noreturn() { void test__fts_set__noreturn()
int x = 1; {
if (cond) { x=100; fts_set(arg1, arg2, arg3); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
fts_set(arg1, arg2, arg3);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__fts_set__arg1__notuninit() { void test__fts_set__arg1__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
fts_set(x, arg2, arg3); // cppcheck-suppress uninitvar
fts_set(x, arg2, arg3);
} }
void test__fts_set__arg2__notuninit() { void test__fts_set__arg2__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
fts_set(arg1, x, arg3); // cppcheck-suppress uninitvar
fts_set(arg1, x, arg3);
} }
void test__fts_set__arg3__notuninit() { void test__fts_set__arg3__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
fts_set(arg1, arg2, x); // cppcheck-suppress uninitvar
fts_set(arg1, arg2, x);
} }
void test__fts_set_clientptr__noreturn() { void test__fts_set_clientptr__noreturn()
int x = 1; {
if (cond) { x=100; fts_set_clientptr(arg1, arg2); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
fts_set_clientptr(arg1, arg2);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__fts_set_clientptr__arg1__notuninit() { void test__fts_set_clientptr__arg1__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
fts_set_clientptr(x, arg2); // cppcheck-suppress uninitvar
fts_set_clientptr(x, arg2);
} }
void test__fts_set_clientptr__arg2__notuninit() { void test__fts_set_clientptr__arg2__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
fts_set_clientptr(arg1, x); // cppcheck-suppress uninitvar
fts_set_clientptr(arg1, x);
} }
void test__fts_get_clientptr__noreturn() { void test__fts_get_clientptr__noreturn()
int x = 1; {
if (cond) { x=100; fts_get_clientptr(arg1); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
fts_get_clientptr(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__fts_get_clientptr__arg1__notuninit() { void test__fts_get_clientptr__arg1__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
fts_get_clientptr(x); // cppcheck-suppress uninitvar
fts_get_clientptr(x);
} }
void test__fts_get_stream__noreturn() { void test__fts_get_stream__noreturn()
int x = 1; {
if (cond) { x=100; fts_get_stream(arg1); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
fts_get_stream(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__fts_get_stream__arg1__notuninit() { void test__fts_get_stream__arg1__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
fts_get_stream(x); // cppcheck-suppress uninitvar
fts_get_stream(x);
} }
void test__fts_close__noreturn() { void test__fts_close__noreturn()
int x = 1; {
if (cond) { x=100; fts_close(arg1); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
fts_close(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__fts_close__arg1__notuninit() { void test__fts_close__arg1__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
fts_close(x); // cppcheck-suppress uninitvar
fts_close(x);
} }
void test__readpassphrase__noreturn() { void test__readpassphrase__noreturn()
int x = 1; {
if (cond) { x=100; readpassphrase(arg1, arg2, arg3, arg4); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
readpassphrase(arg1, arg2, arg3, arg4);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__readpassphrase__leakignore() { void test__readpassphrase__leakignore()
char *p = malloc(10); *p=0; {
readpassphrase(p, arg2, arg3, arg4); char *p = malloc(10);
// cppcheck-suppress memleak *p=0;
readpassphrase(p, arg2, arg3, arg4);
// cppcheck-suppress memleak
} }
void test__readpassphrase__arg1__notuninit() { void test__readpassphrase__arg1__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
readpassphrase(x, arg2, arg3, arg4); // cppcheck-suppress uninitvar
readpassphrase(x, arg2, arg3, arg4);
} }
void test__readpassphrase__arg2__notnull() { void test__readpassphrase__arg2__notnull()
const char *p = NULL; {
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
readpassphrase(arg1, p, arg3, arg4); readpassphrase(arg1, NULL, arg3, arg4);
} }
void test__readpassphrase__arg3__notnull() { void test__readpassphrase__arg3__notnull()
const char *p = NULL; {
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
readpassphrase(arg1, arg2, p, arg4); readpassphrase(arg1, arg2, NULL, arg4);
} }
void test__readpassphrase__arg3__notuninit() { void test__readpassphrase__arg3__notuninit()
int x[10]; {
// cppcheck-suppress uninitvar int x[10];
readpassphrase(arg1, arg2, x, arg4); // cppcheck-suppress uninitvar
readpassphrase(arg1, arg2, x, arg4);
} }
void test__readpassphrase__arg4__notuninit() { void test__readpassphrase__arg4__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
readpassphrase(arg1, arg2, arg3, x); // cppcheck-suppress uninitvar
readpassphrase(arg1, arg2, arg3, x);
} }
void test__setfib__noreturn() { void test__setfib__noreturn()
int x = 1; {
if (cond) { x=100; setfib(arg1); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
setfib(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__setfib__arg1__notuninit() { void test__setfib__arg1__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
setfib(x); // cppcheck-suppress uninitvar
setfib(x);
} }
void test__strtonum__noreturn() { void test__strtonum__noreturn()
int x = 1; {
if (cond) { x=100; strtonum(arg1, arg2, arg3, arg4); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
strtonum(arg1, arg2, arg3, arg4);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__strtonum__leakignore() { void test__strtonum__leakignore()
char *p = malloc(10); *p=0; {
strtonum(p, arg2, arg3, arg4); char *p = malloc(10);
// cppcheck-suppress memleak *p=0;
strtonum(p, arg2, arg3, arg4);
// cppcheck-suppress memleak
} }
void test__strtonum__arg1__notnull() { void test__strtonum__arg1__notnull()
const char *p = NULL; {
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
strtonum(p, arg2, arg3, arg4); strtonum(NULL, arg2, arg3, arg4);
} }
void test__strtonum__arg1__notuninit() { void test__strtonum__arg1__notuninit()
int x[10]; {
// cppcheck-suppress uninitvar int x[10];
strtonum(x, arg2, arg3, arg4); // cppcheck-suppress uninitvar
strtonum(x, arg2, arg3, arg4);
} }
void test__strtonum__arg2__notuninit() { void test__strtonum__arg2__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
strtonum(arg1, x, arg3, arg4); // cppcheck-suppress uninitvar
strtonum(arg1, x, arg3, arg4);
} }
void test__strtonum__arg3__notuninit() { void test__strtonum__arg3__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
strtonum(arg1, arg2, x, arg4); // cppcheck-suppress uninitvar
strtonum(arg1, arg2, x, arg4);
} }
void test__strtonum__arg4__notuninit() { void test__strtonum__arg4__notuninit()
int x; {
// cppcheck-suppress uninitvar int x;
strtonum(arg1, arg2, arg3, 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. // => 'unmatched suppression' warnings are false negatives.
// //
void test__SDL_mutexP__noreturn() { void test__SDL_mutexP__noreturn()
int x = 1; {
if (cond) { x=100; SDL_mutexP(arg1); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
SDL_mutexP(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__SDL_mutexP__arg1__notbool() { void test__SDL_mutexP__arg1__notbool()
// cppcheck-suppress invalidFunctionArgBool {
SDL_mutexP(!x); // cppcheck-suppress invalidFunctionArgBool
SDL_mutexP(!x);
} }
void test__SDL_mutexP__arg1__notnull() { void test__SDL_mutexP__arg1__notnull()
const char *p = NULL; {
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
SDL_mutexP(p); SDL_mutexP(NULL);
} }
void test__SDL_mutexV__noreturn() { void test__SDL_mutexV__noreturn()
int x = 1; {
if (cond) { x=100; SDL_mutexV(arg1); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
SDL_mutexV(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__SDL_mutexV__arg1__notbool() { void test__SDL_mutexV__arg1__notbool()
// cppcheck-suppress invalidFunctionArgBool {
SDL_mutexV(!x); // cppcheck-suppress invalidFunctionArgBool
SDL_mutexV(!x);
} }
void test__SDL_mutexV__arg1__notnull() { void test__SDL_mutexV__arg1__notnull()
const char *p = NULL; {
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
SDL_mutexV(p); SDL_mutexV(NULL);
} }
void test__SDL_RWsize__noreturn() { void test__SDL_RWsize__noreturn()
int x = 1; {
if (cond) { x=100; SDL_RWsize(arg1); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
SDL_RWsize(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__SDL_RWsize__arg1__notbool() { void test__SDL_RWsize__arg1__notbool()
// cppcheck-suppress invalidFunctionArgBool {
SDL_RWsize(!x); // cppcheck-suppress invalidFunctionArgBool
SDL_RWsize(!x);
} }
void test__SDL_RWsize__arg1__notnull() { void test__SDL_RWsize__arg1__notnull()
const char *p = NULL; {
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
SDL_RWsize(p); SDL_RWsize(NULL);
} }
void test__SDL_RWread__noreturn() { void test__SDL_RWread__noreturn()
int x = 1; {
if (cond) { x=100; SDL_RWread(arg1, arg2); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
SDL_RWread(arg1, arg2);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__SDL_RWread__arg1__notbool() { void test__SDL_RWread__arg1__notbool()
// cppcheck-suppress invalidFunctionArgBool {
SDL_RWread(!x, arg2); // cppcheck-suppress invalidFunctionArgBool
SDL_RWread(!x, arg2);
} }
void test__SDL_RWread__arg1__notnull() { void test__SDL_RWread__arg1__notnull()
const char *p = NULL; {
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
SDL_RWread(p, arg2); SDL_RWread(NULL, arg2);
} }
void test__SDL_RWread__arg2__notbool() { void test__SDL_RWread__arg2__notbool()
// cppcheck-suppress invalidFunctionArgBool {
SDL_RWread(arg1, !x); // cppcheck-suppress invalidFunctionArgBool
SDL_RWread(arg1, !x);
} }
void test__SDL_RWread__arg2__notnull() { void test__SDL_RWread__arg2__notnull()
const char *p = NULL; {
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
SDL_RWread(arg1, p); SDL_RWread(arg1, NULL);
} }
void test__IMG_isPNG__noreturn() { void test__IMG_isPNG__noreturn()
int x = 1; {
if (cond) { x=100; IMG_isPNG(arg1); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
IMG_isPNG(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__IMG_isPNG__arg1__notbool() { void test__IMG_isPNG__arg1__notbool()
// cppcheck-suppress invalidFunctionArgBool {
IMG_isPNG(!x); // cppcheck-suppress invalidFunctionArgBool
IMG_isPNG(!x);
} }
void test__IMG_isPNG__arg1__notnull() { void test__IMG_isPNG__arg1__notnull()
const char *p = NULL; {
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
IMG_isPNG(p); IMG_isPNG(NULL);
} }
void test__IMG_isJPG__noreturn() { void test__IMG_isJPG__noreturn()
int x = 1; {
if (cond) { x=100; IMG_isJPG(arg1); } int x = 1;
// cppcheck-suppress shiftTooManyBits if (cond) {
x = 1 << x; x=100;
IMG_isJPG(arg1);
}
// cppcheck-suppress shiftTooManyBits
x = 1 << x;
} }
void test__IMG_isJPG__arg1__notbool() { void test__IMG_isJPG__arg1__notbool()
// cppcheck-suppress invalidFunctionArgBool {
IMG_isJPG(!x); // cppcheck-suppress invalidFunctionArgBool
IMG_isJPG(!x);
} }
void test__IMG_isJPG__arg1__notnull() { void test__IMG_isJPG__arg1__notnull()
const char *p = NULL; {
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
IMG_isJPG(p); 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; return 1;
} }
std::string testfile(cfgfile); std::string testfile(cfgfile);
if (testfile.find('/') != std::string::npos) if (testfile.find('/') != std::string::npos)
testfile = testfile.substr(testfile.rfind('/')+1); testfile = testfile.substr(testfile.rfind('/')+1);
testfile = "generated-cfg-tests-" + testfile.substr(0,testfile.find('.')) + ".cpp"; testfile = "generated-cfg-tests-" + testfile.substr(0,testfile.find('.')) + ".cpp";
std::cout << "// auto generated tests from " << cfgfile << std::endl; std::cout << "// auto generated tests from " << cfgfile << std::endl;
std::cout << "//" << std::endl; std::cout << "//" << std::endl;
@ -192,7 +192,7 @@ static void testfunction(const tinyxml2::XMLElement *node, const std::string &fu
} }
if (notnull) { 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) { if (notuninit) {