Fix 'make checkcfg' by adding inline suppressions when obsolete functions are used.

This commit is contained in:
Daniel Marjamäki 2015-11-22 17:52:47 +01:00
parent b7030fcfa1
commit e8182395f7
3 changed files with 20 additions and 8 deletions

View File

@ -51,8 +51,10 @@ void nullPointer(char *p)
mkdir(p, 0);
getcwd(0, 0);
// cppcheck-suppress nullPointer
// cppcheck-suppress readdirCalled
readdir(0);
// cppcheck-suppress nullPointer
// cppcheck-suppress utimeCalled
utime(NULL, NULL);
}
@ -135,10 +137,14 @@ void ignoredReturnValue(void *addr, int fd)
void invalidFunctionArg()
{
// cppcheck-suppress invalidFunctionArg
// cppcheck-suppress usleepCalled
usleep(-1);
// cppcheck-suppress usleepCalled
usleep(0);
// cppcheck-suppress usleepCalled
usleep(999999);
// cppcheck-suppress invalidFunctionArg
// cppcheck-suppress usleepCalled
usleep(1000000);
}
@ -171,15 +177,19 @@ void uninitvar(int fd)
regerror(0, &reg, 0, 0);
// cppcheck-suppress uninitvar
// cppcheck-suppress unreadVariable
// cppcheck-suppress ecvtCalled
char *buffer = ecvt(d, 11, &decimal, &sign);
// cppcheck-suppress gcvtCalled
gcvt(3.141, 2, buf);
char *filename;
struct utimbuf *times;
// cppcheck-suppress uninitvar
// cppcheck-suppress utimeCalled
utime(filename, times);
struct timeval times1[2];
// cppcheck-suppress uninitvar
// cppcheck-suppress utimeCalled
utime(filename, times1);
}
@ -211,9 +221,11 @@ void timet_h(struct timespec* ptp1)
// cppcheck-suppress uninitvar
clock_settime(CLOCK_REALTIME, &tp); // #6577 - false negative
// cppcheck-suppress uninitvar
// cppcheck-suppress clock_settimeCalled
clock_settime(clk_id, &tp);
time_t clock = time(0);
char buf[26];
// cppcheck-suppress ctime_rCalled
ctime_r(&clock, buf);
}

View File

@ -424,7 +424,7 @@ void uninitvar_asctime(void)
{
const struct tm *tm;
// cppcheck-suppress uninitvar
// cppcheck-suppress obsoleteFunctionsasctime
// cppcheck-suppress asctimeCalled
(void)asctime(tm);
}
@ -1636,7 +1636,7 @@ void uninitvar_getenv(void)
void uninitvar_gets(void)
{
char *buffer;
// cppcheck-suppress obsoleteFunctionsgets
// cppcheck-suppress getsCalled
// cppcheck-suppress uninitvar
(void)gets(buffer);
}
@ -2394,7 +2394,7 @@ void uninitvar_malloc(void)
void uninitvar_alloca(void)
{
size_t size;
// cppcheck-suppress obsoleteFunctionsalloca
// cppcheck-suppress allocaCalled
// cppcheck-suppress uninitvar
(void)alloca(size);
}
@ -3585,10 +3585,10 @@ void ignoredReturnValue_abs(int i)
void nullPointer_asctime(void)
{
struct tm *tm = 0;
// cppcheck-suppress obsoleteFunctionsasctime
// cppcheck-suppress asctimeCalled
// cppcheck-suppress nullPointer
(void)asctime(tm);
// cppcheck-suppress obsoleteFunctionsasctime
// cppcheck-suppress asctimeCalled
// cppcheck-suppress nullPointer
(void)asctime(0);
}

View File

@ -166,7 +166,7 @@ void uninitvar_asctime(void)
{
const struct tm *tm;
// cppcheck-suppress uninitvar
// cppcheck-suppress obsoleteFunctionsasctime
// cppcheck-suppress asctimeCalled
(void)std::asctime(tm);
}
@ -3018,10 +3018,10 @@ void ignoredReturnValue_abs(int i)
void nullPointer_asctime(void)
{
struct tm *tm = 0;
// cppcheck-suppress obsoleteFunctionsasctime
// cppcheck-suppress asctimeCalled
// cppcheck-suppress nullPointer
(void)std::asctime(tm);
// cppcheck-suppress obsoleteFunctionsasctime
// cppcheck-suppress asctimeCalled
// cppcheck-suppress nullPointer
(void)std::asctime(0);
}