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)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 2 Sep 2024 03:43:41 +0000 (20:43 -0700)
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 <lihongbo22@huawei.com>
Cc: Andy Shevchenko <andy@kernel.org>
Cc: Anna Schumaker <anna@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Kees Cook <kees@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Trond Myklebust <trondmy@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/string_choices.h

index d9ebe20229f810d1f002c14ef0e918a0a851123d..4a2432313b8efe67f6efe7c1d423ec3e8d62689e 100644 (file)
@@ -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