std.cfg: Add asctime_s function configuration with tests (#1191)

* std.cfg: Add asctime_s function configuration with tests

* std.cfg: Remove redundant/not needed not-bool attributes.
This commit is contained in:
Sebastian 2018-04-27 23:51:16 +02:00 committed by amai2012
parent 1a9e8c158d
commit 6208ee4af1
2 changed files with 45 additions and 0 deletions

View File

@ -175,6 +175,26 @@
</arg>
<warn severity="style" cstd="c99" alternatives="strftime" reason="Obsolete"/>
</function>
<!-- errno_t asctime_s(char *buf, rsize_t bufsz, const struct tm *time_ptr); // since C11 -->
<function name="asctime_s,std::asctime_s">
<noreturn>false</noreturn>
<returnValue type="errno_t"/>
<leak-ignore/>
<arg nr="1">
<not-null/>
<minsize type="argvalue" arg="2"/>
</arg>
<arg nr="2">
<not-uninit/>
<valid>26:</valid>
</arg>
<arg nr="3">
<not-null/>
<not-uninit/>
<not-bool/>
</arg>
<warn severity="style" alternatives="strftime" reason="Obsolete"/>
</function>
<!-- void assert(int expression) -->
<function name="assert">
<returnValue type="void"/>

View File

@ -504,6 +504,15 @@ void uninitvar_asctime(void)
(void)asctime(tm);
}
void uninitvar_asctime_s(void)
{
const struct tm *tm;
char buf[26];
// cppcheck-suppress uninitvar
// cppcheck-suppress asctime_sCalled
asctime_s(buf, sizeof(buf), tm);
}
void uninitvar_assert(void)
{
int i;
@ -3695,6 +3704,10 @@ void invalidFunctionArgBool_abs(bool b, double x, double y)
void invalidFunctionArg(char c)
{
// cppcheck-suppress asctime_sCalled
// cppcheck-suppress invalidFunctionArg
asctime_s(1, 24, 1);
/* cppcheck-suppress invalidFunctionArg */
(void)isalnum(256);
/* cppcheck-suppress invalidFunctionArg */
@ -3841,6 +3854,18 @@ void nullPointer_asctime(void)
(void)asctime(0);
}
void nullPointer_asctime_s(void)
{
struct tm *tm = 0;
char * buf = NULL;
// cppcheck-suppress asctime_sCalled
// cppcheck-suppress nullPointer
asctime_s(buf, 26, 1);
// cppcheck-suppress asctime_sCalled
// cppcheck-suppress nullPointer
asctime_s(1, 26, tm);
}
void nullPointer_wcsftime(size_t maxsize)
{
wchar_t* ptr = 0;