* + lib-base64-silence-clang-24-wconstant-conversion-with-diag-pragmas.patch added to mm-hotfixes-unstable branch
@ 2026-10-08 17:25 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-10-08 17:25 UTC (permalink / raw)
To: mm-commits, visitorckw, stable, ndesaulniers, morbo, justinstitt,
409411716, nathan, akpm
The patch titled
Subject: lib/base64: silence clang-24 -Wconstant-conversion with diag pragmas
has been added to the -mm mm-hotfixes-unstable branch. Its filename is
lib-base64-silence-clang-24-wconstant-conversion-with-diag-pragmas.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/lib-base64-silence-clang-24-wconstant-conversion-with-diag-pragmas.patch
This patch will later appear in the mm-hotfixes-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Nathan Chancellor <nathan@kernel.org>
Subject: lib/base64: silence clang-24 -Wconstant-conversion with diag pragmas
Date: Thu, 08 Oct 2026 13:08:49 +0200
After a recent change in clang to warn on signed char conversions within
array initializers [1], there are several instances of this warning from
base64_rev_maps in lib/base64.c, which can break the build with W=e or
CONFIG_WERROR=y:
lib/base64.c:58:18: error: implicit conversion from 'int' to 's8' (aka 'signed char') changes value from 131 to -125 [-Werror,-Wconstant-conversion]
58 | [BASE64_IMAP] = BASE64_REV_INIT('+', ',')
| ^~~~~~~~~~~~~~~~~~~~~~~~~
lib/base64.c:52:2: note: expanded from macro 'BASE64_REV_INIT'
48 | #define BASE64_REV_INIT(ch_62, ch_63) { \
| ~
49 | [0 ... 0x1f] = -1, \
50 | INIT_32(0x20, ch_62, ch_63), \
51 | INIT_32(0x40, ch_62, ch_63), \
52 | INIT_32(0x60, ch_62, ch_63), \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
...
lib/base64.c:34:42: note: expanded from macro 'INIT_1'
34 | : (v) >= '0' && (v) <= '9' ? (v) - '0' + 52 \
| ~~~~~~~~~~^~~~
lib/base64.c:58:18: error: implicit conversion from 'int' to 's8' (aka 'signed char') changes value from 130 to -126 [-Werror,-Wconstant-conversion]
58 | [BASE64_IMAP] = BASE64_REV_INIT('+', ',')
| ^~~~~~~~~~~~~~~~~~~~~~~~~
lib/base64.c:52:2: note: expanded from macro 'BASE64_REV_INIT'
48 | #define BASE64_REV_INIT(ch_62, ch_63) { \
| ~
49 | [0 ... 0x1f] = -1, \
50 | INIT_32(0x20, ch_62, ch_63), \
51 | INIT_32(0x40, ch_62, ch_63), \
52 | INIT_32(0x60, ch_62, ch_63), \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
...
lib/base64.c:34:42: note: expanded from macro 'INIT_1'
34 | : (v) >= '0' && (v) <= '9' ? (v) - '0' + 52 \
| ~~~~~~~~~~^~~~
...
These are false positives, as the branch where the wraparound could happen
is unreachable with the values that clang reports. This is not considered
a bug by some clang folks [2][3], so silence the warnings using the __diag
macros the kernel has to workaround compiler warnings when necessary.
Link: https://lore.kernel.org/20261008-base64-silence-clang-24-constant-conversion-v1-1-0858b60b23c8@kernel.org
Link: https://github.com/llvm/llvm-project/commit/a5ef934a8d295dc03be3960f2b3744ec2e53238e [1]
Link: https://github.com/llvm/llvm-project/issues/223923#issuecomment-6056856245 [2]
Link: https://github.com/llvm/llvm-project/pull/226775#pullrequestreview-5454407389 [3]
Fixes: c4eb7ad32eab ("lib/base64: optimize base64_decode() with reverse lookup tables")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Closes: https://github.com/ClangBuiltLinux/linux/issues/2181
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Kuan-Wei Chiu <visitorckw@gmail.com>
Cc: Guan-Chun Wu <409411716@gms.tku.edu.tw>
Cc: <stable@vger.kernel.org>
---
lib/base64.c | 3 +++
1 file changed, 3 insertions(+)
--- a/lib/base64.c~lib-base64-silence-clang-24-wconstant-conversion-with-diag-pragmas
+++ a/lib/base64.c
@@ -52,11 +52,14 @@ static const char base64_tables[][65] =
INIT_32(0x60, ch_62, ch_63), \
[0x80 ... 0xff] = -1 }
+__diag_push();
+__diag_ignore(clang, all, "-Wconstant-conversion", "https://github.com/llvm/llvm-project/issues/223923");
static const s8 base64_rev_maps[][256] = {
[BASE64_STD] = BASE64_REV_INIT('+', '/'),
[BASE64_URLSAFE] = BASE64_REV_INIT('-', '_'),
[BASE64_IMAP] = BASE64_REV_INIT('+', ',')
};
+__diag_pop();
#undef BASE64_REV_INIT
#undef INIT_32
_
Patches currently in -mm which might be from nathan@kernel.org are
lib-base64-silence-clang-24-wconstant-conversion-with-diag-pragmas.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-08 17:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-08 17:25 + lib-base64-silence-clang-24-wconstant-conversion-with-diag-pragmas.patch added to mm-hotfixes-unstable branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.