Skip to content

Commit c2708ba

Browse files
Hongbo Likees
authored andcommitted
lib/string_choices: Introduce several opposite string choice helpers
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. Signed-off-by: Hongbo Li <[email protected]> Acked-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 6ff4cd1 commit c2708ba

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

include/linux/string_choices.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ static inline const char *str_enable_disable(bool v)
88
{
99
return v ? "enable" : "disable";
1010
}
11+
#define str_disable_enable(v) str_enable_disable(!(v))
1112

1213
static inline const char *str_enabled_disabled(bool v)
1314
{
1415
return v ? "enabled" : "disabled";
1516
}
17+
#define str_disabled_enabled(v) str_enabled_disabled(!(v))
1618

1719
static inline const char *str_hi_lo(bool v)
1820
{
@@ -36,11 +38,13 @@ static inline const char *str_on_off(bool v)
3638
{
3739
return v ? "on" : "off";
3840
}
41+
#define str_off_on(v) str_on_off(!(v))
3942

4043
static inline const char *str_yes_no(bool v)
4144
{
4245
return v ? "yes" : "no";
4346
}
47+
#define str_no_yes(v) str_yes_no(!(v))
4448

4549
static inline const char *str_up_down(bool v)
4650
{

0 commit comments

Comments
 (0)