From 400c6c8e768b706d7d7721640525ac3b50eaa5f9 Mon Sep 17 00:00:00 2001 From: amai2012 Date: Thu, 10 Jan 2019 21:14:37 +0100 Subject: [PATCH] Improve configuration for dlopen and add suitable test --- cfg/posix.cfg | 8 ++++++++ test/cfg/posix.c | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index c31cd5074..82e9e08d9 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -74,6 +74,10 @@ + + dlopen + dlclose + false @@ -4107,4 +4111,8 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s + + + + diff --git a/test/cfg/posix.c b/test/cfg/posix.c index 265c413e9..5a0c2747a 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -12,6 +12,7 @@ #include #include #include +#include #include // unavailable on some linux systems #include #include @@ -331,3 +332,19 @@ void timet_h(struct timespec* ptp1) // cppcheck-suppress ctime_rCalled ctime_r(&clock, buf); } + +void dl(const char* libname, const char* func) +{ + void* lib = dlopen(libname, RTLD_NOW); + // cppcheck-suppress resourceLeak + // cppcheck-suppress redundantAssignment + lib = dlopen(libname, RTLD_LAZY); + const char* funcname; + // cppcheck-suppress uninitvar + // cppcheck-suppress unreadVariable + void* sym = dlsym(lib, funcname); + void* uninit; + // cppcheck-suppress uninitvar + dlclose(uninit); + // cppcheck-suppress resourceLeak +}