Re: [PATCH 1/2] lib/xz: Use size_t instead of uint32_t in a few places

From: Thorsten Blum

Date: Mon Jun 15 2026 - 07:29:17 EST


On Sun, Jun 14, 2026 at 07:05:17PM +0300, Lasse Collin wrote:
> Reduce the number of uint32_t <-> size_t conversions a little. Eliminating
> such conversions entirely would require changing almost all uint32_t to
> size_t, which would look confusing and increase the sizes of the structs
> even more. Going the other way, converting everything to uint32_t, isn't
> possible because the input and output buffers use size_t in struct xz_buf.
>
> Now both arguments to min() have the same type. This is required to for
> compatibility with PowerPC boot code[1] whose min() is strict like
> include/linux/minmax.h was before the commit d03eba99f5bf ("minmax: allow
> min()/max()/clamp() if the arguments have the same signedness.").
>
> Swap the order of the "state" and "len" in struct lzma_dec to avoid
> padding in the middle of the struct when size_t is 64 bits. The
> reordering doesn't change the size of the struct; the padding just
> appears at the end instead.
>
> dict_flush() used to truncate size_t to uint32_t when returning.
> This wasn't a bug; the value is always small enough.
>
> Reported-by: Nathan Chancellor <nathan@xxxxxxxxxx>
> Closes: https://lore.kernel.org/lkml/20260610232323.GA1071374@ax162/ [1]
> Cc: Thorsten Blum <thorsten.blum@xxxxxxxxx>
> Cc: David Laight <david.laight.linux@xxxxxxxxx>
> Signed-off-by: Lasse Collin <lasse.collin@xxxxxxxxxxx>

LGTM, thanks!

Reviewed-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>