Merge pull request #15 from ejohnstown/errsys

err_sys() static analysis issue
pull/16/head
dgarske 2016-08-27 15:46:07 -07:00 committed by GitHub
commit 626708de86
2 changed files with 38 additions and 5 deletions

View File

@ -86,18 +86,35 @@ typedef int SOCKET_T;
#define CYASSL_THREAD __stdcall
#endif
typedef struct {
SOCKET_T clientFd;
} thread_ctx_t;
static INLINE void err_sys(const char* msg)
#ifdef __GNUC__
#define WS_NORETURN __attribute__((noreturn))
#else
#define WS_NORETURN
#endif
static INLINE WS_NORETURN void err_sys(const char* msg)
{
printf("server error: %s\n", msg);
#ifndef __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
* WS_NORETURN. */
if (msg)
#endif
{
exit(EXIT_FAILURE);
}
}
static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
@ -669,4 +686,3 @@ int main(void)
return 0;
}

View File

@ -84,18 +84,35 @@ typedef int SOCKET_T;
#define CYASSL_THREAD __stdcall
#endif
typedef struct {
SOCKET_T clientFd;
} thread_ctx_t;
static INLINE void err_sys(const char* msg)
#ifdef __GNUC__
#define WS_NORETURN __attribute__((noreturn))
#else
#define WS_NORETURN
#endif
static INLINE WS_NORETURN void err_sys(const char* msg)
{
printf("server error: %s\n", msg);
#ifndef __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
* WS_NORETURN. */
if (msg)
#endif
{
exit(EXIT_FAILURE);
}
}
static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,