From: David Laight <david.laight.linux@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: zenghongling <zenghongling@kylinos.cn>,
muchun.song@linux.dev, osalvador@suse.de, david@kernel.org,
akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, zhongling0719@126.com
Subject: Re: [PATCH] mm/hugetlb_vmemmap: Use max() macro to simplify the code
Date: Wed, 21 Jan 2026 11:32:12 +0000 [thread overview]
Message-ID: <20260121113212.3d685ad2@pumpkin> (raw)
In-Reply-To: <aXBvY_MjV2GZ0WPN@casper.infradead.org>
On Wed, 21 Jan 2026 06:17:07 +0000
Matthew Wilcox <willy@infradead.org> wrote:
> On Wed, Jan 21, 2026 at 09:51:14AM +0800, zenghongling wrote:
> > Use the max() macro to simplify the function and improve
> > its readability.
>
> How does this improve readability? I understand what this does in
> the ternary form. I have to think far harder about it in the max()
> form.
I must do a patch for checkpatch.pl to stop it suggesting min/max
for trivial cases.
Oh - and stop it ever suggesting the _t variants.
IMHO it is better to have an explicit cast on one of the parameters.
David
>
> > if (!is_power_of_2(sizeof(struct page)))
> > return 0;
> > - return size > 0 ? size : 0;
> > + return max(size, 0);
> > }
>
prev parent reply other threads:[~2026-01-21 13:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-21 1:51 zenghongling
2026-01-21 2:33 ` Muchun Song
2026-01-21 6:17 ` Matthew Wilcox
2026-01-21 11:32 ` David Laight [this message]
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=20260121113212.3d685ad2@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=willy@infradead.org \
--cc=zenghongling@kylinos.cn \
--cc=zhongling0719@126.com \
/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