From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753055AbdKHWbT (ORCPT ); Wed, 8 Nov 2017 17:31:19 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:45631 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752843AbdKHWat (ORCPT ); Wed, 8 Nov 2017 17:30:49 -0500 X-Google-Smtp-Source: ABhQp+QXSvjcJi7B7pM0wBx6yR55q6pKUQ6ayBGqnnyAp24vTg8pszeCb95zu/HvLZFZHS3FRezpkg== From: Rasmus Villemoes To: kernel-hardening@lists.openwall.com Cc: linux-kernel@vger.kernel.org, Andrew Morton , Kees Cook , Rasmus Villemoes Subject: [RFC 5/6] kernel.h: implement fmtmatch() wrapper around fmtcheck() Date: Wed, 8 Nov 2017 23:30:19 +0100 Message-Id: <20171108223020.24487-6-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171108223020.24487-1-linux@rasmusvillemoes.dk> References: <20171108223020.24487-1-linux@rasmusvillemoes.dk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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