Re: [PATCH v3] checkpatch: warn on uppercase N/Y/M as Kconfig tristate literals

From: Andrew Jones

Date: Thu May 21 2026 - 18:35:58 EST


On Thu, May 21, 2026 at 03:46:05PM -0500, Andrew Jones wrote:
> Kconfig tristate literals are always lowercase ('n', 'y', 'm') and
> uppercase N/Y/M are not Kconfig reserved words. Since undefined
> symbols evaluate to 'n', writing 'default Y' or 'default M' silently
> produces 'n' instead of 'y'/'m'. 'default N' happens to produce the
> right value but is still invalid syntax.
>
> Add a warning for N/Y/M in Kconfig expressions found by following
> the same preprocessing logic used by the Kconfig parser itself.
>
> This new warning was inspired by work done for [1].
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=216748 [1]
> Assisted-by: Claude:claude-sonnet-4-6
> Signed-off-by: Andrew Jones <andrew.jones@xxxxxxxxx>
> Acked-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
>
> v3:
> - More changes from another sashiko review which required the
> Perl to get even uglier.
> v2:
> - Added Andy's tag
> - Changes thanks to sashiko's review
> - strip quoted strings before inline comments to avoid '#' inside a string
> - use [^)]* instead of .* in macro strip regex to avoid greedy match
> eating tokens between adjacent $(macro) expansions
>

I need to send a v4 to also handle quoted N/M/Y as pointed out in the
review of the corresponding static checker patch[1]. I'll wait a bit
before sending in case other comments come in in the meantime.

[1] https://lore.kernel.org/all/numrmmjpnheiawifcjhc5zustrlk6bfv5wtr6ibdzbf7mq5o53@x6wf4zv7jhsg/

Thanks,
drew