Skip to content

Commit e818239

Browse files
committed
Fix 'make checkcfg' by adding inline suppressions when obsolete functions are used.
1 parent b7030fc commit e818239

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

test/cfg/posix.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ void nullPointer(char *p)
5151
mkdir(p, 0);
5252
getcwd(0, 0);
5353
// cppcheck-suppress nullPointer
54+
// cppcheck-suppress readdirCalled
5455
readdir(0);
5556
// cppcheck-suppress nullPointer
57+
// cppcheck-suppress utimeCalled
5658
utime(NULL, NULL);
5759
}
5860

@@ -135,10 +137,14 @@ void ignoredReturnValue(void *addr, int fd)
135137
void invalidFunctionArg()
136138
{
137139
// cppcheck-suppress invalidFunctionArg
140+
// cppcheck-suppress usleepCalled
138141
usleep(-1);
142+
// cppcheck-suppress usleepCalled
139143
usleep(0);
144+
// cppcheck-suppress usleepCalled
140145
usleep(999999);
141146
// cppcheck-suppress invalidFunctionArg
147+
// cppcheck-suppress usleepCalled
142148
usleep(1000000);
143149
}
144150

@@ -171,15 +177,19 @@ void uninitvar(int fd)
171177
regerror(0, &reg, 0, 0);
172178
// cppcheck-suppress uninitvar
173179
// cppcheck-suppress unreadVariable
180+
// cppcheck-suppress ecvtCalled
174181
char *buffer = ecvt(d, 11, &decimal, &sign);
182+
// cppcheck-suppress gcvtCalled
175183
gcvt(3.141, 2, buf);
176184

177185
char *filename;
178186
struct utimbuf *times;
179187
// cppcheck-suppress uninitvar
188+
// cppcheck-suppress utimeCalled
180189
utime(filename, times);
181190
struct timeval times1[2];
182191
// cppcheck-suppress uninitvar
192+
// cppcheck-suppress utimeCalled
183193
utime(filename, times1);
184194
}
185195

@@ -211,9 +221,11 @@ void timet_h(struct timespec* ptp1)
211221
// cppcheck-suppress uninitvar
212222
clock_settime(CLOCK_REALTIME, &tp); // #6577 - false negative
213223
// cppcheck-suppress uninitvar
224+
// cppcheck-suppress clock_settimeCalled
214225
clock_settime(clk_id, &tp);
215226

216227
time_t clock = time(0);
217228
char buf[26];
229+
// cppcheck-suppress ctime_rCalled
218230
ctime_r(&clock, buf);
219231
}

test/cfg/std.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ void uninitvar_asctime(void)
424424
{
425425
const struct tm *tm;
426426
// cppcheck-suppress uninitvar
427-
// cppcheck-suppress obsoleteFunctionsasctime
427+
// cppcheck-suppress asctimeCalled
428428
(void)asctime(tm);
429429
}
430430

@@ -1636,7 +1636,7 @@ void uninitvar_getenv(void)
16361636
void uninitvar_gets(void)
16371637
{
16381638
char *buffer;
1639-
// cppcheck-suppress obsoleteFunctionsgets
1639+
// cppcheck-suppress getsCalled
16401640
// cppcheck-suppress uninitvar
16411641
(void)gets(buffer);
16421642
}
@@ -2394,7 +2394,7 @@ void uninitvar_malloc(void)
23942394
void uninitvar_alloca(void)
23952395
{
23962396
size_t size;
2397-
// cppcheck-suppress obsoleteFunctionsalloca
2397+
// cppcheck-suppress allocaCalled
23982398
// cppcheck-suppress uninitvar
23992399
(void)alloca(size);
24002400
}
@@ -3585,10 +3585,10 @@ void ignoredReturnValue_abs(int i)
35853585
void nullPointer_asctime(void)
35863586
{
35873587
struct tm *tm = 0;
3588-
// cppcheck-suppress obsoleteFunctionsasctime
3588+
// cppcheck-suppress asctimeCalled
35893589
// cppcheck-suppress nullPointer
35903590
(void)asctime(tm);
3591-
// cppcheck-suppress obsoleteFunctionsasctime
3591+
// cppcheck-suppress asctimeCalled
35923592
// cppcheck-suppress nullPointer
35933593
(void)asctime(0);
35943594
}

test/cfg/std.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void uninitvar_asctime(void)
166166
{
167167
const struct tm *tm;
168168
// cppcheck-suppress uninitvar
169-
// cppcheck-suppress obsoleteFunctionsasctime
169+
// cppcheck-suppress asctimeCalled
170170
(void)std::asctime(tm);
171171
}
172172

@@ -3018,10 +3018,10 @@ void ignoredReturnValue_abs(int i)
30183018
void nullPointer_asctime(void)
30193019
{
30203020
struct tm *tm = 0;
3021-
// cppcheck-suppress obsoleteFunctionsasctime
3021+
// cppcheck-suppress asctimeCalled
30223022
// cppcheck-suppress nullPointer
30233023
(void)std::asctime(tm);
3024-
// cppcheck-suppress obsoleteFunctionsasctime
3024+
// cppcheck-suppress asctimeCalled
30253025
// cppcheck-suppress nullPointer
30263026
(void)std::asctime(0);
30273027
}

0 commit comments

Comments
 (0)