On 2/12/26 11:59, Arun Giridhar wrote:

I would like to report some gnulib compilation warnings that occur when building GNU Octave: https://savannah.gnu.org/bugs/index.php?68042
The -Wcast-qual false alarms should be easy to fix and arguably make the code a bit clearer, so I installed the attached (which also fixes some similar issues in the neighborhood).

The -Wtautological-constant-out-of-range-compare issue is pretty much just a bug in Clang, if you ask me. At the very least it's a questionable feature. To work around the problem, compile with -Wno-tautological-constant-out-of-range-compare. This is discussed in the HACKING file.

Bruno fixed the -Wformat-security false alarms last year; perhaps something in that didn't catch? See:

https://lists.gnu.org/archive/html/bug-gnulib/2025-05/msg00266.html
From 0106c24241da92548647d95439977f62205e19de Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Thu, 12 Feb 2026 13:02:48 -0800
Subject: [PATCH 1/3] crypto/*-buffer: propagate 'const'

Problem reported by Arun Giridhar in:
https://savannah.gnu.org/bugs/index.php?68042
* lib/gl_openssl.h (GL_CRYPTO_FN): Use a const pointer.
---
 ChangeLog        | 7 +++++++
 lib/gl_openssl.h | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index baaa1f17da..d11c9a4a8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-02-12  Paul Eggert  <[email protected]>
+
+	crypto/*-buffer: propagate 'const'
+	Problem reported by Arun Giridhar in:
+	https://savannah.gnu.org/bugs/index.php?68042
+	* lib/gl_openssl.h (GL_CRYPTO_FN): Use a const pointer.
+
 2026-02-12  Pádraig Brady  <[email protected]>
 
 	parse-datetime: support dd.mm. in combination
diff --git a/lib/gl_openssl.h b/lib/gl_openssl.h
index e81c010433..06fd8f66f9 100644
--- a/lib/gl_openssl.h
+++ b/lib/gl_openssl.h
@@ -103,7 +103,7 @@ GL_OPENSSL_INLINE void *
 GL_CRYPTO_FN (_read_ctx) (const struct _gl_ctx *ctx, void *restrict res)
 {
   /* Assume any unprocessed bytes in ctx are not to be ignored.  */
-  _gl_CTX tmp_ctx = *(_gl_CTX *) ctx;
+  _gl_CTX tmp_ctx = *(_gl_CTX const *) ctx;
   OPENSSL_FN (_Final) ((unsigned char *) res, &tmp_ctx);
   return res;
 }
-- 
2.53.0

From 4ff5b875aa11511e3460deb750b3d6dbba6e48b1 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Thu, 12 Feb 2026 13:34:10 -0800
Subject: [PATCH 2/3] crypto/rijndael: pacify -Wcast-qual

* lib/rijndael-api-fst.c (rijndaelBlockEncrypt)
(rijndaelPadEncrypt): Pacify clang -Wcast-qual.
---
 ChangeLog              |  4 ++++
 lib/rijndael-api-fst.c | 20 ++++++++++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d11c9a4a8c..2b5ec46375 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2026-02-12  Paul Eggert  <[email protected]>
 
+	crypto/rijndael: pacify -Wcast-qual
+	* lib/rijndael-api-fst.c (rijndaelBlockEncrypt)
+	(rijndaelPadEncrypt): Pacify clang -Wcast-qual.
+
 	crypto/*-buffer: propagate 'const'
 	Problem reported by Arun Giridhar in:
 	https://savannah.gnu.org/bugs/index.php?68042
diff --git a/lib/rijndael-api-fst.c b/lib/rijndael-api-fst.c
index fe6422c8d6..9b869e1da3 100644
--- a/lib/rijndael-api-fst.c
+++ b/lib/rijndael-api-fst.c
@@ -234,10 +234,12 @@ rijndaelBlockEncrypt (rijndaelCipherInstance *cipher,
         char *iv = cipher->IV;
         for (size_t i = numBlocks; i > 0; i--)
           {
-            block.words[0] = ((uint32_t *) input)[0] ^ ((uint32_t *) iv)[0];
-            block.words[1] = ((uint32_t *) input)[1] ^ ((uint32_t *) iv)[1];
-            block.words[2] = ((uint32_t *) input)[2] ^ ((uint32_t *) iv)[2];
-            block.words[3] = ((uint32_t *) input)[3] ^ ((uint32_t *) iv)[3];
+            uint32_t const *input_word = (uint32_t const *) input;
+            uint32_t const *iv_word = (uint32_t const *) iv;
+            block.words[0] = input_word[0] ^ iv_word[0];
+            block.words[1] = input_word[1] ^ iv_word[1];
+            block.words[2] = input_word[2] ^ iv_word[2];
+            block.words[3] = input_word[3] ^ iv_word[3];
             rijndaelEncrypt (key->rk, key->Nr, block.bytes, outBuffer);
             memcpy (cipher->IV, outBuffer, 16);
             input += 16;
@@ -317,10 +319,12 @@ rijndaelPadEncrypt (rijndaelCipherInstance *cipher,
         char *iv = cipher->IV;
         for (size_t i = numBlocks; i > 0; i--)
           {
-            block.words[0] = ((uint32_t *) input)[0] ^ ((uint32_t *) iv)[0];
-            block.words[1] = ((uint32_t *) input)[1] ^ ((uint32_t *) iv)[1];
-            block.words[2] = ((uint32_t *) input)[2] ^ ((uint32_t *) iv)[2];
-            block.words[3] = ((uint32_t *) input)[3] ^ ((uint32_t *) iv)[3];
+            uint32_t const *input_word = (uint32_t const *) input;
+            uint32_t const *iv_word = (uint32_t const *) iv;
+            block.words[0] = input_word[0] ^ iv_word[0];
+            block.words[1] = input_word[1] ^ iv_word[1];
+            block.words[2] = input_word[2] ^ iv_word[2];
+            block.words[3] = input_word[3] ^ iv_word[3];
             rijndaelEncrypt (key->rk, key->Nr, block.bytes, outBuffer);
             memcpy (cipher->IV, outBuffer, 16);
             input += 16;
-- 
2.53.0

From d218b43724410c5a04f803ee43c5055552c12ccc Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Thu, 12 Feb 2026 13:36:26 -0800
Subject: [PATCH 3/3] crypto/sha3-buffer: pacify -Wcast-qual

* lib/sha3.c (sha3_process_bytes): Pacify clang -Wcast-qual.
---
 ChangeLog  |  3 +++
 lib/sha3.c | 14 ++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2b5ec46375..15f8aafd6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2026-02-12  Paul Eggert  <[email protected]>
 
+	crypto/sha3-buffer: pacify -Wcast-qual
+	* lib/sha3.c (sha3_process_bytes): Pacify clang -Wcast-qual.
+
 	crypto/rijndael: pacify -Wcast-qual
 	* lib/rijndael-api-fst.c (rijndaelBlockEncrypt)
 	(rijndaelPadEncrypt): Pacify clang -Wcast-qual.
diff --git a/lib/sha3.c b/lib/sha3.c
index 003addbc0f..5ee23dc48e 100644
--- a/lib/sha3.c
+++ b/lib/sha3.c
@@ -137,19 +137,21 @@ DEFINE_SHA3_BUFFER (512)
 bool
 sha3_process_bytes (const void *buffer, size_t len, struct sha3_ctx *ctx)
 {
+  char const *buf = buffer;
+
   if (0 < ctx->buflen)
     {
       size_t left = ctx->blocklen - ctx->buflen;
       if (len < left)
         {
           /* Not enough to fill a full block.  */
-          memcpy (ctx->buffer + ctx->buflen, buffer, len);
+          memcpy (ctx->buffer + ctx->buflen, buf, len);
           ctx->buflen += len;
           return true;
         }
       /* Process the block that already had bytes buffered.  */
-      memcpy (ctx->buffer + ctx->buflen, buffer, left);
-      buffer = (char *) buffer + left;
+      memcpy (ctx->buffer + ctx->buflen, buf, left);
+      buf += left;
       len -= left;
       sha3_process_block (ctx->buffer, ctx->blocklen, ctx);
     }
@@ -157,10 +159,10 @@ sha3_process_bytes (const void *buffer, size_t len, struct sha3_ctx *ctx)
   if (0 < len)
     {
       size_t full_blocks = (len / ctx->blocklen) * ctx->blocklen;
-      sha3_process_block (buffer, full_blocks, ctx);
-      buffer = (char *) buffer + full_blocks;
+      sha3_process_block (buf, full_blocks, ctx);
+      buf += full_blocks;
       len -= full_blocks;
-      memcpy (ctx->buffer, buffer, len);
+      memcpy (ctx->buffer, buf, len);
       ctx->buflen = len;
     }
   return true;
-- 
2.53.0

Reply via email to