lkml.org 
[lkml]   [2017]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC 5/6] kernel.h: implement fmtmatch() wrapper around fmtcheck()
Date
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 <linux@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 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 FMTCHECK_NO_EXTRA_ARGS 0x02

+#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)
--
2.11.0
\
 
 \ /
  Last update: 2017-11-08 23:32    [W:0.165 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site