lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8d19aece-3a33-4667-8bcf-635a3a861d1d@huawei.com>
Date: Wed, 28 Aug 2024 09:48:21 +0800
From: Hongbo Li <lihongbo22@...wei.com>
To: Andrew Morton <akpm@...ux-foundation.org>
CC: <kees@...nel.org>, <andy@...nel.org>, <trondmy@...nel.org>,
	<anna@...nel.org>, <gregkh@...uxfoundation.org>,
	<linux-hardening@...r.kernel.org>, <linux-mm@...ck.org>,
	<linux-nfs@...r.kernel.org>
Subject: Re: [PATCH -next v3 1/3] lib/string_choices: Add
 str_true_false()/str_false_true() helper



On 2024/8/28 7:42, Andrew Morton wrote:
> On Tue, 27 Aug 2024 10:45:15 +0800 Hongbo Li <lihongbo22@...wei.com> wrote:
> 
>> Add str_true_false()/str_false_true() helper to return "true" or
>> "false" string literal.
>>
>> ...
>>
>> --- a/include/linux/string_choices.h
>> +++ b/include/linux/string_choices.h
>> @@ -48,6 +48,12 @@ static inline const char *str_up_down(bool v)
>>   }
>>   #define str_down_up(v)		str_up_down(!(v))
>>   
>> +static inline const char *str_true_false(bool v)
>> +{
>> +	return v ? "true" : "false";
>> +}
>> +#define str_false_true(v)		str_true_false(!(v))
>> +
>>   /**
>>    * str_plural - Return the simple pluralization based on English counts
>>    * @num: Number used for deciding pluralization
> 
> This might result in copies of the strings "true" and "false" being
> generated for every .c file which uses this function, resulting in
> unnecessary bloat.
> 
> It's possible that the compiler/linker can eliminate this duplication.
> If not, I suggest that every function in string_choices.h be uninlined.
The inline function is in header file, it will cause code expansion. It 
should avoid the the copies of the strings.

Thanks,
Hongbo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ