Skip to content

Commit

Permalink
posix.cfg: Warn in case the return value of localtime() is ignored. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitcowboy committed Oct 14, 2023
1 parent 903df84 commit 16c5a11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions cfg/posix.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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/>
Expand Down
9 changes: 9 additions & 0 deletions test/cfg/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 16c5a11

Please sign in to comment.