Commit abdc71186f for openssl.org

commit abdc71186f2aad0e7a55d13f50563e8cdcf39179
Author: Tomas Mraz <tomas@openssl.foundation>
Date:   Mon Sep 14 11:17:55 2026 +0200

    Remove unused static variables to suppress new clang warning

    There were unused static variables in
    bn_lib.c, ssl_init.c, (dtls)client.c, (dtls)server.c,
    quic-client/server.c, dtlsssllistenertest.c

    Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
    Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
    Merge-date: Thu Sep 17 14:05:01 2026
    Merged-from: https://github.com/openssl/openssl/pull/32821

diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c
index 3d432fb317..494561b0fa 100644
--- a/crypto/bn/bn_lib.c
+++ b/crypto/bn/bn_lib.c
@@ -28,13 +28,9 @@
  * 8 - 256 == 8192
  */
 static int bn_limit_bits = 0;
-static int bn_limit_num = 8; /* (1<<bn_limit_bits) */
 static int bn_limit_bits_low = 0;
-static int bn_limit_num_low = 8; /* (1<<bn_limit_bits_low) */
 static int bn_limit_bits_high = 0;
-static int bn_limit_num_high = 8; /* (1<<bn_limit_bits_high) */
 static int bn_limit_bits_mont = 0;
-static int bn_limit_num_mont = 8; /* (1<<bn_limit_bits_mont) */

 void BN_set_params(int mult, int high, int low, int mont)
 {
@@ -42,25 +38,21 @@ void BN_set_params(int mult, int high, int low, int mont)
         if (mult > (int)(sizeof(int) * 8) - 1)
             mult = sizeof(int) * 8 - 1;
         bn_limit_bits = mult;
-        bn_limit_num = 1 << mult;
     }
     if (high >= 0) {
         if (high > (int)(sizeof(int) * 8) - 1)
             high = sizeof(int) * 8 - 1;
         bn_limit_bits_high = high;
-        bn_limit_num_high = 1 << high;
     }
     if (low >= 0) {
         if (low > (int)(sizeof(int) * 8) - 1)
             low = sizeof(int) * 8 - 1;
         bn_limit_bits_low = low;
-        bn_limit_num_low = 1 << low;
     }
     if (mont >= 0) {
         if (mont > (int)(sizeof(int) * 8) - 1)
             mont = sizeof(int) * 8 - 1;
         bn_limit_bits_mont = mont;
-        bn_limit_num_mont = 1 << mont;
     }
 }

diff --git a/fuzz/client.c b/fuzz/client.c
index 64d30dd09e..8ed77ea8cd 100644
--- a/fuzz/client.c
+++ b/fuzz/client.c
@@ -18,9 +18,6 @@
 #include <openssl/err.h>
 #include "fuzzer.h"

-/* unused, to avoid warning. */
-static int idx;
-
 #define FUZZTIME 1485898104

 #define TIME_IMPL(t)       \
@@ -50,7 +47,9 @@ time_t time(time_t *t) TIME_IMPL(t)
     OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);
     ERR_clear_error();
     CRYPTO_free_ex_index(0, -1);
-    idx = SSL_get_ex_data_X509_STORE_CTX_idx();
+    if (SSL_get_ex_data_X509_STORE_CTX_idx() != 0) {
+        /* Just suppress warning */
+    }
     comp_methods = SSL_COMP_get_compression_methods();
     if (comp_methods != NULL)
         sk_SSL_COMP_sort(comp_methods);
diff --git a/fuzz/dtlsclient.c b/fuzz/dtlsclient.c
index b475a7dee2..0fe3c9eacf 100644
--- a/fuzz/dtlsclient.c
+++ b/fuzz/dtlsclient.c
@@ -18,9 +18,6 @@
 #include <openssl/err.h>
 #include "fuzzer.h"

-/* unused, to avoid warning. */
-static int idx;
-
 #define FUZZTIME 1485898104

 #define TIME_IMPL(t)       \
@@ -50,7 +47,9 @@ time_t time(time_t *t) TIME_IMPL(t)
     OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);
     ERR_clear_error();
     CRYPTO_free_ex_index(0, -1);
-    idx = SSL_get_ex_data_X509_STORE_CTX_idx();
+    if (SSL_get_ex_data_X509_STORE_CTX_idx() != 0) {
+        /* Just suppress warning */
+    }
     comp_methods = SSL_COMP_get_compression_methods();
     if (comp_methods != NULL)
         sk_SSL_COMP_sort(comp_methods);
diff --git a/fuzz/dtlsserver.c b/fuzz/dtlsserver.c
index 1e8868ce0f..e9c825ea81 100644
--- a/fuzz/dtlsserver.c
+++ b/fuzz/dtlsserver.c
@@ -735,9 +735,6 @@ static const char DSACertPEM[] = {
 };
 #endif

-/* unused, to avoid warning. */
-static int idx;
-
 #define FUZZTIME 1485898104

 #define TIME_IMPL(t)       \
@@ -767,7 +764,9 @@ time_t time(time_t *t) TIME_IMPL(t)
     OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);
     ERR_clear_error();
     CRYPTO_free_ex_index(0, -1);
-    idx = SSL_get_ex_data_X509_STORE_CTX_idx();
+    if (SSL_get_ex_data_X509_STORE_CTX_idx() == 0) {
+        /* Just suppress warning */
+    }
     comp_methods = SSL_COMP_get_compression_methods();
     if (comp_methods != NULL)
         sk_SSL_COMP_sort(comp_methods);
diff --git a/fuzz/quic-client.c b/fuzz/quic-client.c
index 11a833f4ca..00238998c7 100644
--- a/fuzz/quic-client.c
+++ b/fuzz/quic-client.c
@@ -16,9 +16,6 @@
 #include "internal/time.h"
 #include "internal/quic_ssl.h"

-/* unused, to avoid warning. */
-static int idx;
-
 static OSSL_TIME fake_now;

 static OSSL_TIME fake_now_cb(void *arg)
@@ -35,7 +32,9 @@ int FuzzerInitialize(int *argc, char ***argv)
     OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);
     ERR_clear_error();
     CRYPTO_free_ex_index(0, -1);
-    idx = SSL_get_ex_data_X509_STORE_CTX_idx();
+    if (SSL_get_ex_data_X509_STORE_CTX_idx() == 0) {
+        /* Just suppress warning */
+    }
     comp_methods = SSL_COMP_get_compression_methods();
     if (comp_methods != NULL)
         sk_SSL_COMP_sort(comp_methods);
diff --git a/fuzz/quic-server.c b/fuzz/quic-server.c
index 6be099d31d..65446f47dc 100644
--- a/fuzz/quic-server.c
+++ b/fuzz/quic-server.c
@@ -16,9 +16,6 @@
 #include "internal/time.h"
 #include "internal/quic_ssl.h"

-/* unused, to avoid warning. */
-static int idx;
-
 static OSSL_TIME fake_now;

 static OSSL_TIME fake_now_cb(void *arg)
@@ -35,7 +32,9 @@ int FuzzerInitialize(int *argc, char ***argv)
     OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);
     ERR_clear_error();
     CRYPTO_free_ex_index(0, -1);
-    idx = SSL_get_ex_data_X509_STORE_CTX_idx();
+    if (SSL_get_ex_data_X509_STORE_CTX_idx() == 0) {
+        /* Just suppress warning */
+    }
     comp_methods = SSL_COMP_get_compression_methods();
     if (comp_methods != NULL)
         sk_SSL_COMP_sort(comp_methods);
diff --git a/fuzz/server.c b/fuzz/server.c
index 740ade8513..a06d872d1d 100644
--- a/fuzz/server.c
+++ b/fuzz/server.c
@@ -551,9 +551,6 @@ static const char DSACertPEM[] = {
 };
 #endif

-/* unused, to avoid warning. */
-static int idx;
-
 #define FUZZTIME 1485898104

 #define TIME_IMPL(t)       \
@@ -583,7 +580,9 @@ time_t time(time_t *t) TIME_IMPL(t)
     OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);
     ERR_clear_error();
     CRYPTO_free_ex_index(0, -1);
-    idx = SSL_get_ex_data_X509_STORE_CTX_idx();
+    if (SSL_get_ex_data_X509_STORE_CTX_idx() == 0) {
+        /* Just suppress warning */
+    }
     comp_methods = SSL_COMP_get_compression_methods();
     if (comp_methods != NULL)
         sk_SSL_COMP_sort(comp_methods);
diff --git a/ssl/ssl_init.c b/ssl/ssl_init.c
index 634fd39237..5b31b0a2df 100644
--- a/ssl/ssl_init.c
+++ b/ssl/ssl_init.c
@@ -19,7 +19,6 @@
 static int stopped;

 static CRYPTO_ONCE ssl_base = CRYPTO_ONCE_STATIC_INIT;
-static int ssl_base_inited = 0;
 DEFINE_RUN_ONCE_STATIC(ossl_init_ssl_base)
 {
 #ifndef OPENSSL_NO_COMP
@@ -33,7 +32,6 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_ssl_base)
 #endif
     ssl_sort_cipher_list();
     OSSL_TRACE(INIT, "ossl_init_ssl_base: SSL_add_ssl_module()\n");
-    ssl_base_inited = 1;
     return 1;
 }

diff --git a/test/dtlsssllistenertest.c b/test/dtlsssllistenertest.c
index e173a9b8cd..d25d690aed 100644
--- a/test/dtlsssllistenertest.c
+++ b/test/dtlsssllistenertest.c
@@ -4615,7 +4615,6 @@ static SSL_CTX *new_pending_cb_expected_ctx;
 static void *new_pending_cb_expected_arg;
 static int new_pending_cb_ctx_matched;
 static int new_pending_cb_arg_matched;
-static SSL *new_pending_cb_last_ssl;

 /*
  * Reset the file-scope callback state before registering the callback for
@@ -4643,13 +4642,11 @@ static void new_pending_cb_reset(SSL_CTX *ctx, void *arg, int allow_remaining)
     new_pending_cb_expected_arg = arg;
     new_pending_cb_ctx_matched = 1;
     new_pending_cb_arg_matched = 1;
-    new_pending_cb_last_ssl = NULL;
 }

 static int new_pending_cb_fn(SSL_CTX *ctx, SSL *new_ssl, void *arg)
 {
     new_pending_cb_call_count++;
-    new_pending_cb_last_ssl = new_ssl;
     if (ctx != new_pending_cb_expected_ctx)
         new_pending_cb_ctx_matched = 0;
     if (arg != new_pending_cb_expected_arg)