Re: [PATCH] kconfig: add warn-unknown-symbols sanity check
From: Sergey Senozhatsky
Date: Tue Aug 29 2023 - 20:46:43 EST
On (23/08/29 22:13), Masahiro Yamada wrote:
> > +KCONFIG_WARN_UNKNOWN_SYMBOLS
> > +----------------------------
> > +This environment variable makes Kconfig warn about all unrecognized
> > +symbols in the .config file.
>
>
> This warns not only for the .config but also defconfig files.
>
> Could you reword it?
>
> For example,
>
> "symbols in the config input".
Done.
>
>
> > +
> > +KCONFIG_WERROR
> > +--------------
> > +If set, Kconfig will treat `KCONFIG_WARN_UNKNOWN_SYMBOLS` warnings as
> > +errors.
>
> My hope is to turn other warnings in the config file into errors.
Done.
> > +++ b/scripts/kconfig/confdata.c
> > @@ -349,7 +349,12 @@ int conf_read_simple(const char *name, int def)
> > char *p, *p2;
> > struct symbol *sym;
> > int i, def_flags;
> > + bool found_unknown = false;
> > + const char *warn_unknown;
> > + const char *werror;
> >
> > + warn_unknown = getenv("KCONFIG_WARN_UNKNOWN_SYMBOLS");
> > + werror = getenv("KCONFIG_WERROR");
> > if (name) {
> > in = zconf_fopen(name);
> > } else {
> > @@ -437,6 +442,13 @@ int conf_read_simple(const char *name, int def)
> > if (def == S_DEF_USER) {
> > sym = sym_find(line + 2 + strlen(CONFIG_));
> > if (!sym) {
> > + if (warn_unknown) {
> > + conf_warning("unknown symbol: %s",
> > + line + 2 + strlen(CONFIG_));
> > + found_unknown = true;
> > + continue;
>
> Please drop this 'continue' because it would skip
> conf_set_changed(true).
My bad. Those 'continue' are left-overs from previous version.
> > + }
> > +
> > conf_set_changed(true);
> > continue;
> > }
> > @@ -471,6 +483,13 @@ int conf_read_simple(const char *name, int def)
> >
> > sym = sym_find(line + strlen(CONFIG_));
> > if (!sym) {
> > + if (warn_unknown && def != S_DEF_AUTO) {
> > + conf_warning("unknown symbol: %s",
> > + line + strlen(CONFIG_));
> > + found_unknown = true;
> > + continue;
>
> Same here.
Same here. My bad.
> > @@ -519,6 +538,10 @@ int conf_read_simple(const char *name, int def)
> > }
> > free(line);
> > fclose(in);
> > +
> > + if (found_unknown && werror)
> > + exit(1);
>
>
> I like to reuse 'conf_warnings' as you did in the previous version.
Done.