From: Nathan Chancellor <nathan@kernel.org>
To: Lasse Collin <lasse.collin@tukaani.org>,
Thorsten Blum <thorsten.blum@linux.dev>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib/xz: replace min_t with min
Date: Wed, 10 Jun 2026 16:23:23 -0700 [thread overview]
Message-ID: <20260610232323.GA1071374@ax162> (raw)
In-Reply-To: <20260609150030.634570-1-lasse.collin@tukaani.org>
On Tue, Jun 09, 2026 at 06:00:28PM +0300, Lasse Collin wrote:
> From: Thorsten Blum <thorsten.blum@linux.dev>
>
> Use the simpler min() macro since the values are unsigned and
> compatible.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> Reviewed-by: Lasse Collin <lasse.collin@tukaani.org>
> Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
...
> diff --git a/lib/xz/xz_dec_lzma2.c b/lib/xz/xz_dec_lzma2.c
> index 4b783ac94e71..9d80342b9c6b 100644
> --- a/lib/xz/xz_dec_lzma2.c
> +++ b/lib/xz/xz_dec_lzma2.c
> @@ -354,7 +354,7 @@ static bool dict_repeat(struct dictionary *dict, uint32_t *len, uint32_t dist)
> if (dist >= dict->full || dist >= dict->size)
> return false;
>
> - left = min_t(size_t, dict->limit - dict->pos, *len);
> + left = min(dict->limit - dict->pos, *len);
> *len -= left;
>
> back = dict->pos - dist - 1;
> @@ -1098,9 +1098,8 @@ enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, struct xz_buf *b)
> * the output buffer yet, we may run this loop
> * multiple times without changing s->lzma2.sequence.
> */
> - dict_limit(&s->dict, min_t(size_t,
> - b->out_size - b->out_pos,
> - s->lzma2.uncompressed));
> + dict_limit(&s->dict, min(b->out_size - b->out_pos,
> + s->lzma2.uncompressed));
> if (!lzma2_lzma(s, b))
> return XZ_DATA_ERROR;
>
These two hunks from this change in -next as 1003161e12ac ("lib/xz:
replace min_t with min") cause warnings in the arch/powerpc/boot code,
as it uses an old, simple version of min() and max() that does not have
the improvements done in d03eba99f5bf ("minmax: allow
min()/max()/clamp() if the arguments have the same signedness."):
In file included from arch/powerpc/boot/ops.h:13,
from arch/powerpc/boot/decompress.c:12:
arch/powerpc/boot/../../../lib/xz/xz_dec_lzma2.c: In function 'dict_repeat':
arch/powerpc/boot/types.h:31:21: warning: comparison of distinct pointer types lacks a cast [-Wcompare-distinct-pointer-types]
31 | (void) (&_x == &_y); \
| ^~
arch/powerpc/boot/../../../lib/xz/xz_dec_lzma2.c:357:16: note: in expansion of macro 'min'
357 | left = min(dict->limit - dict->pos, *len);
| ^~~
arch/powerpc/boot/../../../lib/xz/xz_dec_lzma2.c: In function 'xz_dec_lzma2_run':
arch/powerpc/boot/types.h:31:21: warning: comparison of distinct pointer types lacks a cast [-Wcompare-distinct-pointer-types]
31 | (void) (&_x == &_y); \
| ^~
arch/powerpc/boot/../../../lib/xz/xz_dec_lzma2.c:1101:46: note: in expansion of macro 'min'
1101 | dict_limit(&s->dict, min(b->out_size - b->out_pos,
| ^~~
We could try to update arch/powerpc/boot/types.h with the current min()
and max() versions but that will require dragging in many other macros.
Could try to make the Linux headers work as is to reduce duplication but
that is likely quite involved (and maybe even undesirable). Backing out
of these two changes is likely a better solution, at least for now.
--
Cheers,
Nathan
next prev parent reply other threads:[~2026-06-10 23:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 15:00 Lasse Collin
2026-06-10 23:23 ` Nathan Chancellor [this message]
2026-06-10 23:48 ` Andrew Morton
2026-06-11 9:54 ` David Laight
2026-06-12 19:41 ` Lasse Collin
-- strict thread matches above, loose matches on Subject: below --
2026-06-08 19:41 Thorsten Blum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260610232323.GA1071374@ax162 \
--to=nathan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=lasse.collin@tukaani.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thorsten.blum@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®