std.cfg: Improved configuration of localtime_s()
This commit is contained in:
parent
0410f01647
commit
5db6fc1f54
|
@ -3178,6 +3178,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1" direction="in">
|
<arg nr="1" direction="in">
|
||||||
<not-null/>
|
<not-null/>
|
||||||
|
<not-uninit/>
|
||||||
</arg>
|
</arg>
|
||||||
<arg nr="2" direction="out">
|
<arg nr="2" direction="out">
|
||||||
<not-null/>
|
<not-null/>
|
||||||
|
|
|
@ -19,12 +19,33 @@
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#include <fenv.h>
|
#include <fenv.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
#define __STDC_WANT_LIB_EXT1__ 1
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
#ifdef __STDC_LIB_EXT1__
|
||||||
|
void uninitvar_localtime_s(const time_t *restrict time, struct tm *restrict result)
|
||||||
|
{
|
||||||
|
const time_t *restrict Time;
|
||||||
|
// cppcheck-suppress uninitvar
|
||||||
|
(void)localtime_s(Time, result);
|
||||||
|
(void)localtime_s(time, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void nullPointer_localtime_s(const time_t *restrict time, struct tm *restrict result)
|
||||||
|
{
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
(void)localtime_s(NULL, result);
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
(void)localtime_s(time, NULL);
|
||||||
|
(void)localtime_s(time, result);
|
||||||
|
}
|
||||||
|
#endif // __STDC_LIB_EXT1__
|
||||||
|
|
||||||
size_t bufferAccessOutOfBounds_wcsrtombs(char * dest, const wchar_t ** src, size_t len, mbstate_t * ps)
|
size_t bufferAccessOutOfBounds_wcsrtombs(char * dest, const wchar_t ** src, size_t len, mbstate_t * ps)
|
||||||
{
|
{
|
||||||
char buf[42];
|
char buf[42];
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#define __STDC_WANT_LIB_EXT1__ 1
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -31,6 +32,26 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
#ifdef __STDC_LIB_EXT1__
|
||||||
|
void uninitvar_localtime_s(const std::time_t *restrict time, struct tm *restrict result)
|
||||||
|
{
|
||||||
|
const std::time_t *restrict Time;
|
||||||
|
// TODO cppcheck-suppress uninitvar
|
||||||
|
(void)std::localtime_s(Time, result);
|
||||||
|
(void)std::localtime_s(time, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void nullPointer_localtime_s(const std::time_t *restrict time, struct tm *restrict result)
|
||||||
|
{
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
(void)std::localtime_s(NULL, result);
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
(void)std::localtime_s(time, NULL);
|
||||||
|
(void)std::localtime_s(time, result);
|
||||||
|
}
|
||||||
|
#endif // __STDC_LIB_EXT1__
|
||||||
|
|
||||||
size_t nullPointer_strftime(char *s, size_t max, const char *fmt, const struct tm *p)
|
size_t nullPointer_strftime(char *s, size_t max, const char *fmt, const struct tm *p)
|
||||||
{
|
{
|
||||||
// cppcheck-suppress nullPointer
|
// cppcheck-suppress nullPointer
|
||||||
|
|
Loading…
Reference in New Issue