Re: [PATCH 10/10] [for next only] kconfig: generate include/generated/rustc_cfg

From: Masahiro Yamada
Date: Sat Oct 02 2021 - 05:00:22 EST


On Fri, Oct 1, 2021 at 8:29 PM <n.schier@xxxxxx> wrote:
>
> On Fri, Oct 01, 2021 at 02:32:53PM +0900, Masahiro Yamada wrote:
> > This patch is not intended for the mainline.
> >
> > I created this patch for Stephen Rothwell to resolve the merge
> > conflicts more easily.
> >
> > The Rust tree is touching scripts/kconfig/confdata.c to generate
> > include/generated/rustc_cfg, which would cause complicated conflicts
> > with changes from the kbuild tree.
> >
> > I re-implemented it to produce the equaivalent rustc_cfg.
> >
> > I also fixed the memory leak; the original code from the Rust tree
> > did not free the malloc'ed pointer.
> >
> > Stephen:
> > When you resolve the conflicts in confdata.c, please take this one.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> > ---
> >
> > scripts/kconfig/confdata.c | 42 ++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 42 insertions(+)
> >
> > diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> > index 9ece2f3b61a6..4767f3810cf4 100644
> > --- a/scripts/kconfig/confdata.c
> > +++ b/scripts/kconfig/confdata.c
> > @@ -603,6 +603,9 @@ static const struct comment_style comment_style_c = {
> >
> > static void conf_write_heading(FILE *fp, const struct comment_style *cs)
> > {
> > + if (!cs) /* no heading for rustc_cfg? */
> > + return;
> > +
> > fprintf(fp, "%s\n", cs->comment_block_begin);
> >
> > fprintf(fp, "%s Automatically generated file; DO NOT EDIT.\n",
> > @@ -750,6 +753,39 @@ static void print_symbol_for_c(FILE *fp, struct symbol *sym)
> > free(escaped);
> > }
> >
> > +/* rustc configuration */
> > +static void print_symbol_for_rustc_cfg(FILE *fp, struct symbol *sym)
> > +{
> > + const char *val;
> > + char *escaped;
> > +
> > + if (sym->type == S_UNKNOWN)
> > + return;
> > +
> > + val = sym_get_string_value(sym);
> > + escaped = escape_string_value(val);
> > +
> > + if (sym->type == S_BOOLEAN || sym->type == S_TRISTATE) {
> > + if (*val == 'n')
> > + return;
>
> I'd expect a "free(escaped);" here.


Thank you for catching it.

I just sent v2.





--
Best Regards
Masahiro Yamada