mbox series

[-next,v2,0/2] Introduce several opposite string choice helpers

Message ID 20240905092540.2962122-1-lihongbo22@huawei.com (mailing list archive)
Headers show
Series Introduce several opposite string choice helpers | expand

Message

Hongbo Li Sept. 5, 2024, 9:25 a.m. UTC
Similar to the exists helper: str_enable_disable/
str_enabled_disabled/str_on_off/str_yes_no helpers, we can
add the opposite helpers. That's str_disable_enable,
str_disabled_enabled, str_off_on and str_no_yes.

There are more than 10 cases currently (expect
str_disable_enable now has 3 use cases) exist in the code
can be replaced with these helper.

Changes in v2:
  - Remove the use cases and only keep the added helpers.
  - Add comments to explaing the use of string choices' helpers
    as suggested by Andy.

v1: https://lore.kernel.org/netdev/20240831095840.4173362-1-lihongbo22@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(+)

Comments

Andy Shevchenko Sept. 5, 2024, 11:32 a.m. UTC | #1
On Thu, Sep 05, 2024 at 05:25:38PM +0800, Hongbo Li wrote:
> Similar to the exists helper: str_enable_disable/
> str_enabled_disabled/str_on_off/str_yes_no helpers, we can
> add the opposite helpers. That's str_disable_enable,
> str_disabled_enabled, str_off_on and str_no_yes.
> 
> There are more than 10 cases currently (expect
> str_disable_enable now has 3 use cases) exist in the code
> can be replaced with these helper.

Acked-by: Andy Shevchenko <andy@kernel.org>
Kees Cook Sept. 5, 2024, 4:53 p.m. UTC | #2
On Thu, 05 Sep 2024 17:25:38 +0800, Hongbo Li wrote:
> Similar to the exists helper: str_enable_disable/
> str_enabled_disabled/str_on_off/str_yes_no helpers, we can
> add the opposite helpers. That's str_disable_enable,
> str_disabled_enabled, str_off_on and str_no_yes.
> 
> There are more than 10 cases currently (expect
> str_disable_enable now has 3 use cases) exist in the code
> can be replaced with these helper.
> 
> [...]

Applied to for-next/hardening, thanks!

[1/2] lib/string_choices: Introduce several opposite string choice helpers
      https://git.kernel.org/kees/c/c2708ba91c3c
[2/2] lib/string_choices: Add some comments to make more clear for string choices helpers.
      https://git.kernel.org/kees/c/c121d5cc3a99

Take care,