Re: [PATCH v1 1/1] base64: Unroll the tables initialisers

From: Andy Shevchenko
Date: Mon Nov 03 2025 - 14:18:55 EST


On Mon, Nov 03, 2025 at 08:05:10PM +0100, Andy Shevchenko wrote:
> Currently the initialisers of the tables have duplicate indices.
> This prevents from building with `make W=1`.
>
> To address the issue, unroll the table initialisers with generated
> arrays by the following Python excerpt:
>
> CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
>
> def gen_table(ch62, ch63):
> table = [ 0xff ] * 256
> for idx, char in enumerate(CHARS):
> table[ord(char)] = idx
> table[ord(ch62)] = 62
> table[ord(ch63)] = 63
>
> for i in range(0, len(table), 8):
> print (f"\t{', '.join(f"0x{c:02x}" for c in table[i:i+8])},\t/* {i:-3d} - {i+7:-3d} */")

I haven't added a Fixes tag as the idea to fold this to the initial
contribution.

--
With Best Regards,
Andy Shevchenko