From patchwork Thu May 17 06:16:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 136104 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1881642lji; Wed, 16 May 2018 23:24:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpmpgITlsHeZKco7xGzXI2GpW1FyrbC4o6xecqEzANjX9i8Je6rIK/sFQyWqiQWjzmZTidK X-Received: by 2002:a62:449c:: with SMTP id m28-v6mr3966727pfi.145.1526538258821; Wed, 16 May 2018 23:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526538258; cv=none; d=google.com; s=arc-20160816; b=eCZBwADSuMevrUHbOpxsTNCAVEO5XZa7VW2HB/Q0HUjjyw1Xv1fJT6asRQACFMhq+m RCvu7O+qPCYnTwo+0wmFhlbPg5e+8bhRU0nmfqgp4HE9z4Cmy1Cxdn80zqkroR4Bjmnq K9qBL2CZT5/ynj8PJMOWK8P+g/VyPs4SVSh/2i5GD1QsBJgH8Eoa98zGhDh88PVHMGAg E9KwS/b0D/E9tUXVfegIchwyWlTrormIcARbLhWhL8XYF7zi/tsjkJbHx4WI+y3JqvhH mkcZlpAmTJKU9Knf6TrL8zz0D8gKq+BhtmsFjYQ/FQmm4uKt1oS11Ej3u/lrRAMyey7L 3JWQ== 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=5S53LhpTS+CxEf8CrW5uwWBe7fNb1Rso9Yw0oFdAG38=; b=R9dylc9M65u6HR77uiA4ce/0SOOMdrWQTvwDkIUPajBu83Qszxm+C6oNWAFXNejl6W B1+YvxZ6Rg2M+bXzQytQKZ/mQ3ZdFktPWFwE/QvSZoGA8K7gQqfcaHB0GPKBO1hImsbX O4C8uUvq4cr65bnfdxxXGAkXwVcZqbvtUP96T62ap3JodZnHoJveIKafuqLDW04/wmdp lo/70zDJLx05Yx5ILMneolYb4yC6qvaMlbdFvJdfVL5kH0NJgP7hbgRsJr3M1jEJ4FfJ cMFpZhZNBftTSORSbypILs510TSzHx2ZKoVIK5PvM3+2Rh0VqwvFyLD542kXtLL9cluR meNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=EFK1kqNp; 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 r14-v6si5070543plj.341.2018.05.16.23.24.18; Wed, 16 May 2018 23:24:18 -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=EFK1kqNp; 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 S1752594AbeEQGYP (ORCPT + 29 others); Thu, 17 May 2018 02:24:15 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:24993 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751396AbeEQGTQ (ORCPT ); Thu, 17 May 2018 02:19:16 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id w4H6HbUF002841; Thu, 17 May 2018 15:17:55 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com w4H6HbUF002841 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1526537875; bh=5S53LhpTS+CxEf8CrW5uwWBe7fNb1Rso9Yw0oFdAG38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EFK1kqNp6OM/1N28g/jZU04YBB8b8z5gl7Vd53ded7lwvaYprL7wqKY5ut45v/AvV L6dIGv42aOIKSl2ioK93jNzpul8Zb918q/kyUwvOYOfTe/YlCuatkNQg9W5qZfSpdG 88/q8T0aSikwRO+Z1g0yXtNCZVgnBxkAWlwMAUrFXOZ5A7RazAESVBmPK35s6mnaBF u4+GNvpxoY+ackQK8txOrXKX3K1QygVivXuQwfbyG8pGVEAS+pYnldoW53u/WjfoJU h82PJLORwTqNWUgDi8gIijNw67gtjiAh/XbVzXFuUW61C26ZVniB2Ybc0Dqq9nwgQt dOmnidIj5VCgw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Linus Torvalds , Sam Ravnborg , Ulf Magnusson , "Luis R . Rodriguez" , linux-kernel@vger.kernel.org, Nicholas Piggin , Kees Cook , Emese Revfy , x86@kernel.org, Masahiro Yamada Subject: [PATCH v4 17/31] kconfig: add 'filename' and 'lineno' built-in variables Date: Thu, 17 May 2018 15:16:56 +0900 Message-Id: <1526537830-22606-18-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526537830-22606-1-git-send-email-yamada.masahiro@socionext.com> References: <1526537830-22606-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 The special variables, $(filename) and $(lineno), are expanded to a file name and its line number being parsed, respectively. Suggested-by: Randy Dunlap Signed-off-by: Masahiro Yamada --- Changes in v4: - Newly added Changes in v3: None Changes in v2: None scripts/kconfig/preprocess.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.7.4 Reviewed-by: Kees Cook diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c index 88844a7..c39e30e 100644 --- a/scripts/kconfig/preprocess.c +++ b/scripts/kconfig/preprocess.c @@ -111,6 +111,11 @@ static char *do_error(int argc, char *argv[], int old_argc, char *old_argv[]) return NULL; } +static char *do_filename(int argc, char *argv[], int old_argc, char *old_argv[]) +{ + return xstrdup(current_file->name); +} + static char *do_if(int argc, char *argv[], int old_argc, char *old_argv[]) { char *cond, *p, *res; @@ -144,6 +149,15 @@ static char *do_info(int argc, char *argv[], int old_argc, char *old_argv[]) return xstrdup(""); } +static char *do_lineno(int argc, char *argv[], int old_argc, char *old_argv[]) +{ + char buf[16]; + + sprintf(buf, "%d", yylineno); + + return xstrdup(buf); +} + static char *do_shell(int argc, char *argv[], int old_argc, char *old_argv[]) { FILE *p; @@ -194,8 +208,10 @@ static char *do_warning(int argc, char *argv[], int old_argc, char *old_argv[]) static const struct function function_table[] = { /* Name MIN MAX EXP? Function */ { "error", 1, 1, true, do_error }, + { "filename", 0, 0, false, do_filename }, { "if", 2, 3, false, do_if }, { "info", 1, 1, true, do_info }, + { "lineno", 0, 0, false, do_lineno }, { "shell", 1, 1, true, do_shell }, { "warning", 1, 1, true, do_warning }, };