Some users may prefer to check a "user-supplied" string upfront and return EINVAL rather than using the the template as a fallback for printf'ing later. fmtmatch() is simply a shorthand for
fmtcheck(a, b, c | FMTCHECK_SILENT) == a. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- include/linux/kernel.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 8e9154e100c3..c2b710426227 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -507,11 +507,18 @@ _fmtcheck(const char *fmt, const char *tmpl, unsigned flags) return fmt; } #endif + +static inline bool +_fmtmatch(const char *fmt, const char *tmpl, unsigned flags) +{ + return _fmtcheck(fmt, tmpl, flags | FMTCHECK_SILENT) == fmt; +} /* * Use of fmtcheck is pointless if the template is not a string * literal, so try to enforce that. */ #define fmtcheck(fmt, tmpl, flags) _fmtcheck(fmt, "" tmpl "", flags) +#define fmtmatch(fmt, tmpl, flags) _fmtmatch(fmt, "" tmpl "", flags) extern __scanf(2, 3) int sscanf(const char *, const char *, ...); -- 2.19.1.6.gbde171bbf5