Linux Security Modules development
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: Qianfeng Rong <rongqianfeng@vivo.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Qianfeng Rong <rongqianfeng@vivo.com>
Subject: Re: [PATCH] security: min_addr: use max() to improve code
Date: Thu, 14 Aug 2025 22:17:46 -0400	[thread overview]
Message-ID: <8ab2084cc35ddc9f2a4796ff7cd88954@paul-moore.com> (raw)
In-Reply-To: <20250814142653.283355-1-rongqianfeng@vivo.com>

On Aug 14, 2025 Qianfeng Rong <rongqianfeng@vivo.com> wrote:
> 
> Use max() to reduce the code in update_mmap_min_addr() and improve its
> readability.
> 
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> ---
>  security/min_addr.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/security/min_addr.c b/security/min_addr.c
> index df1bc643d886..50035bc9281c 100644
> --- a/security/min_addr.c
> +++ b/security/min_addr.c
> @@ -16,10 +16,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
>  static void update_mmap_min_addr(void)
>  {
>  #ifdef CONFIG_LSM_MMAP_MIN_ADDR
> -	if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
> -		mmap_min_addr = dac_mmap_min_addr;
> -	else
> -		mmap_min_addr = CONFIG_LSM_MMAP_MIN_ADDR;
> +	mmap_min_addr = max(dac_mmap_min_addr, CONFIG_LSM_MMAP_MIN_ADDR);

It seems like the umax() macro would be a better choice here, yes?

It might also be a good idea to explicitly include the
include/linux/minmax.h header in this file.

>  #else
>  	mmap_min_addr = dac_mmap_min_addr;
>  #endif
> -- 
> 2.34.1

--
paul-moore.com

  reply	other threads:[~2025-08-15  2:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14 14:26 [PATCH] security: min_addr: use max() to improve code Qianfeng Rong
2025-08-15  2:17 ` Paul Moore [this message]
2025-08-15  3:39   ` Qianfeng Rong

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=8ab2084cc35ddc9f2a4796ff7cd88954@paul-moore.com \
    --to=paul@paul-moore.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=rongqianfeng@vivo.com \
    --cc=serge@hallyn.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