File mbedtls-fix-building-with-GCC-16.patch of Package canokey-qemu

From ceae67f81dd60b4f50406e5387630545b72626a3 Mon Sep 17 00:00:00 2001
From: Dario Faggioli <dfaggioli@suse.com>
Date: Thu, 5 Mar 2026 12:49:30 +0100
Subject: [PATCH] mbedtls: fix building with GCC 16
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

GCC 16 is strictier about variables set but not actually used. In fact,
the build (in OBS) with it fails like this:

[   13s] [...]/mbedtls/library/bignum.c:1650:29: error: variable ‘t’ set but not used [-Werror=unused-but-set-variable=]
[   13s]  1650 |     mbedtls_mpi_uint c = 0, t = 0;
[   13s]       |                             ^
[   13s] cc1: all warnings being treated as errors

And this:

[   13s] [...]/mbedtls/library/psa_crypto_cipher.c:270:12: error: parameter ‘output_size’ set but not used [-Werror=unused-but-set-parameter=]
[   13s]   270 |     size_t output_size,
[   13s]       |     ~~~~~~~^~~~~~~~~~~
[   13s] cc1: all warnings being treated as errors

In the first case, the variable is used in some of the macros, so
we add a "fake" read of it, for silencing the warning.

In the second case, just remove it.

References: bsc#1256957
Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
---
 library/bignum.c            | 2 ++
 library/psa_crypto_cipher.c | 4 ----
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/canokey-core/canokey-crypto/mbedtls/library/bignum.c b/canokey-core/canokey-crypto/mbedtls/library/bignum.c
index 20afa22d5d..2548576f0b 100644
--- a/canokey-core/canokey-crypto/mbedtls/library/bignum.c
+++ b/canokey-core/canokey-crypto/mbedtls/library/bignum.c
@@ -1699,6 +1699,8 @@ void mpi_mul_hlp( size_t i,
 #endif /* MULADDC_HUIT */
 
     t++;
+    // FIX: Silence GCC16 "set but unused" warning 
+    (void) t;
 
     while( c != 0 )
     {
diff --git a/canokey-core/canokey-crypto/mbedtls/library/psa_crypto_cipher.c b/canokey-core/canokey-crypto/mbedtls/library/psa_crypto_cipher.c
index 2213ad0c2a..360c3c94d3 100644
--- a/canokey-core/canokey-crypto/mbedtls/library/psa_crypto_cipher.c
+++ b/canokey-core/canokey-crypto/mbedtls/library/psa_crypto_cipher.c
@@ -267,7 +267,6 @@ static psa_status_t psa_cipher_update_ecb(
     const uint8_t *input,
     size_t input_length,
     uint8_t *output,
-    size_t output_size,
     size_t *output_length )
 {
     psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
@@ -307,7 +306,6 @@ static psa_status_t psa_cipher_update_ecb(
                 goto exit;
 
             output += internal_output_length;
-            output_size -= internal_output_length;
             *output_length += internal_output_length;
             ctx->unprocessed_len = 0;
         }
@@ -328,7 +326,6 @@ static psa_status_t psa_cipher_update_ecb(
         input += block_size;
 
         output += internal_output_length;
-        output_size -= internal_output_length;
         *output_length += internal_output_length;
     }
 
@@ -383,7 +380,6 @@ static psa_status_t cipher_update( mbedtls_psa_cipher_operation_t *operation,
                                         input,
                                         input_length,
                                         output,
-                                        output_size,
                                         output_length );
     }
     else
-- 
2.53.0

openSUSE Build Service is sponsored by