Add str_true_false() helper to return "true" or "false"
string literal.
Signed-off-by: Hongbo Li
---
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.
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_choi
There are many "false" : "true" format in the kernel tree,
so we add str_false_true() as well.
Signed-off-by: Hongbo Li
---
include/linux/string_choices.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/string_choices.h b/include/linux/string_choices.
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 wrote:
Add str_true_false()/str_false_true() helper to "true" or "false"
string literal. And we found more than 10 cases cu
Add str_true_false()/str_false_true() helper to return "true" or
"false" string literal.
Signed-off-by: Hongbo Li
---
v2:
- Squash into a single patch as Andy Shevchenko' suggesstion.
v1:
-
https://lore.kernel.org/all/1deb2bc4-0cd1-41a0-9434-65c02eef7...@huawei.
As discussed in the previous thread, the coccinelle rules and some
replacements will be added in the future.
Thanks,
Hongbo
On 2024/8/24 15:09, Hongbo Li wrote:
Add str_true_false()/str_false_true() helper to return "true" or
"false" string literal.
Signed-off-by
The helper str_false_true is introduced to reback "false/true"
string literal. We can simplify this format by str_false_true.
Signed-off-by: Hongbo Li
---
fs/nfs/nfs4xdr.c | 11 +--
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4x
The helper str_true_false is introduced to reback "true/false"
string literal. We can simplify this format by str_true_false.
Signed-off-by: Hongbo Li
---
mm/memory-tiers.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mm/memory-tiers.c b/mm/memory-tie
tps://lore.kernel.org/all/1deb2bc4-0cd1-41a0-9434-65c02eef7...@huawei.com/T/
Hongbo Li (3):
lib/string_choices: Add str_true_false()/str_false_true() helper
mm: make use of str_true_false helper
nfs make use of str_false_true helper
fs/nfs/nfs4xdr.c | 11 +--
include/li
Add str_true_false()/str_false_true() helper to return "true" or
"false" string literal.
Signed-off-by: Hongbo Li
---
include/linux/string_choices.h | 6 ++
1 file changed, 6 insertions(+)
diff --git a/include/linux/string_choices.h b/include/linux/string_choices.
On 2024/8/27 11:33, Matthew Wilcox wrote:
On Tue, Aug 27, 2024 at 10:45:17AM +0800, Hongbo Li wrote:
The helper str_false_true is introduced to reback "false/true"
string literal. We can simplify this format by str_false_true.
This seems unnecessarily verbose & compl
On 2024/8/28 7:42, Andrew Morton wrote:
On Tue, 27 Aug 2024 10:45:15 +0800 Hongbo Li 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
@@ -4
On 2024/8/28 11:22, Andrew Morton wrote:
On Wed, 28 Aug 2024 09:48:21 +0800 Hongbo Li wrote:
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 tha
On 2024/8/29 4:25, Andrew Morton wrote:
On Wed, 28 Aug 2024 11:49:51 +0800 Hongbo Li wrote:
Anything which is calling these functions is not performance-sensitive,
so optimizing for space is preferred. An out-of-line function which
returns a const char * will achieve this?
I think this
After str_true_false()/str_false_true() has been introduced
in the tree, we can add rules for finding places where
str_true_false()/str_false_true() can be used.
Hongbo Li (2):
coccinelle: Add rules to find str_true_false() replacements
coccinelle: Add rules to find str_false_true
After str_true_false() has been introduced in the tree,
we can add rules for finding places where str_true_false()
can be used. A simple test can find over 10 locations.
Signed-off-by: Hongbo Li
---
drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c:910:40-44:
opportunity for
As done with str_true_false(), add checks for str_false_true()
opportunities. A simple test can find over 9 cases currently
exist in the tree.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 23 +
1 file changed, 23 insertions(+)
diff --git a
cases) exist in the code
can be replaced with these helper.
Patch 1: Introduce the string choice helpers
Patch 2~4: Give the relative use cases to use these helpers.
Hongbo Li (4):
lib/string_choices: Introduce several opposite string choice helpers
tun: Make use of str_disabled_enabled helper
Use str_disabled_enabled() helper instead of open
coding the same.
Signed-off-by: Hongbo Li
---
drivers/net/tun.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 6fe5e8f7017c..29647704bda8 100644
--- a/drivers/net/tun.c
+++ b
cases) exist in the code
can be replaced with these helper.
Signed-off-by: Hongbo Li
---
include/linux/string_choices.h | 4
1 file changed, 4 insertions(+)
diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h
index f3670dbd1169..c2134eeda1fd 100644
--- a/include/
On 2024/9/1 4:07, Jakub Kicinski wrote:
On Sat, 31 Aug 2024 17:58:38 +0800 Hongbo Li wrote:
Use str_disabled_enabled() helper instead of open
coding the same.
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 6fe5e8f7017c..29647704bda8 100644
--- a/drivers/net/tun.c
+++ b/drivers
The helper str_no_yes is introduced to reback "no/yes"
string literal. We can use str_no_yes() helper instead
of open coding the same.
Signed-off-by: Hongbo Li
---
net/core/sock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/sock.c b/net/core/so
The helper str_off_on is introduced to reback "off/on"
string literal. We can use str_off_on() helper instead
of open coding the same.
Signed-off-by: Hongbo Li
---
mm/page_alloc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_all
On 2024/9/2 22:30, Willem de Bruijn wrote:
Andy Shevchenko wrote:
On Sat, Aug 31, 2024 at 01:07:41PM -0700, Jakub Kicinski wrote:
On Sat, 31 Aug 2024 17:58:38 +0800 Hongbo Li wrote:
Use str_disabled_enabled() helper instead of open
coding the same.
...
netif_info(tun
Add the __counted_by compiler attribute to the flexible array member
entries to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.
Signed-off-by: Hongbo Li
---
drivers/mmc/host/sdhci-cadence.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a
Add the __counted_by compiler attribute to the flexible array member
entries to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.
Signed-off-by: Hongbo Li
---
drivers/dma/loongson1-apb-dma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a
Add the __counted_by compiler attribute to the flexible array member
entries to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.
Signed-off-by: Hongbo Li
---
drivers/net/dsa/ocelot/felix_vsc9959.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git
On 2024/9/3 23:09, Andy Shevchenko wrote:
On Tue, Sep 03, 2024 at 02:25:53PM +0800, Hongbo Li wrote:
On 2024/9/2 22:30, Willem de Bruijn wrote:
Andy Shevchenko wrote:
On Sat, Aug 31, 2024 at 01:07:41PM -0700, Jakub Kicinski wrote:
On Sat, 31 Aug 2024 17:58:38 +0800 Hongbo Li wrote
On 2024/8/29 19:24, Hongbo Li wrote:
After str_true_false()/str_false_true() has been introduced
in the tree, we can add rules for finding places where
str_true_false()/str_false_true() can be used.
Hongbo Li (2):
coccinelle: Add rules to find str_true_false() replacements
coccinelle
On 2024/9/4 15:37, Andy Shevchenko wrote:
On Wed, Sep 4, 2024 at 5:36 AM Hongbo Li wrote:
On 2024/8/29 19:24, Hongbo Li wrote:
...
I found that there are still a few function rules that are not complete,
such as str_on_off, str_enable_disable, str_yes_no. How about adding
these rules as
As other rules done, we add rules for str_lo{w}_hi{gh}()
to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 46 +
1 file changed, 46 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
b
i/cx23885/cimax2.c:227:4-8: opportunity for str_read_write(read)
drivers/media/usb/em28xx/em28xx-video.c:941:4-9: opportunity for
str_enabled_disabled(flags)
```
Changes since v1:
- Add more rules for helpers in string_choices.h.
Thanks,
Hongbo.
Hongbo Li (9):
coccinelle: Add rules to f
As done with str_true_false(), add checks for str_false_true()
opportunities. A simple test can find over 9 cases currently
exist in the tree.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 23 +
1 file changed, 23 insertions(+)
diff --git a
As other rules done, we add rules for str_write_read()
to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 23 +
1 file changed, 23 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
b/scripts
As other rules done, we add rules for str_yes_no()
to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 23 +
1 file changed, 23 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
b/scripts
As other rules done, we add rules for str_on_off()
to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 23 +
1 file changed, 23 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
b/scripts
As other rules done, we add rules for str_hi{gh}_lo{w}()
to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 46 +
1 file changed, 46 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
b
After str_true_false() has been introduced in the tree,
we can add rules for finding places where str_true_false()
can be used. A simple test can find over 10 locations.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 23 +
1 file changed, 23
As other rules done, we add rules for str_read_write()
to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 23 +
1 file changed, 23 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
b/scripts
As other rules done, we add rules for str_enable{d}_
disable{d}() to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 46 +
1 file changed, 46 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
On 2024/9/5 8:16, Gustavo A. R. Silva wrote:
[..]
- struct sdhci_cdns_phy_param phy_params[];
+ struct sdhci_cdns_phy_param phy_params[] __counted_by(count);
It seems there is no such `count` member in the structure[1].
Since `counted_by` hasn't been released in GCC yet. Please, mak
Add some comments to explain why we should use string_choices helpers.
Signed-off-by: Hongbo Li
---
include/linux/string_choices.h | 13 +
1 file changed, 13 insertions(+)
diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h
index c2134eeda1fd..5a89261d3918
-1-lihongb...@huawei.com/
Hongbo Li (2):
lib/string_choices: Introduce several opposite string choice helpers
lib/string_choices: Add some comments to make more clear for string
choices helpers.
include/linux/string_choices.h | 17 +
1 file changed, 17 insertions(+)
--
2.34.1
cases) exist in the code
can be replaced with these helper.
Signed-off-by: Hongbo Li
---
include/linux/string_choices.h | 4
1 file changed, 4 insertions(+)
diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h
index f3670dbd1169..c2134eeda1fd 100644
--- a/include/
On 2024/9/4 17:14, Hongbo Li wrote:
We found that many of the detection rules for helpers in
string_choices.h are missing. This series of patches is
intended to complete these rules. We have verified in the
latest kernel tree that these rules can detect many places
where the string choices
On 2024/9/10 0:00, Julia Lawall wrote:
On Wed, 4 Sep 2024, Hongbo Li wrote:
After str_true_false() has been introduced in the tree,
we can add rules for finding places where str_true_false()
can be used. A simple test can find over 10 locations.
Signed-off-by: Hongbo Li
---
scripts
On 2024/9/10 10:23, Hongbo Li wrote:
On 2024/9/10 0:00, Julia Lawall wrote:
On Wed, 4 Sep 2024, Hongbo Li wrote:
After str_true_false() has been introduced in the tree,
we can add rules for finding places where str_true_false()
can be used. A simple test can find over 10 locations
After str_true_false() has been introduced in the tree,
we can add rules for finding places where str_true_false()
can be used. A simple test can find over 10 locations.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 19 +++
1 file changed, 19
As other rules done, we add rules for str_hi{gh}_lo{w}()
to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 42 +
1 file changed, 42 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
b
As other rules done, we add rules for str_read_write()
to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 19 +++
1 file changed, 19 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
b/scripts
As other rules done, we add rules for str_enable{d}_
disable{d}() to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 38 +
1 file changed, 38 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
As done with str_true_false(), add checks for str_false_true()
opportunities. A simple test can find over 9 cases currently
exist in the tree.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 19 +++
1 file changed, 19 insertions(+)
diff --git a
As other rules done, we add rules for str_on_off()
to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 19 +++
1 file changed, 19 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
b/scripts
As other rules done, we add rules for str_lo{w}_hi{gh}()
to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 38 +
1 file changed, 38 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
b
choices.h.
Thanks,
Hongbo.
Hongbo Li (10):
coccinelle: Add rules to find str_true_false() replacements
coccinelle: Add rules to find str_false_true() replacements
coccinelle: Add rules to find str_hi{gh}_lo{w}() replacements
coccinelle: Add rules to find str_lo{w}_hi{gh}() replacements
As other rules done, we add rules for str_write_read()
to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 19 +++
1 file changed, 19 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
b/scripts
As other rules done, we add rules for str_yes_no()
to check the relative opportunities.
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 19 +++
1 file changed, 19 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci
b/scripts
The parentheses are only needed if there is a disjunction, ie a
set of possible changes. If there is only one pattern, we can
remove these parentheses. Just like the format:
- x
+ y
not:
(
- x
+ y
)
Signed-off-by: Hongbo Li
---
scripts/coccinelle/api/string_choices.cocci | 8
Hi,
Gently ping for this.
Thanks,
Hongbo
On 2024/9/11 9:09, Hongbo Li wrote:
We found that many of the detection rules for helpers in
string_choices.h are missing. This series of patches is
intended to complete these rules. We have verified in the
latest kernel tree that these rules can
On 2024/9/19 14:25, Julia Lawall wrote:
On Wed, 11 Sep 2024, Hongbo Li wrote:
After str_true_false() has been introduced in the tree,
we can add rules for finding places where str_true_false()
can be used. A simple test can find over 10 locations.
Signed-off-by: Hongbo Li
---
scripts
On 2024/9/23 18:24, Julia Lawall wrote:
Thanks for testing it. I will see if there is some other way to improve the
performance.
May be every rules in the same file are executed sequentially cost a lot?
Thanks,
Hongbo
Sent from my iPhone
On 23 Sep 2024, at 09:01, Hongbo Li wrote
61 matches
Mail list logo