[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXu5jKpNN3SSh3CRb9+U=1nFvOqrAtcdk0Km_QO1Cwa5dZfNQ@mail.gmail.com>
Date: Wed, 16 May 2018 23:39:28 -0700
From: Kees Cook <keescook@...omium.org>
To: Masahiro Yamada <yamada.masahiro@...ionext.com>
Cc: linux-kbuild <linux-kbuild@...r.kernel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Sam Ravnborg <sam@...nborg.org>,
Ulf Magnusson <ulfalizer@...il.com>,
"Luis R . Rodriguez" <mcgrof@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
Nicholas Piggin <npiggin@...il.com>,
Emese Revfy <re.emese@...il.com>, X86 ML <x86@...nel.org>
Subject: Re: [PATCH v4 17/31] kconfig: add 'filename' and 'lineno' built-in variables
On Wed, May 16, 2018 at 11:16 PM, Masahiro Yamada
<yamada.masahiro@...ionext.com> wrote:
> The special variables, $(filename) and $(lineno), are expanded to a
> file name and its line number being parsed, respectively.
>
> Suggested-by: Randy Dunlap <rdunlap@...radead.org>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
Reviewed-by: Kees Cook <keescook@...omium.org>
-Kees
> ---
>
> 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 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 },
> };
> --
> 2.7.4
>
--
Kees Cook
Pixel Security
Powered by blists - more mailing lists