Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2143706imm; Mon, 28 May 2018 02:30:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp6NM7FvQbCNvwocfyDrljHLwbY1n11M3/VcyFrQcElw2xe3hpxMrPLe/w3SWBadvEiUyYN X-Received: by 2002:aa7:8009:: with SMTP id j9-v6mr12789406pfi.52.1527499824758; Mon, 28 May 2018 02:30:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527499824; cv=none; d=google.com; s=arc-20160816; b=ozA/+4g3TzS80ShIcasnKvGvAsL2FaeQOmyPHWeje/ZhjuCbnKRCzo05Vu01D5S1O8 KQ+D2wCy5tcLAcHFgGWmU+C8XUYUw9CPGG54A9JAJzRBpuPdJ1TatYES4jT5CsKvI+2r XMMSHz6BVxPYr1UWGoVYm51Bxq2I3AkX1pNgr0HgzK3hQ+1KJgkeG79QyWXRCIkI57uZ 1hUFXGxgmXALDrQx28fXnLaky53zIW01do8KWOwD+DX3+9kyB6rAAda6VbfYREr7OePX DqaFJHvvyllfG8RtfJ2VK2xXcEOajjqLfySmkRO8jRqr3VkKzZqIAc6Vv2yKd1o93uBg 7ERw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=JyN+S9qjkCUrUFMgbXUBDGzRIL5odSelzsNe5w8J8TY=; b=ArlZC+HkWgAxup1G/g8p0hfGaA5BdWO5d+tXFeLLMEoSnH9Sy8++b50Pb0RKS+nPmW XNpVS3JKqeXZfarnuXUN5g8HW9X2dNoP+vp94JCPYsA0d5wefWPK6JFBf4IHoEeVd9wD 5M3KjCuj5oXhzyFLmKQOace3tyYlJiGD/bAigae9bLp1rXNI1QTb21c04R5VSzWqo1Nt 65RimBpC5WkMZt/j0bjuYN54kU0TRxkohKV77sWkjnOJiIP1R1Ebth70tr21Ux10ujeH +lsGFJHmX8TEroWIofBFmWdI8X3hp3SHYsotXwVJuDHmwzcp8Sd7jmBKOnbubtxfYTBS d6Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=TLxWhGMC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g13-v6si6362169pgq.124.2018.05.28.02.30.09; Mon, 28 May 2018 02:30:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=TLxWhGMC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933961AbeE1J2R (ORCPT + 99 others); Mon, 28 May 2018 05:28:17 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:21625 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754333AbeE1JYR (ORCPT ); Mon, 28 May 2018 05:24:17 -0400 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-10.nifty.com with ESMTP id w4S9MInX027506; Mon, 28 May 2018 18:22:32 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com w4S9MInX027506 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1527499352; bh=JyN+S9qjkCUrUFMgbXUBDGzRIL5odSelzsNe5w8J8TY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TLxWhGMCGZuksNAJ2dPT+1KP/EaHtdgrHxvOCbRcWoQOfoHzYQCSzLrLJ5FieyTYX AcTYGcgc1+huttpndXspK8f49iCHIBIx5ko4MnA569sm0SqKEksB7csH9U0DBgKbmY idYHs7A+hkfHkHnE44bWJQH6+GOz7Te4HZji+I5M3O5BY4TQWE2d8XJj3kqij6kmLO +TaqlaPBwPSmP9hUNh+qfOKcOHjYyBdhZvGJXKs/whVGOzsn62G6twW+dYhXLkpNod otiiNn4Y1r7Mjm9XOBPZRBaK4TuUAfgfvYKpgwCS7+NY4p4E9vSZf++reqQPy/SDLb aJPiRO/7w8WlA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Kees Cook , Nicholas Piggin , "Luis R . Rodriguez" , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Linus Torvalds , Masahiro Yamada Subject: [PATCH v5 16/31] kconfig: add 'info', 'warning-if', and 'error-if' built-in functions Date: Mon, 28 May 2018 18:21:53 +0900 Message-Id: <1527499328-13213-17-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527499328-13213-1-git-send-email-yamada.masahiro@socionext.com> References: <1527499328-13213-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Syntax: $(info,) $(warning-if,,) $(error-if,, part is y. Kconfig does not implement the lazy expansion as used in the 'if' 'and, 'or' functions in Make. In other words, Kconfig does not support conditional expansion. The unconditional 'error' function would always terminate the parsing, hence would be useless in Kconfig. Signed-off-by: Masahiro Yamada Reviewed-by: Kees Cook --- Changes in v5: - Replace 'warning', 'error' with 'warning-if', 'error-if' Changes in v4: - Add 'error' function Changes in v3: None Changes in v2: None scripts/kconfig/preprocess.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c index 56aa1f0..5ee58ee 100644 --- a/scripts/kconfig/preprocess.c +++ b/scripts/kconfig/preprocess.c @@ -106,6 +106,21 @@ struct function { char *(*func)(int argc, char *argv[]); }; +static char *do_error_if(int argc, char *argv[]) +{ + if (!strcmp(argv[0], "y")) + pperror("%s", argv[1]); + + return NULL; +} + +static char *do_info(int argc, char *argv[]) +{ + printf("%s\n", argv[0]); + + return xstrdup(""); +} + static char *do_shell(int argc, char *argv[]) { FILE *p; @@ -146,9 +161,21 @@ static char *do_shell(int argc, char *argv[]) return xstrdup(buf); } +static char *do_warning_if(int argc, char *argv[]) +{ + if (!strcmp(argv[0], "y")) + fprintf(stderr, "%s:%d: %s\n", + current_file->name, yylineno, argv[1]); + + return xstrdup(""); +} + static const struct function function_table[] = { /* Name MIN MAX Function */ + { "error-if", 2, 2, do_error_if }, + { "info", 1, 1, do_info }, { "shell", 1, 1, do_shell }, + { "warning-if", 2, 2, do_warning_if }, }; #define FUNCTION_MAX_ARGS 16 -- 2.7.4