From nobody Fri Jun 12 15:56:28 2026 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F25FA335067 for ; Wed, 13 May 2026 20:58:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778705887; cv=none; b=HEDI0H9tKu3EPOUupzWos+de8IQfZpC79u0DCgP5NWrlCirrfgzy00PGX1CelH9MT+lZHW48WAeBL8jC27EhHEKu/Ub0PwMo9Ci9AVPal0aTf4Jd0kUMV5WN77RyDpsOVycNN/Gd07gnj+RBhhCtVOR4JBDjcbWmyhsgw3MIYdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778705887; c=relaxed/simple; bh=iU9CD+mZiIw4V6aOGLEhjbh6OJn1xtKlVRr6MCaWIXk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=XOp3CTqHBJ9aUCDBeIyrRI83IUvT1l/WgG4J9FXJplZW+aGa4dEfi+mu9X2NvU4KPrCkNIZjZ77WnAjmsbnv66hCCDbPRLSWgRhzbfKBh66EFO45Xc0krhFx0Nym5ZzXWtwbGqBT6FTSHVcreK4DtyMG1RXXAp8xhg8osZVQBRQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Fk5YvRNw; arc=none smtp.client-ip=95.215.58.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Fk5YvRNw" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1778705882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Ib21vpEdwN8IVkiP81fxA8cr/2NGzsuBLJ0vZ+PLSjE=; b=Fk5YvRNwhLZwElcF/QW5wwQ6ljypyVroOkMGuYvqYWX1HdT97HC4HUze/K56k2VMSKtECC up1C0SgNU8sEWsE/WOmx2u6wtUBqItPQnX81uExuMnF+E833dHdH0M9QlBY67CO/mVyjqM 2hYmypPsPdfUsWeSi7BLk+GTgRtOMuA= From: Andrew Jones To: linux-kernel@vger.kernel.org Cc: apw@canonical.com, joe@perches.com, dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com, andriy.shevchenko@linux.intel.com Subject: [PATCH] checkpatch: warn on uppercase N/Y/M as Kconfig tristate literals Date: Wed, 13 May 2026 15:57:45 -0500 Message-ID: <20260513205745.636737-1-andrew.jones@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" 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=3D216748 [1] Assisted-by: Claude:claude-sonnet-4-6 Signed-off-by: Andrew Jones Acked-by: Andy Shevchenko --- Fixes such as [2] have already been posted for a few uses. [2] https://lore.kernel.org/lkml/20260513162758.365972-1-andriy.shevchenko@= linux.intel.com/ scripts/checkpatch.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3727156e4cca..aae6c3e7aa51 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3732,6 +3732,21 @@ sub process { } } =20 +# check for uppercase N/Y/M used as Kconfig tristate literals + if ($realfile =3D~ /Kconfig/ && + $line =3D~ /^\+\s*(?:default|def_bool|def_tristate|select|imply|depe= nds\s+on|visible\s+if|range|if)\s+(.+)$/) { + my $expr =3D $1; + $expr =3D~ s/#.*//; # strip inline comments + $expr =3D~ s/\$\(.*\)//g; # strip $(macro) expansions + $expr =3D~ s/"[^"]*"//g; # strip "quoted strings" + $expr =3D~ s/'[^']*'//g; # strip 'quoted strings' + for my $tok (split /[^A-Za-z0-9_]+/, $expr) { + next unless ($tok eq 'Y' || $tok eq 'M' || $tok eq 'N'); + WARN("KCONFIG_TRISTATE_UPPERCASE", + "'$tok' is probably not what you want here; Kconfig tristate lite= rals are always lowercase ('n', 'y', 'm')\n" . $herecurr); + } + } + # check MAINTAINERS entries if ($realfile =3D~ /^MAINTAINERS$/) { # check MAINTAINERS entries for the right form --=20 2.43.0