From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: linux-hardening@vger.kernel.org
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Jani Nikula <jani.nikula@intel.com>
Subject: [PATCH] lib/string_choices: Add str_plural() helper
Date: Wed, 14 Feb 2024 17:50:15 +0100 [thread overview]
Message-ID: <20240214165015.1656-1-michal.wajdeczko@intel.com> (raw)
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
next reply other threads:[~2024-02-14 16:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-14 16:50 Michal Wajdeczko [this message]
2024-02-14 18:08 ` [PATCH] lib/string_choices: Add str_plural() helper 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240214165015.1656-1-michal.wajdeczko@intel.com \
--to=michal.wajdeczko@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=jani.nikula@intel.com \
--cc=linux-hardening@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).