posix.cfg: Warn in case the return value of localtime() is ignored. (#5555)

This commit is contained in:
orbitcowboy 2023-10-14 16:59:42 +02:00 committed by GitHub
parent 903df84ddc
commit 16c5a11786
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -4054,6 +4054,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<noreturn>false</noreturn>
<returnValue type="struct tm *"/>
<leak-ignore/>
<use-retval/>
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>

View File

@ -30,6 +30,7 @@
#include <stdarg.h>
#include <ctype.h>
#include <stdbool.h>
#include <time.h>
#if !(defined(__APPLE__) && defined(__MACH__))
#include <mqueue.h>
#endif
@ -169,6 +170,14 @@ void invalidFunctionArgStr_mbsnrtowcs(void)
if (mbsnrtowcs (wenough, &cp, 1, 10, &s) != 1 || wcscmp (wenough, L"AEF") != 0) {}
}
struct tm * ignoredReturnValue_localtime(const time_t *tp)
{
// cppcheck-suppress [ignoredReturnValue,localtimeCalled]
localtime(tp);
// cppcheck-suppress localtimeCalled
return localtime(tp);
}
int nullPointer_getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
{
// cppcheck-suppress nullPointer