Skip to content

Commit 366f5fe

Browse files
committed
src/ssl.c: refactor initRefCount increment/decrement to avoid -Wvolatile.
1 parent f6fbd2a commit 366f5fe

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/ssl.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,12 @@ static int wolfSSL_parse_cipher_list(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
11191119
#endif
11201120

11211121
/* prevent multiple mutex initializations */
1122+
1123+
/* note, initRefCount is not used for thread synchronization, only for
1124+
* bookkeeping while inits_count_mutex is held.
1125+
*/
11221126
static volatile WC_THREADSHARED int initRefCount = 0;
1127+
11231128
/* init ref count mutex */
11241129
static WC_THREADSHARED wolfSSL_Mutex inits_count_mutex
11251130
WOLFSSL_MUTEX_INITIALIZER_CLAUSE(inits_count_mutex);
@@ -6527,7 +6532,7 @@ int wolfSSL_Init(void)
65276532
#endif /* WOLFSSL_SYS_CRYPTO_POLICY */
65286533

65296534
if (ret == WOLFSSL_SUCCESS) {
6530-
initRefCount++;
6535+
initRefCount = initRefCount + 1;
65316536
}
65326537
else {
65336538
initRefCount = 1; /* Force cleanup */
@@ -11401,7 +11406,7 @@ int wolfSSL_Cleanup(void)
1140111406
#endif
1140211407

1140311408
if (initRefCount > 0) {
11404-
--initRefCount;
11409+
initRefCount = initRefCount - 1;
1140511410
if (initRefCount == 0)
1140611411
release = 1;
1140711412
}

0 commit comments

Comments
 (0)