Commit 9ca5facd authored by Michal Wajdeczko's avatar Michal Wajdeczko Committed by Kees Cook

lib/string_choices: Add str_plural() helper

Add str_plural() helper to replace existing open implementations
used by many drivers and help improve future user facing messages.
Signed-off-by: default avatarMichal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://lore.kernel.org/r/20240214165015.1656-1-michal.wajdeczko@intel.comSigned-off-by: default avatarKees Cook <keescook@chromium.org>
parent 08d45ee8
......@@ -42,4 +42,15 @@ static inline const char *str_yes_no(bool v)
return v ? "yes" : "no";
}
/**
* str_plural - Return the simple pluralization based on English counts
* @num: Number used for deciding pluralization
*
* If @num is 1, returns empty string, otherwise returns "s".
*/
static inline const char *str_plural(size_t num)
{
return num == 1 ? "" : "s";
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment