mirror of
https://github.com/lammertb/libhttp.git
synced 2025-12-22 04:02:04 +03:00
Disable clang unreachable-code warning for function ssl_id_callback
Checking sizeof(pthread_t) > sizeof(unsigned long) has to be done at compile time, since the sizeof(...) operator can not be used in "#if" preprocessor conditions. Thus, depending on the compiler, either the if-branch or the else-branch will be logically dead code. There seems to be no reasonable way to prevent this, so disable -Wunreachable-code for this "if" statement. See #200
This commit is contained in:
@@ -9617,6 +9617,17 @@ static unsigned long ssl_id_callback(void)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return GetCurrentThreadId();
|
return GetCurrentThreadId();
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wunreachable-code"
|
||||||
|
/* For every compiler, either "sizeof(pthread_t) > sizeof(unsigned long)"
|
||||||
|
* or not, so one of the two conditions will be unreachable by construction.
|
||||||
|
* Unfortunately the C standard does not define a way to check this at
|
||||||
|
* compile time, since the #if preprocessor conditions can not use the sizeof
|
||||||
|
* operator as an argument. */
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sizeof(pthread_t) > sizeof(unsigned long)) {
|
if (sizeof(pthread_t) > sizeof(unsigned long)) {
|
||||||
/* This is the problematic case for CRYPTO_set_id_callback:
|
/* This is the problematic case for CRYPTO_set_id_callback:
|
||||||
* The OS pthread_t can not be cast to unsigned long. */
|
* The OS pthread_t can not be cast to unsigned long. */
|
||||||
@@ -9633,6 +9644,11 @@ static unsigned long ssl_id_callback(void)
|
|||||||
} else {
|
} else {
|
||||||
return (unsigned long)pthread_self();
|
return (unsigned long)pthread_self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user