Merge pull request #532 from toddouska/sb-aiaddr

make sure static analysis realizes err_sys does exit()
This commit is contained in:
dgarske
2016-08-26 16:29:20 -07:00
committed by GitHub

View File

@ -355,11 +355,29 @@ void join_thread(THREAD_TYPE);
#endif #endif
static const word16 wolfSSLPort = 11111; static const word16 wolfSSLPort = 11111;
static INLINE void err_sys(const char* msg)
#if defined(__GNUC__)
#define WC_NORETURN __attribute__((noreturn))
#else
#define WC_NORETURN
#endif
static INLINE WC_NORETURN void err_sys(const char* msg)
{ {
printf("wolfSSL error: %s\n", msg); printf("wolfSSL error: %s\n", msg);
#if !defined(__GNUC__)
/* scan-build (which pretends to be gnuc) can get confused and think the
* msg pointer can be null even when hardcoded and then it won't exit,
* making null pointer checks above the err_sys() call useless.
* We could just always exit() but some compilers will complain about no
* possible return, with gcc we know the attribute to handle that with
* WC_NORETURN. */
if (msg) if (msg)
#endif
{
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
}
} }