Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2144273imm; Mon, 28 May 2018 02:31:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrTc0oq1ivuNuBgs5c36nYLqPpVU2G53VNnaJME56PpuaMITsCgiO0wNybSeNFKjrU7Ee9D X-Received: by 2002:a62:ed12:: with SMTP id u18-v6mr12814479pfh.127.1527499866827; Mon, 28 May 2018 02:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527499866; cv=none; d=google.com; s=arc-20160816; b=h7+hVSb+AkYe8V/to5PJDUpQBfOfRnRxB8fj97Iyn/8Kr/vMxsQ7tMEmhNWxlZ/FkG F7AvBb8pnM58eofppIPASNUUEMlE2HKWBtr3GJvRMrtDIchqhQhnWeyExlV5KQTUW/91 C0/Dv8hL0mDa8w9J06tPK9vVRbId+b5YyMSta6RbgJ0UX2x38BT2eZXf+Nl5PY5dj1oc uCcEh7Jp41e5Nzz6tY883ez3d+fEn4SDsSGA9AKB7o76PPsFhk6NAnrDXaNdYLYcJUTC vCZ4xIT+EeNKHGvP4z/1BJIFb4tLdbx4F7woFdbGB/WsT4YjY+hqwpNBJ5t7TdgQFeae cUaQ== 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=yy4siuNzt3oM11IST7ouMxBogD9ZdE8h3kOPZXVnJdI=; b=CCHtzLkVUeNSOj97xMkKcdu7bpCIePPGi00kE+Tw6Xm+p/YmNK18pQU/ZHgU0BTCQ3 +8vtgwqrCmB4Bcr7eqzINPpxZS5EeHN/cI/U6m3rFD58GGIGD+leS2SngJo0WZjaCzEP zulOZZ0s4/bUypF2cZyI3tmzdhiqoUPvETIzV2HvyYcBoXrEGd5LBL2xFRCEAD+yOCDk HvYq3a8qqGm6+VDx129diTWzIx/ow+Drc9zmI9yI6emL07iS/v1zg2MEsNHQAt6OpoeH Lghv69cNw36KX8zaXCBj/tYEGg68mVTftdFBhsUmE+Y2EAyz/DmkN9T/BS21Dlh8goi5 aSXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Eq2dVn0h; 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 k7-v6si23073233pgo.98.2018.05.28.02.30.52; Mon, 28 May 2018 02:31:06 -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=Eq2dVn0h; 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 S1754470AbeE1J3s (ORCPT + 99 others); Mon, 28 May 2018 05:29:48 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:21615 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754319AbeE1JYQ (ORCPT ); Mon, 28 May 2018 05:24:16 -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 w4S9MInY027506; Mon, 28 May 2018 18:22:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com w4S9MInY027506 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1527499353; bh=yy4siuNzt3oM11IST7ouMxBogD9ZdE8h3kOPZXVnJdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eq2dVn0hd24xKOSryq7GVGM70lHNM7bXufgmO7P18Gq3MZ+lsABtanb47Gp98qdBa 08AUYyyVl1BJJus+PqtPx1HdH+XtT2JPjbSsPufG3zO23mdYR7Rt/29+F9CVyFcX1V 1DmGVa+AOyZ4IMmyqpnf6IJslzM06MqTJO6/AW8AJpp8NhKX3AWgwChuiSGIYdgSXH qEWXEdZY4i4QHTE0YQgRWIlgQi9BEb3++oTQbxv9T4MuVLLx6CEY0NKnrhK2Mly+UD q7l9rAo1+VeH9bhBDLGkh9eqNc1mQe1UcS8g1+Nna4iAoxDlbNmc6mvkZ/LlcFwQoE +KWyrWTKRDAYA== 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 17/31] kconfig: add 'filename' and 'lineno' built-in variables Date: Mon, 28 May 2018 18:21:54 +0900 Message-Id: <1527499328-13213-18-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 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 Reviewed-by: Kees Cook --- Changes in v5: None Changes in v4: - Newly added Changes in v3: None Changes in v2: None scripts/kconfig/preprocess.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c index 5ee58ee..0574039 100644 --- a/scripts/kconfig/preprocess.c +++ b/scripts/kconfig/preprocess.c @@ -114,6 +114,11 @@ static char *do_error_if(int argc, char *argv[]) return NULL; } +static char *do_filename(int argc, char *argv[]) +{ + return xstrdup(current_file->name); +} + static char *do_info(int argc, char *argv[]) { printf("%s\n", argv[0]); @@ -121,6 +126,15 @@ static char *do_info(int argc, char *argv[]) return xstrdup(""); } +static char *do_lineno(int argc, char *argv[]) +{ + char buf[16]; + + sprintf(buf, "%d", yylineno); + + return xstrdup(buf); +} + static char *do_shell(int argc, char *argv[]) { FILE *p; @@ -173,7 +187,9 @@ static char *do_warning_if(int argc, char *argv[]) static const struct function function_table[] = { /* Name MIN MAX Function */ { "error-if", 2, 2, do_error_if }, + { "filename", 0, 0, do_filename }, { "info", 1, 1, do_info }, + { "lineno", 0, 0, do_lineno }, { "shell", 1, 1, do_shell }, { "warning-if", 2, 2, do_warning_if }, }; -- 2.7.4