From: Hongbo Li Date: Tue, 27 Aug 2024 02:45:15 +0000 (+0800) Subject: lib/string_choices: add str_true_false()/str_false_true() helper X-Git-Tag: v6.12-rc1~114^2~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=32cebfe1cc21a84e4a907575bb9fd1c3f6b091fd;p=thirdparty%2Fkernel%2Flinux.git lib/string_choices: add str_true_false()/str_false_true() helper Add str_true_false()/str_false_true() helper to retur a "true" or "false" string literal. We found more than 10 cases currently exist in the tree. So these helpers can be used for these cases. This patch (of 3): Add str_true_false()/str_false_true() helper to return "true" or "false" string literal. Link: https://lkml.kernel.org/r/20240827024517.914100-1-lihongbo22@huawei.com Link: https://lkml.kernel.org/r/20240827024517.914100-2-lihongbo22@huawei.com Signed-off-by: Hongbo Li Cc: Andy Shevchenko Cc: Anna Schumaker Cc: Greg Kroah-Hartman Cc: Kees Cook Cc: Matthew Wilcox Cc: Trond Myklebust Signed-off-by: Andrew Morton --- diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h index d9ebe20229f81..4a2432313b8ef 100644 --- a/include/linux/string_choices.h +++ b/include/linux/string_choices.h @@ -42,6 +42,12 @@ static inline const char *str_yes_no(bool v) return v ? "yes" : "no"; } +static inline const char *str_true_false(bool v) +{ + return v ? "true" : "false"; +} +#define str_false_true(v) str_true_false(!(v)) + /** * str_plural - Return the simple pluralization based on English counts * @num: Number used for deciding pluralization