Skip to content

Commit

Permalink
Use valid address in pthread_setspecific to silence warnings (#162)
Browse files Browse the repository at this point in the history
* use valid address in pthread_setspecific to silence warnings

* Update thread_setup_unix.c

Co-authored-by: Davis Goodin <dagood@users.noreply.github.com>

* use local variable instead of global

---------

Co-authored-by: Davis Goodin <dagood@users.noreply.github.com>
(cherry picked from commit 6f4d87d)
  • Loading branch information
qmuntal committed Sep 5, 2024
1 parent 61a53ab commit c98a2c8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions thread_setup_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ static void thread_id(GO_CRYPTO_THREADID_PTR tid)
// per-thread error state, so this function is guaranteed to be executed at
// least once on any thread with associated error state. The thread-local
// variable needs to be set to a non-NULL value so that the destructor will
// be called when the thread exits. The actual value does not matter.
(void) pthread_setspecific(destructor_key, (void*)1);
// be called when the thread exits.
// The actual value does not matter, but should be a pointer with a valid size.
// See https://github.com/golang-fips/openssl/pull/162
static char stub;
(void) pthread_setspecific(destructor_key, &stub);
}

static void cleanup_thread_state(void *ignored)
Expand Down

0 comments on commit c98a2c8

Please sign in to comment.