diff options
author | Hongbo Li <lihongbo22@huawei.com> | 2024-09-05 17:25:40 +0800 |
---|---|---|
committer | Kees Cook <kees@kernel.org> | 2024-09-05 09:50:16 -0700 |
commit | c121d5cc3a993cdbfab46a152bdd50227a4d5e8c (patch) | |
tree | 8294936578197e4affb65c491420e3cba8086388 /include/linux/string_choices.h | |
parent | c2708ba91c3c1fba424b77de83b6fc45cbf38c46 (diff) |
lib/string_choices: Add some comments to make more clear for string choices helpers.
Add some comments to explain why we should use string_choices helpers.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Acked-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20240905092540.2962122-3-lihongbo22@huawei.com
Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'include/linux/string_choices.h')
-rw-r--r-- | include/linux/string_choices.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h index fd067992260a..120ca0f28e95 100644 --- a/include/linux/string_choices.h +++ b/include/linux/string_choices.h @@ -2,6 +2,19 @@ #ifndef _LINUX_STRING_CHOICES_H_ #define _LINUX_STRING_CHOICES_H_ +/* + * Here provide a series of helpers in the str_$TRUE_$FALSE format (you can + * also expand some helpers as needed), where $TRUE and $FALSE are their + * corresponding literal strings. These helpers can be used in the printing + * and also in other places where constant strings are required. Using these + * helpers offers the following benefits: + * 1) Reducing the hardcoding of strings, which makes the code more elegant + * through these simple literal-meaning helpers. + * 2) Unifying the output, which prevents the same string from being printed + * in various forms, such as enable/disable, enabled/disabled, en/dis. + * 3) Deduping by the linker, which results in a smaller binary file. + */ + #include <linux/types.h> static inline const char *str_enable_disable(bool v) |