Re: [PATCH 2/2] perf parse-events: enable more flex/yacc warnings

From: Arnaldo Carvalho de Melo
Date: Wed Jun 10 2020 - 10:18:22 EST


Em Wed, Jun 10, 2020 at 11:09:56AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Wed, Jun 10, 2020 at 11:05:26AM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Tue, Jun 09, 2020 at 04:43:44PM -0700, Ian Rogers escreveu:
> > > All C compiler warnings are disabled are disabled by -w. This change
> > > removes the -w from flex and bison targets. To avoid implicit
> > > declarations header files are declared as targets and included.
>
> > > Tested with GCC 9.3.0 and clang 9.0.1.
>
> > > Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
>
> > > +++ b/tools/perf/util/Build
> <SNIP>
> > > -$(OUTPUT)util/parse-events-flex.c: util/parse-events.l $(OUTPUT)util/parse-events-bison.c
> > > +$(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-flex.h: util/parse-events.l $(OUTPUT)util/parse-events-bison.c
> > > $(call rule_mkdir)
> > > - $(Q)$(call echo-cmd,flex)$(FLEX) -o $@ --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) util/parse-events.l
> > > + $(Q)$(call echo-cmd,flex)$(FLEX) -o $(OUTPUT)util/parse-events-flex.c \
> > > + --header-file=$(OUTPUT)util/parse-events-flex.h \
> > > + $(PARSER_DEBUG_FLEX) $<
>
> <SNIP>
>
> > And you took advantage of util/parse-events.l being
> > the first dependency to replace it with $<
>
> <SNIP>
>
> > Damn, Makefiles are obtuse, we better do this more piecemeal, for
> > instance, using $< where applicable first, etc.
>
> I mean, first this, ok? Then you do the other bits, and please try to
> keep the positioning as far as possible, so that visually we see what is
> being replaced by what.

Argh, replace all %< below with, of course, $<

- Arnaldo
>
> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> index 8d18380ecd10..cc50fdfd0c2f 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -193,27 +193,27 @@ CFLAGS_genelf_debug.o += -Wno-packed
>
> $(OUTPUT)util/parse-events-flex.c: util/parse-events.l $(OUTPUT)util/parse-events-bison.c
> $(call rule_mkdir)
> - $(Q)$(call echo-cmd,flex)$(FLEX) -o $@ --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) util/parse-events.l
> + $(Q)$(call echo-cmd,flex)$(FLEX) -o $@ --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) %<
>
> $(OUTPUT)util/parse-events-bison.c: util/parse-events.y
> $(call rule_mkdir)
> - $(Q)$(call echo-cmd,bison)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $@ -p parse_events_
> + $(Q)$(call echo-cmd,bison)$(BISON) -v %< -d $(PARSER_DEBUG_BISON) -o $@ -p parse_events_
>
> $(OUTPUT)util/expr-flex.c: util/expr.l $(OUTPUT)util/expr-bison.c
> $(call rule_mkdir)
> - $(Q)$(call echo-cmd,flex)$(FLEX) -o $@ --header-file=$(OUTPUT)util/expr-flex.h $(PARSER_DEBUG_FLEX) util/expr.l
> + $(Q)$(call echo-cmd,flex)$(FLEX) -o $@ --header-file=$(OUTPUT)util/expr-flex.h $(PARSER_DEBUG_FLEX) %<
>
> $(OUTPUT)util/expr-bison.c: util/expr.y
> $(call rule_mkdir)
> - $(Q)$(call echo-cmd,bison)$(BISON) -v util/expr.y -d $(PARSER_DEBUG_BISON) -o $@ -p expr_
> + $(Q)$(call echo-cmd,bison)$(BISON) -v %< -d $(PARSER_DEBUG_BISON) -o $@ -p expr_
>
> $(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c
> $(call rule_mkdir)
> - $(Q)$(call echo-cmd,flex)$(FLEX) -o $@ --header-file=$(OUTPUT)util/pmu-flex.h util/pmu.l
> + $(Q)$(call echo-cmd,flex)$(FLEX) -o $@ --header-file=$(OUTPUT)util/pmu-flex.h %<
>
> $(OUTPUT)util/pmu-bison.c: util/pmu.y
> $(call rule_mkdir)
> - $(Q)$(call echo-cmd,bison)$(BISON) -v util/pmu.y -d -o $@ -p perf_pmu_
> + $(Q)$(call echo-cmd,bison)$(BISON) -v %< -d -o $@ -p perf_pmu_
>
> CFLAGS_parse-events-flex.o += -w
> CFLAGS_pmu-flex.o += -w

--

- Arnaldo