Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions cfg/gnu.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@
<not-null/>
<not-uninit/>
</arg>
</function>
</function>
<!-- https://www.gnu.org/software/libc/manual/html_node/Getopt-Long-Options.html#Getopt-Long-Options -->
<!-- int getopt_long(int argc, char * const argv[],
const char *optstring,
Expand Down Expand Up @@ -1165,7 +1165,7 @@
</arg>
</function>
<!-- https://linux.die.net/man/3/mkostemp -->
<!-- int mkostemp(char *template, int flags);
<!-- int mkostemp(char *template, int flags);
int mkstemps(char *template, int suffixlen);-->
<function name="mkostemp,mkstemps">
<returnValue type="int"/>
Expand Down Expand Up @@ -1286,9 +1286,9 @@
<not-null/>
<not-bool/>
</arg>
</function>
</function>
<!-- http://man7.org/linux/man-pages/man3/ffs.3.html -->
<!-- int ffsl(long int i);
<!-- int ffsl(long int i);
int ffsll(long long int i); -->
<function name="ffsl,ffsll">
<use-retval/>
Expand Down Expand Up @@ -1648,6 +1648,13 @@
<not-uninit/>
</arg>
</function>
<!-- https://man7.org/linux/man-pages/man2/getcwd.2.html -->
<!-- char *get_current_dir_name(void); -->
<function name="get_current_dir_name">
<returnValue type="char *"/>
<use-retval/>
<noreturn>false</noreturn>
</function>
<!-- https://man7.org/linux/man-pages/man3/error.3.html -->
<!-- void error(int status, int errnum, const char *format, ...); -->
<!-- void error_at_line(int status, int errnum, const char *filename, unsigned int linenum, const char *format, ...); -->
Expand Down
31 changes: 31 additions & 0 deletions test/cfg/gnu.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#ifdef __gnu_linux__
#include <error.h>
#endif
#ifdef _GNU_SOURCE
#include <unistd.h>
#endif
#include <getopt.h>
#include <netdb.h>

Expand All @@ -41,6 +44,34 @@ void unreachableCode_error(void) // #11197
}
#endif

#ifdef _GNU_SOURCE
void leakReturnValNotUsed_get_current_dir_name(void)
{
// cppcheck-suppress leakReturnValNotUsed
get_current_dir_name();
}

void memleak_get_current_dir_name0(void)
{
const char *const name = get_current_dir_name();
if (name)
{
// cppcheck-suppress memleak
return;
}
}

void memleak_get_current_dir_name1(void)
{
const char *const name = get_current_dir_name();
if (name)
{
free(name);
return;
}
}
#endif

int nullPointer_gethostbyname2_r(const char* name, int af, struct hostent* ret, const char* buf, size_t buflen, struct hostent** result, const int* h_errnop)
{
// cppcheck-suppress nullPointer
Expand Down