]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
lib/string_choices: Add str_true_false()/str_false_true() helper
authorHongbo Li <lihongbo22@huawei.com>
Tue, 27 Aug 2024 02:45:15 +0000 (10:45 +0800)
committerKees Cook <kees@kernel.org>
Thu, 5 Sep 2024 16:48:40 +0000 (09:48 -0700)
Add str_true_false()/str_false_true() helper to return "true" or
"false" string literal.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Link: https://lore.kernel.org/r/20240827024517.914100-2-lihongbo22@huawei.com
Signed-off-by: Kees Cook <kees@kernel.org>
include/linux/string_choices.h

index 1320bcdcb89cb5570906586393fb12dcf6827cbc..ebcc56b28ede5c63ec59af46f8ed8aa6f202bdb2 100644 (file)
@@ -48,6 +48,12 @@ static inline const char *str_up_down(bool v)
 }
 #define str_down_up(v)         str_up_down(!(v))
 
+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