linux-hardening.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib/string_choices: Add str_plural() helper
@ 2024-02-14 16:50 Michal Wajdeczko
  2024-02-14 18:08 ` Andy Shevchenko
  2024-02-15 19:23 ` Kees Cook
  0 siblings, 2 replies; 13+ messages in thread
From: Michal Wajdeczko @ 2024-02-14 16:50 UTC (permalink / raw)
  To: linux-hardening; +Cc: Michal Wajdeczko, Andy Shevchenko, Jani Nikula

Add str_plural() helper to replace existing open implementations
used by many drivers and help improve future user facing messages.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
---
 include/linux/string_choices.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h
index 3c1091941eb8..f3cd270d11fd 100644
--- a/include/linux/string_choices.h
+++ b/include/linux/string_choices.h
@@ -42,4 +42,9 @@ static inline const char *str_yes_no(bool v)
 	return v ? "yes" : "no";
 }
 
+static inline const char *str_plural(size_t num)
+{
+	return num == 1 ? "" : "s";
+}
+
 #endif
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-02-15 19:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-14 16:50 [PATCH] lib/string_choices: Add str_plural() helper Michal Wajdeczko
2024-02-14 18:08 ` Andy Shevchenko
2024-02-14 18:09   ` Andy Shevchenko
2024-02-14 18:30     ` Jani Nikula
2024-02-14 18:49       ` Andy Shevchenko
2024-02-14 19:07         ` Kees Cook
2024-02-15 15:20           ` Jani Nikula
2024-02-15 15:37             ` Michal Wajdeczko
2024-02-15 16:11               ` Andy Shevchenko
2024-02-15 16:55                 ` Michal Wajdeczko
2024-02-15 17:05                   ` Andy Shevchenko
2024-02-15 17:14                     ` Michal Wajdeczko
2024-02-15 19:23 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).