From patchwork Mon May 28 09:21:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 137057 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2594882lji; Mon, 28 May 2018 02:28:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpAp9qjrHs/Ro+Q4epxWg7W9/6VmWQjxRtwEivd9l4uOONvV03iA5kv+PvU6wbfRq/iYKuF X-Received: by 2002:a62:4fd8:: with SMTP id f85-v6mr12832012pfj.77.1527499701952; Mon, 28 May 2018 02:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527499701; cv=none; d=google.com; s=arc-20160816; b=uzyTfKAq91vpmt685Eu6yLGQm6ROlMGQ2i672XxRRUOgg7/VxzWgrEVsFPJDu0jEKB VV5v6ENVbqGP8yoZUuAfeL3mAglGWHocvHDJlYQxLqqY+4OeIS9KMMWQA62heyYQK2Uz DdEY0XazqVzbNxQwPk8jrKjtuw1rNlr2aKUBL/zx00M5qW0A2MkJH7dif3RxuFKX4OyD rq/F/WGdVgaiIEtU/nBnnqzAsBae0a0IaslzuojVnxR5RknOxbBKBhMiBZluoAMUmq+J Wo7VU0ixP7l3DV71OAvOorGbWkRL3yZd3zFfxk6UsdIOrwngctooT3UDuBnMcD7YiQPT AE2A== 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 88-v6si29308679pla.315.2018.05.28.02.28.21; Mon, 28 May 2018 02:28:21 -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 S933979AbeE1J2R (ORCPT + 30 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(+) -- 2.7.4 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