From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 245FC31E833 for ; Thu, 30 Jul 2026 14:01:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785420104; cv=none; b=c34R4syIqKwaHUFKpRHDKqKQAOwffSjX0EcBUSbOss4IIWXijMBNh2evQ59NOWsLwaKu1LcLWXRqL4YQ+ltkO1H4ZcXo1EpFvHiLHeU0tvOuF5Cr7AM7kP5BkWqzgqPT9rhsYa9/ryfvORoX5oqHu8cI8zToZj5FTWnlzCDfIyc= 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.41 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-f41.google.com with SMTP id 5b1f17b1804b1-49556f97a9dso15223815e9.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=Wq/3sgyxAic34ziNdi760JJJMpNKuW2Yj0fYeXax2Tad1AAf+NnPYE/wz3RxTVkyyR kWSTV9fJt0wJIzx7Y9Uc+B0A/d6FIoMiW59Yti67fx5izzC8lGF9XuQKNOdkUzObQHtG yKt1so2VG3FtwCUe7GQ2gAYx7NUIeFDdEbGoBnCGea5/zXqPBc43eXW93Crfx9X5YOaW Qb1a0Iir3eU4ggVrQrFmdq9gNUhQOBZrgOLd9TPlDm7BXjaIM+IaKvKs1OGRcCobcnkb 2S5ux3biFb+JTPpsAL/mPpys/SVGJvvXOc0y6rJApZcmdb08NbtPhxM+sv/hTA9nI8ry Mjdg== X-Forwarded-Encrypted: i=1; AHgh+RpTUk6C/3qZ/dujcBlQkNhhCpGJxPjWBsi2lqnk2d0H3Jp4IgAn0kkrZ+WdiP/2it8i9gPL0SOzjcpeHuo=@vger.kernel.org X-Gm-Message-State: AOJu0Yw63gxbkiyM0IWvz6QU83L4GEcJJDUYPjjkuisIkKLWumlbyRtH 3ykpQMJNTmWyc22/zMHQnaaY9Xe/5ZZgK5obo26ipm8bqZnoWU/b1bGp X-Gm-Gg: AR+sD10NXM86ugATS40nRm9FYGiRFu0/PVyWHh09bjQL7QVb0DV725rkbiZ6aArSWh7 OOFrW/dK52zFyYydR4S64w4AIBy0NC/Z2tgPCFDid0KyB5Vlhlasvgf3nENE47O/Q9rwy+phpl0 eTId9LvAl9mar1dCSxcUew1VE0/0FbWVlDMgnyfqukVYjQqapUs52FKONnd7a+MnmBVk/LGiO2U tBJYXOsX/snRixxrQIYqmzJ4549yEQYERGTQqH8njrsUWghySeCN9emXD5OxkZSTipGVveG588X na7yNO0CzkyojRVRWbdwWxaJAz2p2A8esnZDdkyYjHreKVOF91m2DktfhXZGQMAoL+5FgK/ElJC eOVZKRyZjQB0m1P7X4xrttfJd+J1vh0GTYzW1hWlS8zPwMD5UL39DfGIZCT5zgyJM1HRudgUTlh TZS+G0qE9e5lE6flNwkMr56GZlre3mvgLdTGe5pFle9SW2hl0EbSycX75TyBfgy9vaUF811cd+c WyXTgwtjSTHAdzEix/KdgwXO5VbZlS7+M6Dez+t3VY8wqMmxArK 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-kernel@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