diff options
| author | Jeffrey Walton <noloader@gmail.com> | 2015-11-18 15:32:28 -0500 |
|---|---|---|
| committer | Jeffrey Walton <noloader@gmail.com> | 2015-11-18 15:32:28 -0500 |
| commit | 6ac1e46a1fb01f01705b67dd553d5ba317b1dc3e (patch) | |
| tree | f0d873d0b377a91dce5ee384e60426ef57efc92b /trdlocal.cpp | |
| parent | d2fda9bd4231a7dfcb44e59150f11246d992843f (diff) | |
| download | cryptopp-git-6ac1e46a1fb01f01705b67dd553d5ba317b1dc3e.tar.gz | |
Cleared issues 11,12,13 (Clang integrated assembler), 58 (RC rollup), 66 (Coverity rollup)
Diffstat (limited to 'trdlocal.cpp')
| -rw-r--r-- | trdlocal.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/trdlocal.cpp b/trdlocal.cpp index cff44a72..3c450d6a 100644 --- a/trdlocal.cpp +++ b/trdlocal.cpp @@ -28,10 +28,13 @@ ThreadLocalStorage::ThreadLocalStorage() {
#ifdef HAS_WINTHREADS
m_index = TlsAlloc();
+ assert(m_index != TLS_OUT_OF_INDEXES);
if (m_index == TLS_OUT_OF_INDEXES)
throw Err("TlsAlloc", GetLastError());
#else
+ m_index = 0;
int error = pthread_key_create(&m_index, NULL);
+ assert(!error);
if (error)
throw Err("pthread_key_create", error);
#endif
@@ -82,9 +85,14 @@ void *ThreadLocalStorage::GetValue() const {
#ifdef HAS_WINTHREADS
void *result = TlsGetValue(m_index);
- if (!result && GetLastError() != NO_ERROR)
- throw Err("TlsGetValue", GetLastError());
+ const DWORD dwRet = GetLastError();
+
+ assert(result || (!result && (dwRet == NO_ERROR)));
+ if (!result && dwRet != NO_ERROR)
+ throw Err("TlsGetValue", dwRet);
#else
+ // Null is a valid return value. Posix does not provide a way to
+ // check for a "good" Null vs a "bad" Null (errno is not set).
void *result = pthread_getspecific(m_index);
#endif
return result;
|
