From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2ED56347FCD for ; Thu, 30 Jul 2026 14:01:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785420104; cv=none; b=iq15Zk4Up1eooSro8zABbEfSxaqpjNGzhn0G6nugL79hHWwU4zNcGQrMA4KQAFDv/9uXUEIzokclcDoSFjU4N5e8FYQWvu6PA+YqBfBz33i2h5nVONAIC38ZihPOn+jgcAiCQWSCUIL0eASiLnGn+xswhQz3MiytHsTfkHmpo7s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785420104; c=relaxed/simple; bh=ri9MLwB0DvTFmAF7fuhBZmWK0NcRSRkk+obgkZ9ss54=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fMaWfWMUFoZUafQBT6JRAIko8wczan6Qk+z+Rayw4qpAIlrYdMXM5ZQD/M/hoiC+AynP15MBMCnBlvFkKzZRIjUTRYOjyOkMIiP5+ECzQU1OZPytwUVnadSw85MoTY/IqJ+yxsCRm5586Jv0jQH8rPFOwIPnJ20QyQSjjCjKIlY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FQIEka0u; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FQIEka0u" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-49556f97a9dso15223795e9.1 for ; Thu, 30 Jul 2026 07:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785420101; x=1786024901; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MM+a2ReeoFL4RNqETaQgicGycDtbnrFeItVUphw4i3o=; b=FQIEka0ut0coGrT4W3F7Xd0zzFJuiHQUQm7Rp7ESw9XFbheEHLUWmKxz2I77k/BvTa hpwP1Je4c6yVSt5YFY0pX4zv8GCQQooTHk6Sg8gQfOSkC/Itikr4bQwzd8v/748uwb74 2qrrZ0dcUp2xUOEe/1j3x051Ggljgylh20aseRHjobaSQQ1VlfWAq02JYBmQ6hWnNXeK 2Tp2OULGYk7/YOi8lwlaPFzY5NYPRGAg+BG/EPM6aTEZRPyFsgJDzYlnvafBkfCkwlIG UdcZXqxiygn8Ehd3NKEnf1vrCVLGmq7xOgXB0oCNML8NABp9iMnXC82gYT08TDTGGOaj ZIJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785420101; x=1786024901; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=MM+a2ReeoFL4RNqETaQgicGycDtbnrFeItVUphw4i3o=; b=J+3aS7xHg1QUWO+NAYpMMmkmtIATtxbowzYG3he39hS95Y1x6ZVc7uWX0FhQRy05To fZb0TAkrDXB2T5xrKfHYTXVxNi99acWkRy5Wp80wIQFANo0dfg8WFh6Nxq/YSoYiMNCC t6ZVanAnse9AaQJ0kjXLzxmb2tOikcExdg3ICj2jU/QAiN2azW8SrZnVgVoUAyXPKrm+ 5irZyOsG+gU5tIqF2nRiLwzLOmFtuzIFi1KFTMpbY/ALo39oDxKL9tv6NCtBskww5SWg PDmqD9U7KQwsc8P7kb/IyOEnheWi+NyM39lx5lL2qFC7HBpGfWhm2hLB8nDh99IjBLd4 HK5Q== X-Forwarded-Encrypted: i=1; AHgh+RrFhjkHBDyHkJU1GeS9IqtmDNRVtrDKS+hQXr4OiTPJyls2/OXJT4IMJLNzFhA3UFCWSeWtbn9Q9vg=@vger.kernel.org X-Gm-Message-State: AOJu0YzVOjA1GoWi2Mu3lIE/O54oRSxY5buuCI6welVFaZyxQouZ1TSx zN531748zVUn/UWzkRYu4ZNve1/DMuCkFh0dhXIXn98UQeMFXAoCUyGs X-Gm-Gg: AR+sD13AkLPqWPSkGvRxuPY2ahsRNpWEVqxHwwg4Ys7YR6KC1oaQmTRkyULcmdDMlQr nkPwpXLAK2ySiTIs9CL7wIoafOuaL6qUiMywWktGnYBH3U0PhTpAkf71OswBdrtFXT5l1WfhE0T HoVaxtwH4iz0AZs2bCFfAo1wXCRSQxUrfW7tdYdJf/j/pzQv7UPgQbav2hleSHwwEPODdPMYvyC bXAf4egqCxZOQpV4VrbKp9as6rcQMdwxOF0YqO3UKMrDJt4rR7DNjokymg3cpkxUX+BBEk9JV1g iIZrVuZZEDA3fMdDAY7MpiVxAvYFIqsdSPeHo/wlyNgf0iVE3NoFf/R1El3T3MkYFpSzkCWGAb6 NHfUnSDpg6GyBLEjEwyjZxLy3Znfrd7YuaKfKiod8shRMomXImmLJ6RWMq6r+S/gncQiClKEbnl sqNL+7nCJwTRbKxFKqoedfwZkWy0UPTqL7nwNc/OKlTBSlVLXSb9HftE47+A6Va0qON65rlDf3b RMnxZNXd/quosyjUzeYT08w5PvkspaqtY3X89JOFMcOgCF6Pv+0 X-Received: by 2002:a05:600c:e557:10b0:493:bcba:46a4 with SMTP id 5b1f17b1804b1-49800ea21a6mr25943175e9.20.1785420100866; Thu, 30 Jul 2026 07:01:40 -0700 (PDT) Received: from nixos-office (195-23-151-163.net.novis.pt. [195.23.151.163]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49800f1a91fsm58238575e9.6.2026.07.30.07.01.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2026 07:01:39 -0700 (PDT) Sender: Julian Braha From: Julian Braha To: nathan@kernel.org, nsc@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org Cc: jani.nikula@linux.intel.com, arnd@arndb.de, stefan.hengelein@fau.de, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, nico@fluxnic.net, officialnaumansabir@gmail.com, rdunlap@infradead.org, vegard.nossum@oracle.com, kees@kernel.org, tj@kernel.org, Julian Braha Subject: [PATCH] Documentation: warn against using int, hex, string options as expressions in Kconfig Date: Thu, 30 Jul 2026 15:01:08 +0100 Message-ID: <20260730140108.683967-1-julianbraha@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit I've been working on type checking Kconfig, and found some instances of dead code due to conditions that always evaluate to false. For example: config FOO int config BAR bool default 'y' if FOO This 'if FOO' will always be false, regardless of FOO's value (even when FOO=1). The same goes for strings and hex. See also this related patch: https://lore.kernel.org/all/20260729210546.394392-1-julianbraha@gmail.com/ Let's warn users against this usage. Signed-off-by: Julian Braha --- Documentation/kbuild/kconfig-language.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst index ab2822d7ca1c..aee84b294a56 100644 --- a/Documentation/kbuild/kconfig-language.rst +++ b/Documentation/kbuild/kconfig-language.rst @@ -320,6 +320,17 @@ An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 respectively for calculations). A menu entry becomes visible when its expression evaluates to 'm' or 'y'. +Note that options of int, hex, or string type should not be used directly +as expressions; these will always evaluate to 'n'. Instead, to check if +one of these options is in use, consider using one of these heuristics:: + + != 0 + != 0x0 + != "" + +because int, hex, and string options will take these values of '0', '0x0', +and the empty string, respectively, when the dependencies are unmet. + There are two types of symbols: constant and non-constant symbols. Non-constant symbols are the most common ones and are defined with the 'config' statement. Non-constant symbols consist entirely of alphanumeric -- 2.55.0