use-retval for localtime() (#3935)

* use-retval for localtime()

* Adjust test to avoid new warning
This commit is contained in:
amai2012 2022-03-25 17:32:54 +01:00 committed by GitHub
parent fe7d0eeffc
commit a143fa37dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -3159,6 +3159,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
</function> </function>
<!-- struct tm * localtime(const time_t *tp); --> <!-- struct tm * localtime(const time_t *tp); -->
<function name="localtime,std::localtime"> <function name="localtime,std::localtime">
<use-retval/>
<returnValue type="struct tm *"/> <returnValue type="struct tm *"/>
<noreturn>false</noreturn> <noreturn>false</noreturn>
<leak-ignore/> <leak-ignore/>

View File

@ -374,7 +374,7 @@ private:
check("void f()\n" check("void f()\n"
"{\n" "{\n"
" time_t t = 0;" " time_t t = 0;"
" std::localtime(&t);\n" " auto lt = std::localtime(&t);\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:3]: (portability) Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'.\n", errout.str()); ASSERT_EQUALS("[test.cpp:3]: (portability) Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'.\n", errout.str());