* [PATCH -next 0/2] Add str_true_false()/str_false_true() helper
@ 2024-08-23 6:20 Hongbo Li
2024-08-23 6:20 ` [PATCH -next 1/2] lib/string_choices: Add str_true_false() helper Hongbo Li
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Hongbo Li @ 2024-08-23 6:20 UTC (permalink / raw)
To: kees, andy; +Cc: lihongbo22, linux-hardening
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(+)
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH -next 1/2] lib/string_choices: Add str_true_false() helper
2024-08-23 6:20 [PATCH -next 0/2] Add str_true_false()/str_false_true() helper Hongbo Li
@ 2024-08-23 6:20 ` Hongbo Li
2024-08-23 6:20 ` [PATCH -next 2/2] lib/string_choices: Add wrapper for str_false_true() Hongbo Li
2024-08-23 13:22 ` [PATCH -next 0/2] Add str_true_false()/str_false_true() helper Andy Shevchenko
2 siblings, 0 replies; 7+ messages in thread
From: Hongbo Li @ 2024-08-23 6:20 UTC (permalink / raw)
To: kees, andy; +Cc: lihongbo22, linux-hardening
Add str_true_false() helper to return "true" or "false"
string literal.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
include/linux/string_choices.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h
index 1320bcdcb89c..7c74497caf2b 100644
--- a/include/linux/string_choices.h
+++ b/include/linux/string_choices.h
@@ -48,6 +48,11 @@ 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";
+}
+
/**
* str_plural - Return the simple pluralization based on English counts
* @num: Number used for deciding pluralization
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH -next 2/2] lib/string_choices: Add wrapper for str_false_true()
2024-08-23 6:20 [PATCH -next 0/2] Add str_true_false()/str_false_true() helper Hongbo Li
2024-08-23 6:20 ` [PATCH -next 1/2] lib/string_choices: Add str_true_false() helper Hongbo Li
@ 2024-08-23 6:20 ` Hongbo Li
2024-08-23 13:22 ` [PATCH -next 0/2] Add str_true_false()/str_false_true() helper Andy Shevchenko
2 siblings, 0 replies; 7+ messages in thread
From: Hongbo Li @ 2024-08-23 6:20 UTC (permalink / raw)
To: kees, andy; +Cc: lihongbo22, linux-hardening
There are many "false" : "true" format in the kernel tree,
so we add str_false_true() as well.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
include/linux/string_choices.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h
index 7c74497caf2b..ebcc56b28ede 100644
--- a/include/linux/string_choices.h
+++ b/include/linux/string_choices.h
@@ -52,6 +52,7 @@ 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
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH -next 0/2] Add str_true_false()/str_false_true() helper
2024-08-23 6:20 [PATCH -next 0/2] Add str_true_false()/str_false_true() helper Hongbo Li
2024-08-23 6:20 ` [PATCH -next 1/2] lib/string_choices: Add str_true_false() helper Hongbo Li
2024-08-23 6:20 ` [PATCH -next 2/2] lib/string_choices: Add wrapper for str_false_true() Hongbo Li
@ 2024-08-23 13:22 ` Andy Shevchenko
2024-08-23 13:38 ` Greg KH
2 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2024-08-23 13:22 UTC (permalink / raw)
To: Hongbo Li; +Cc: kees, andy, linux-hardening
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.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next 0/2] Add str_true_false()/str_false_true() helper
2024-08-23 13:22 ` [PATCH -next 0/2] Add str_true_false()/str_false_true() helper Andy Shevchenko
@ 2024-08-23 13:38 ` Greg KH
2024-08-23 14:25 ` Andy Shevchenko
2024-08-24 2:07 ` Hongbo Li
0 siblings, 2 replies; 7+ messages in thread
From: Greg KH @ 2024-08-23 13:38 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Hongbo Li, kees, andy, linux-hardening
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next 0/2] Add str_true_false()/str_false_true() helper
2024-08-23 13:38 ` Greg KH
@ 2024-08-23 14:25 ` Andy Shevchenko
2024-08-24 2:07 ` Hongbo Li
1 sibling, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-08-23 14:25 UTC (permalink / raw)
To: Greg KH; +Cc: Hongbo Li, kees, linux-hardening
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!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next 0/2] Add str_true_false()/str_false_true() helper
2024-08-23 13:38 ` Greg KH
2024-08-23 14:25 ` Andy Shevchenko
@ 2024-08-24 2:07 ` Hongbo Li
1 sibling, 0 replies; 7+ messages in thread
From: Hongbo Li @ 2024-08-24 2:07 UTC (permalink / raw)
To: Greg KH, Andy Shevchenko; +Cc: kees, andy, linux-hardening
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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-08-24 2:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-23 6:20 [PATCH -next 0/2] Add str_true_false()/str_false_true() helper Hongbo Li
2024-08-23 6:20 ` [PATCH -next 1/2] lib/string_choices: Add str_true_false() helper Hongbo Li
2024-08-23 6:20 ` [PATCH -next 2/2] lib/string_choices: Add wrapper for str_false_true() Hongbo Li
2024-08-23 13:22 ` [PATCH -next 0/2] Add str_true_false()/str_false_true() helper Andy Shevchenko
2024-08-23 13:38 ` Greg KH
2024-08-23 14:25 ` Andy Shevchenko
2024-08-24 2:07 ` Hongbo Li
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.