From e8182395f771da84ff2d153a9ee28aa0dad2f4ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 22 Nov 2015 17:52:47 +0100 Subject: [PATCH] Fix 'make checkcfg' by adding inline suppressions when obsolete functions are used. --- test/cfg/posix.c | 12 ++++++++++++ test/cfg/std.c | 10 +++++----- test/cfg/std.cpp | 6 +++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/test/cfg/posix.c b/test/cfg/posix.c index ce7df7e27..33fcb60bb 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -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, ®, 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); } diff --git a/test/cfg/std.c b/test/cfg/std.c index b4e02751a..47abe4f3b 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -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); } diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index ef8ce2615..ecfe59e35 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -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); }