include/linux/string_choices.h | 6 ++++++ 1 file changed, 6 insertions(+)
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Add str_assert_deassert() helper to return "assert" or "deassert"
string literal depending on the boolean argument. Also add the
inversed variant str_deassert_assert().
Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
Hi All,
Note checkpatch complians about adding a new line before the macro
definition. But this is the existing style in this file. So keeping
it as is.
Cheers, Prabhakar
---
include/linux/string_choices.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h
index a27c87c954ae..ee84087d4b26 100644
--- a/include/linux/string_choices.h
+++ b/include/linux/string_choices.h
@@ -17,6 +17,12 @@
#include <linux/types.h>
+static inline const char *str_assert_deassert(bool v)
+{
+ return v ? "assert" : "deassert";
+}
+#define str_deassert_assert(v) str_assert_deassert(!(v))
+
static inline const char *str_enable_disable(bool v)
{
return v ? "enable" : "disable";
--
2.51.0
On Tue, 23 Sep 2025 10:52:29 +0100, Prabhakar wrote: > Add str_assert_deassert() helper to return "assert" or "deassert" > string literal depending on the boolean argument. Also add the > inversed variant str_deassert_assert(). > > Applied to for-next/hardening, thanks! [1/1] lib/string_choices: Add str_assert_deassert() helper https://git.kernel.org/kees/c/c8a935a31bc7 Take care, -- Kees Cook
On Tue, Sep 23, 2025 at 12:52 PM Prabhakar <prabhakar.csengg@gmail.com> wrote: > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> > > Add str_assert_deassert() helper to return "assert" or "deassert" > string literal depending on the boolean argument. Also add the > inversed variant str_deassert_assert(). FWIW, Reviewed-by: Andy Shevchenko <andy@kernel.org> ... > Note checkpatch complians about adding a new line before the macro > definition. But this is the existing style in this file. So keeping > it as is. It's a checkpatch's problem. It's fine to ignore it in this case. -- With Best Regards, Andy Shevchenko
© 2016 - 2025 Red Hat, Inc.