]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Remove superfluous volatile for RCU on Windows
authorMilan Broz <gmazyland@gmail.com>
Fri, 27 Mar 2026 09:38:52 +0000 (10:38 +0100)
committerEugene Syromiatnikov <esyr@openssl.org>
Tue, 31 Mar 2026 01:31:51 +0000 (03:31 +0200)
When compiling on the MINGW platform, there are many warnings like this:

  warning: passing argument 1 of 'CRYPTO_atomic_add64' discards 'volatile'
  qualifier from pointer target type [-Wdiscarded-qualifiers]
  CRYPTO_atomic_add64(&lock->qp_group[qp_idx].users, (uint64_t)1, &tmp64,
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The warning actually shows several issues with volatile in struct rcu_qp:

 - all handling functions using it do not use the volatile modifier,
   so that the compiler can treat this pointer as non-volatile already
   (Posix pthread variant does not use volatile here at all.)

 - thread safety is already guaranteed by using locks
   (NO_INTERLOCKEDOR64) or Interlocked*64 Win32 API functions.

 - the volatile removal modifier should always be explicit

In short, I think the volatile in struct rcu_qp on Windows
has no additional value and can be removed.

This also fixes the warnings mentioned above :-)

Signed-off-by: Milan Broz <gmazyland@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Tue Mar 31 01:25:56 2026
(Merged from https://github.com/openssl/openssl/pull/30602)

(cherry picked from commit b0380fa9331e8d9d4d8b1ab7c3f57d7a35603757)

crypto/threads_win.c

index 525c8d432e6af651cd8193d16ae26a7244b6aa37..4884fae6c58171eeeb59169e34855d127d21eddf 100644 (file)
@@ -51,7 +51,7 @@ typedef struct {
  * atomically updated
  */
 struct rcu_qp {
-    volatile uint64_t users;
+    uint64_t users;
 };
 
 struct thread_qp {