On Sat, 07 Nov 2026, [email protected] wrote:
> >
> > +checkconfig := $(PYTHON3) -B $(srctree)/tools/kconfig-checker/check.py
> > +list_checkconfig_rules =                                           \
> > +   echo -n >&2 "Available RULES: ";                                \
> > +   $(checkconfig) list-rules >&2;                                  \
> > +   echo >&2
> > +
> > +PHONY += checkconfig
> > +checkconfig:
> > +   $(Q)if [ -z "$(RULES)" ]; then                                  \
> > +           echo >&2 "Usage: make RULES=<profile> checkconfig";     \
> > +           $(list_checkconfig_rules);                              \
> > +           exit 2;                                                 \
> > +   fi
> > +   $(Q)if ! $(checkconfig) list-rules | grep -qw "$(RULES)"; then  \
> > +           echo >&2 "Unknown RULES profile = $(RULES)";            \
> > +           $(list_checkconfig_rules);                              \
> > +           exit 2;                                                 \
> > +   fi
> > +   $(Q)$(checkconfig) check -r "$(RULES)" -c "$(KCONFIG_CONFIG)"
>
...
>
> When either module is missing, check.py writes the error to stderr,
> produces no stdout, and exits with os.EX_UNAVAILABLE.  Because the POSIX
> shell pipeline ignores the exit status of $(checkconfig) list-rules,
> grep -qw exits 1 on the empty stdout and the negated condition enters the
> branch.  That reports a valid setting such as RULES=preempt_rt as an
> unknown profile and runs $(list_checkconfig_rules), which invokes check.py
> a second time and prints a duplicate module error on the same line after
> "Available RULES: ".

It works, so there is no reason to complicate things.

For example, invoking the make target from a container with old Python:

   $ make checkconfig
   Usage: make RULES=<profile> [OVERLAY=<overlay>] checkconfig
   Available RULES: Error: Python 3.9 or later is required

   make[2]: *** [scripts/kconfig/Makefile:138: checkconfig] Error 2
   make[1]: *** [/home/darwi/linux/Makefile:772: checkconfig] Error 2
   make: *** [Makefile:248: __sub-make] Error 2

and:

   $ make RULES=nonExistent checkconfig
   Error: Python 3.9 or later is required
   Unknown RULES profile = nonExistent
   Available RULES: Error: Python 3.9 or later is required

   make[2]: *** [scripts/kconfig/Makefile:139: checkconfig] Error 2
   make[1]: *** [/home/darwi/linux/Makefile:772: checkconfig] Error 2
   make: *** [Makefile:248: __sub-make] Error 2

The duplicate error, which is a single line, is no big deal. IMO, it's
better than complicating the Makefile for that single edge case.

>
> In addition, grep -qw treats $(RULES) as a regular expression with word
> boundaries against the comma-separated output of list-rules rather than
> matching an exact profile name, and spawns Python twice on every valid
> invocation even though check.py check -r already validates the profile
> name.
>

That's good catch; will fix.

Thanks,
Ahmed

Reply via email to