[PATCH v5 3/6] lib/base64: rework encode/decode for speed and stricter validation
Andrew Morton
akpm at linux-foundation.org
Mon Nov 17 09:46:52 PST 2025
On Sun, 16 Nov 2025 18:28:49 +0800 Guan-Chun Wu <409411716 at gms.tku.edu.tw> wrote:
> > Reviewed-by: David Laight <david.laight.linux at gmail.com>
> >
> > But see minor nit below.
>
> Hi David,
>
> Thanks for the review and for pointing this out.
>
> Andrew, would it be possible for you to fold this small change
> (removing the redundant casts) directly when updating the patch?
> If that’s not convenient, I can resend an updated version of the
> series instead.
Sure, I added this:
--- a/lib/base64.c~lib-base64-rework-encode-decode-for-speed-and-stricter-validation-fix
+++ a/lib/base64.c
@@ -83,7 +83,7 @@ int base64_encode(const u8 *src, int src
const char *base64_table = base64_tables[variant];
while (srclen >= 3) {
- ac = (u32)src[0] << 16 | (u32)src[1] << 8 | (u32)src[2];
+ ac = src[0] << 16 | src[1] << 8 | src[2];
*cp++ = base64_table[ac >> 18];
*cp++ = base64_table[(ac >> 12) & 0x3f];
*cp++ = base64_table[(ac >> 6) & 0x3f];
@@ -95,7 +95,7 @@ int base64_encode(const u8 *src, int src
switch (srclen) {
case 2:
- ac = (u32)src[0] << 16 | (u32)src[1] << 8;
+ ac = src[0] << 16 | src[1] << 8;
*cp++ = base64_table[ac >> 18];
*cp++ = base64_table[(ac >> 12) & 0x3f];
*cp++ = base64_table[(ac >> 6) & 0x3f];
@@ -103,7 +103,7 @@ int base64_encode(const u8 *src, int src
*cp++ = '=';
break;
case 1:
- ac = (u32)src[0] << 16;
+ ac = src[0] << 16;
*cp++ = base64_table[ac >> 18];
*cp++ = base64_table[(ac >> 12) & 0x3f];
if (padding) {
_
More information about the Linux-nvme
mailing list