mbox series

[-next,0/2] Add str_true_false()/str_false_true() helper

Message ID 20240823062046.3323694-1-lihongbo22@huawei.com (mailing list archive)
Headers show
Series Add str_true_false()/str_false_true() helper | expand

Message

Hongbo Li Aug. 23, 2024, 6:20 a.m. UTC
Add str_true_false()/str_false_true() helper to "true" or "false"
string literal. And we found more than 10 cases currently exist
in the tree. So these helpers can be used for these cases.

Hongbo Li (2):
  lib/string_choices: Add str_true_false() helper
  lib/string_choices: Add wrapper for str_false_true()

 include/linux/string_choices.h | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Andy Shevchenko Aug. 23, 2024, 1:22 p.m. UTC | #1
On Fri, Aug 23, 2024 at 9:13 AM Hongbo Li <lihongbo22@huawei.com> wrote:
>
> Add str_true_false()/str_false_true() helper to "true" or "false"
> string literal. And we found more than 10 cases currently exist
> in the tree. So these helpers can be used for these cases.

Squash them into a single patch. There is no need to split these.
Greg Kroah-Hartman Aug. 23, 2024, 1:38 p.m. UTC | #2
On Fri, Aug 23, 2024 at 04:22:32PM +0300, Andy Shevchenko wrote:
> On Fri, Aug 23, 2024 at 9:13 AM Hongbo Li <lihongbo22@huawei.com> wrote:
> >
> > Add str_true_false()/str_false_true() helper to "true" or "false"
> > string literal. And we found more than 10 cases currently exist
> > in the tree. So these helpers can be used for these cases.
> 
> Squash them into a single patch. There is no need to split these.

And let's see some patches that change existing code to use them, we
can't add new functions that are never used in the tree.

thanks,

greg k-h
Andy Shevchenko Aug. 23, 2024, 2:25 p.m. UTC | #3
On Fri, Aug 23, 2024 at 09:38:39PM +0800, Greg KH wrote:
> On Fri, Aug 23, 2024 at 04:22:32PM +0300, Andy Shevchenko wrote:
> > On Fri, Aug 23, 2024 at 9:13 AM Hongbo Li <lihongbo22@huawei.com> wrote:
> > >
> > > Add str_true_false()/str_false_true() helper to "true" or "false"
> > > string literal. And we found more than 10 cases currently exist
> > > in the tree. So these helpers can be used for these cases.
> > 
> > Squash them into a single patch. There is no need to split these.
> 
> And let's see some patches that change existing code to use them, we
> can't add new functions that are never used in the tree.

Exactly, thanks, Greg!
Hongbo Li Aug. 24, 2024, 2:07 a.m. UTC | #4
On 2024/8/23 21:38, Greg KH wrote:
> On Fri, Aug 23, 2024 at 04:22:32PM +0300, Andy Shevchenko wrote:
>> On Fri, Aug 23, 2024 at 9:13 AM Hongbo Li <lihongbo22@huawei.com> wrote:
>>>
>>> Add str_true_false()/str_false_true() helper to "true" or "false"
>>> string literal. And we found more than 10 cases currently exist
>>> in the tree. So these helpers can be used for these cases.
>>
>> Squash them into a single patch. There is no need to split these.
> 
> And let's see some patches that change existing code to use them, we
> can't add new functions that are never used in the tree.
> 

After this helper being added, I will add the coccinelle rules and do 
some replacements on the existing code to use them. Now there are many 
existing codes have use like this way (just use grep -rn "\"true\" : 
\"false\"" . to lookup):

fs/ceph/debugfs.c:360  seq_printf(s, "blocklisted: %s\n", 
fsc->blocklisted ? "true" : "false");

./net/sunrpc/backchannel_rqst.c:233 list_empty(&xprt->bc_pa_list) ? 
"true" : "false");

./crypto/drbg.c:1415  drbg->pr ? "true" : "false"

./sound/soc/intel/skylake/skl-debug.c:133 mconfig->pipe->passthru ? 
"true" : "false");

./mm/memory-tiers.c:925 numa_demotion_enabled ? "true" : "false");

etc.


> thanks,
> 
> greg k-h