[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXu5jLPzCYaT199CZTFdy0Fnqrr70q2YrZs5J3NdTBKPHO8AA@mail.gmail.com>
Date: Wed, 16 May 2018 23:38:55 -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 15/31] kconfig: add 'info', 'warning', and 'error'
built-in functions
On Wed, May 16, 2018 at 11:16 PM, Masahiro Yamada
<yamada.masahiro@...ionext.com> wrote:
> Add 'info', 'warning', and 'error' functions as in Make.
>
> They print messages during parsing Kconfig files. 'error' will be
> useful to terminate the parsing immediately in fatal cases.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
Reviewed-by: Kees Cook <keescook@...omium.org>
-Kees
> ---
>
> Changes in v4:
> - Add 'error' function
>
> Changes in v3: None
> Changes in v2: None
>
> scripts/kconfig/preprocess.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c
> index 47b32dc..591bcf7 100644
> --- a/scripts/kconfig/preprocess.c
> +++ b/scripts/kconfig/preprocess.c
> @@ -104,6 +104,20 @@ struct function {
> char *(*func)(int argc, char *argv[], int old_argc, char *old_argv[]);
> };
>
> +static char *do_error(int argc, char *argv[], int old_argc, char *old_argv[])
> +{
> + pperror("%s", argv[0]);
> +
> + return NULL;
> +}
> +
> +static char *do_info(int argc, char *argv[], int old_argc, char *old_argv[])
> +{
> + printf("%s\n", argv[0]);
> +
> + return xstrdup("");
> +}
> +
> static char *do_shell(int argc, char *argv[], int old_argc, char *old_argv[])
> {
> FILE *p;
> @@ -144,9 +158,19 @@ static char *do_shell(int argc, char *argv[], int old_argc, char *old_argv[])
> return xstrdup(buf);
> }
>
> +static char *do_warning(int argc, char *argv[], int old_argc, char *old_argv[])
> +{
> + fprintf(stderr, "%s:%d: %s\n", current_file->name, yylineno, argv[0]);
> +
> + return xstrdup("");
> +}
> +
> static const struct function function_table[] = {
> /* Name MIN MAX EXP? Function */
> + { "error", 1, 1, true, do_error },
> + { "info", 1, 1, true, do_info },
> { "shell", 1, 1, true, do_shell },
> + { "warning", 1, 1, true, do_warning },
> };
>
> #define FUNCTION_MAX_ARGS 16
> --
> 2.7.4
>
--
Kees Cook
Pixel Security
Powered by blists - more mailing lists