mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qianfeng Rong <rongqianfeng@vivo.com>
To: Paul Moore <paul@paul-moore.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] security: min_addr: use max() to improve code
Date: Fri, 15 Aug 2025 11:39:59 +0800	[thread overview]
Message-ID: <1ef37cd9-9aa8-4276-9b5e-f9094effbc7d@vivo.com> (raw)
In-Reply-To: <8ab2084cc35ddc9f2a4796ff7cd88954@paul-moore.com>


在 2025/8/15 10:17, Paul Moore 写道:
> 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?


You are right, using umax() here makes the semantics clearer.

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


ok, Will do in the next version.

>
>>   #else
>>   	mmap_min_addr = dac_mmap_min_addr;
>>   #endif
>> -- 
>> 2.34.1
> --
> paul-moore.com
Best regards,
Qianfeng

      reply	other threads:[~2025-08-15  3:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14 14:26 Qianfeng Rong
2025-08-15  2:17 ` Paul Moore
2025-08-15  3:39   ` Qianfeng Rong [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=1ef37cd9-9aa8-4276-9b5e-f9094effbc7d@vivo.com \
    --to=rongqianfeng@vivo.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.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

all inboxes | Powered by JetHome®