Skip to content

Commit c121d5c

Browse files
Hongbo Likees
authored andcommitted
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 <[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 c2708ba commit c121d5c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

include/linux/string_choices.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
#ifndef _LINUX_STRING_CHOICES_H_
33
#define _LINUX_STRING_CHOICES_H_
44

5+
/*
6+
* Here provide a series of helpers in the str_$TRUE_$FALSE format (you can
7+
* also expand some helpers as needed), where $TRUE and $FALSE are their
8+
* corresponding literal strings. These helpers can be used in the printing
9+
* and also in other places where constant strings are required. Using these
10+
* helpers offers the following benefits:
11+
* 1) Reducing the hardcoding of strings, which makes the code more elegant
12+
* through these simple literal-meaning helpers.
13+
* 2) Unifying the output, which prevents the same string from being printed
14+
* in various forms, such as enable/disable, enabled/disabled, en/dis.
15+
* 3) Deduping by the linker, which results in a smaller binary file.
16+
*/
17+
518
#include <linux/types.h>
619

720
static inline const char *str_enable_disable(bool v)

0 commit comments

Comments
 (0)