aboutsummaryrefslogtreecommitdiffstats
path: root/examples/performance-thread/common/lthread_tls.c
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@gmail.com>2017-12-08 17:17:23 +0000
committerLuca Boccassi <luca.boccassi@gmail.com>2017-12-08 17:17:27 +0000
commit1754d8e45ba3f8b13484dee3c2b8ac4d845f2b74 (patch)
treedb372b59e29883bab5802c65b462c38a01b7b33a /examples/performance-thread/common/lthread_tls.c
parentfc42933813b2ba541bed9ef6b3e616dbf4b762ec (diff)
parent47d9763a1dd3103d732da9eec350cfc1cd784717 (diff)
Merge branch 'upstream-16.11-stable' into 16.11.x
Change-Id: Ida57d6d5aedcd4fe3a504a9ced733e73deee76c5 Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
Diffstat (limited to 'examples/performance-thread/common/lthread_tls.c')
-rw-r--r--examples/performance-thread/common/lthread_tls.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/performance-thread/common/lthread_tls.c b/examples/performance-thread/common/lthread_tls.c
index 6876f831..e58388b9 100644
--- a/examples/performance-thread/common/lthread_tls.c
+++ b/examples/performance-thread/common/lthread_tls.c
@@ -199,11 +199,12 @@ void _lthread_tls_destroy(struct lthread *lt)
void
*lthread_getspecific(unsigned int k)
{
+ void *res = NULL;
- if (k > LTHREAD_MAX_KEYS)
- return NULL;
+ if (k < LTHREAD_MAX_KEYS)
+ res = THIS_LTHREAD->tls->data[k];
- return THIS_LTHREAD->tls->data[k];
+ return res;
}
/*
@@ -213,7 +214,7 @@ void
*/
int lthread_setspecific(unsigned int k, const void *data)
{
- if (k > LTHREAD_MAX_KEYS)
+ if (k >= LTHREAD_MAX_KEYS)
return POSIX_ERRNO(EINVAL);
int n = THIS_LTHREAD->tls->nb_keys_inuse;