Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed,  8 Nov 2017 23:30:19 +0100
From: Rasmus Villemoes <>
	Andrew Morton <>,
	Kees Cook <>,
	Rasmus Villemoes <>
Subject: [RFC 5/6] kernel.h: implement fmtmatch() wrapper around fmtcheck()

I couldn't come up with a better name, suggestions welcome.

Some users may prefer to EINVAL rather than using the the template as a
fallback for printf'ing. fmtmatch() is simply a shorthand for
fmtcheck(a, b, c) == a.

Signed-off-by: Rasmus Villemoes <>
 include/linux/kernel.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d7c6f9a9c024..5eae5ecb590d 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -466,6 +466,13 @@ const char *_fmtcheck(const char *fmt, const char *tmpl, unsigned flags);
 #define FMTCHECK_SILENT        0x01
+#define fmtmatch(fmt, tmpl, flags) _fmtmatch(fmt, "" tmpl "", flags)
+static inline bool
+_fmtmatch(const char *fmt, const char *tmpl, unsigned flags)
+	return _fmtcheck(fmt, tmpl, flags) == fmt;
 extern __scanf(2, 3)
 int sscanf(const char *, const char *, ...);
 extern __scanf(2, 0)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.