Skip to content

Commit f743809

Browse files
committed
update tests
1 parent 9c1b4eb commit f743809

3 files changed

Lines changed: 26 additions & 52 deletions

File tree

‎test/cfg/std.c‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -171,26 +171,6 @@ void nullPointer_qsort(void *base, size_t n, size_t size, int (*cmp)(const void
171171
qsort(base, n, size, qsort_cmpfunc);
172172
}
173173

174-
// As with all bounds-checked functions, localtime_s is only guaranteed to be available if __STDC_LIB_EXT1__ is defined by the implementation and if the user defines __STDC_WANT_LIB_EXT1__ to the integer constant 1 before including time.h.
175-
#ifdef __STDC_LIB_EXT1__
176-
void uninitvar_localtime_s(const time_t *restrict time, struct tm *restrict result)
177-
{
178-
const time_t *restrict Time;
179-
// cppcheck-suppress uninitvar
180-
(void)localtime_s(Time, result);
181-
(void)localtime_s(time, result);
182-
}
183-
184-
void nullPointer_localtime_s(const time_t *restrict time, struct tm *restrict result)
185-
{
186-
// cppcheck-suppress nullPointer
187-
(void)localtime_s(NULL, result);
188-
// cppcheck-suppress nullPointer
189-
(void)localtime_s(time, NULL);
190-
(void)localtime_s(time, result);
191-
}
192-
#endif // __STDC_LIB_EXT1__
193-
194174
size_t bufferAccessOutOfBounds_wcsrtombs(char * dest, const wchar_t ** src, size_t len, mbstate_t * ps)
195175
{
196176
char buf[42];

‎test/cfg/std.cpp‎

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -689,38 +689,6 @@ void *bufferAccessOutOfBounds_memchr(void *s, int c, size_t n)
689689
return std::memchr(s,c,n);
690690
}
691691

692-
// As with all bounds-checked functions, localtime_s is only guaranteed to be available if __STDC_LIB_EXT1__ is defined by the implementation and if the user defines __STDC_WANT_LIB_EXT1__ to the integer constant 1 before including time.h.
693-
#ifdef __STDC_LIB_EXT1__
694-
void uninitvar_localtime_s(const std::time_t *restrict time, struct tm *restrict result)
695-
{
696-
// cppcheck-suppress valueFlowBailoutIncompleteVar
697-
const std::time_t *restrict Time;
698-
// TODO cppcheck-suppress uninitvar
699-
(void)std::localtime_s(Time, result);
700-
(void)std::localtime_s(time, result);
701-
}
702-
703-
void nullPointer_localtime_s(const std::time_t *restrict time, struct tm *restrict result)
704-
{
705-
// cppcheck-suppress nullPointer
706-
(void)std::localtime_s(NULL, result);
707-
// cppcheck-suppress nullPointer
708-
(void)std::localtime_s(time, NULL);
709-
(void)std::localtime_s(time, result);
710-
}
711-
712-
void memleak_localtime_s(const std::time_t *restrict time, struct tm *restrict result) // #9258
713-
{
714-
const time_t t = time(0);
715-
const struct tm* const now = new tm();
716-
if (localtime_s(now, &t) == 0) {
717-
// cppcheck-suppress valueFlowBailoutIncompleteVar
718-
std::cout << now->tm_mday << std::endl;
719-
}
720-
// cppcheck-suppress memleak
721-
}
722-
#endif // __STDC_LIB_EXT1__
723-
724692
size_t nullPointer_strftime(char *s, size_t max, const char *fmt, const struct tm *p)
725693
{
726694
// cppcheck-suppress nullPointer

‎test/cfg/windows.cpp‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,3 +1260,29 @@ void constParameterPointer_SetupDiGetDeviceInstanceId(HDEVINFO info, SP_DEVINFO_
12601260
TCHAR buffer[buffer_size];
12611261
SetupDiGetDeviceInstanceId(info, data, buffer, buffer_size, NULL);
12621262
}
1263+
1264+
void uninitvar_localtime_s(const time_t *time, struct tm *result)
1265+
{
1266+
time_t Time;
1267+
// cppcheck-suppress uninitvar
1268+
(void)localtime_s(result, &Time);
1269+
(void)localtime_s(result, time);
1270+
}
1271+
1272+
void nullPointer_localtime_s(const time_t *time, struct tm *result)
1273+
{
1274+
// cppcheck-suppress nullPointer
1275+
(void)localtime_s(result, NULL);
1276+
// cppcheck-suppress nullPointer
1277+
(void)localtime_s(NULL, time);
1278+
(void)localtime_s(result, time);
1279+
}
1280+
1281+
void memleak_localtime_s(void) // #9258
1282+
{
1283+
const time_t t = time(0);
1284+
struct tm *const now = new tm();
1285+
if (localtime_s(now, &t) == 0)
1286+
printf("%d\n", now->tm_mday);
1287+
// cppcheck-suppress memleak
1288+
}

0 commit comments

Comments
 (0)