Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp552683lqh; Sat, 4 May 2024 11:36:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXzxB5N0lqH3HAZrNcqnbO9FiXKGVqoS0vbYcqBI37j7XROPmhLKInHak/af3UhhPW339Mry6RU8A5zM+VCpjJRoh/3O7pCwFVdO4z0eA== X-Google-Smtp-Source: AGHT+IHYY/hk0OHvrwRMxRKDGpZBnT6iH3VgKys4OUropdEb4tY7h1X2ZCV7eClFQF9Mi0a4b8Wr X-Received: by 2002:a05:6830:3493:b0:6ee:35a4:1583 with SMTP id c19-20020a056830349300b006ee35a41583mr8968075otu.30.1714847761317; Sat, 04 May 2024 11:36:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714847761; cv=pass; d=google.com; s=arc-20160816; b=vrBIhLvwNWHce/JjP+abwdV6Tmy5LLEXFhEXiCP49Kqq2p0AaA7N6+IJHAlcbmdjH8 4FzGfiHAmJyaqbi18CH/J9bbiBZQZRukKhs/8Ux6DaTJ3L81nkUof6Ia13asLcJ0+dMv L7T72Hvm5i+s0fJaawwChYxKrQNFWNXgcpqcp8qSDOZmU7AvNXgM0dRsly1lFYTuNzOw rif5AsTQm4ZuXspNkxm0cxQP7o9ePI4uI0d801ZGhcyRW8lW75FgGvaar3he7vJd33Rt FPrz3rTp5XLukKNw47BLrRJ11yAQFSp2f7/pBjSxgMBPRLj0dhObxYcg1C11bfaSDah3 DN2w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=kBx2omfii4y4zM9L+fHQmcp20Fenvwcn9BvokRFM5Yk=; fh=oQbvuNnOUeIuBT5siQdg+euUHNNdn+CeEwAg69/1RSo=; b=mBl341Pz7+FgiiKbxG6ugZj2tssMz3w5HXPi0QZV5CIkphnCF8si5d8OqYAb23Is+t u5Ww3ufjjFR0NV2VTroq0gph4YJT2KgZQmhotCpvq/C9qwomzIlsg+icahvjVw9QtBnn B/EE8PPAj14YqMwmE3oOiIIM/+vyrkYjW1lrvXr/TWro1i4yRf36Ht/5/pPuzEQm7LYZ fXuYt5CzLNLHgA9le4pb3UePfRycYqarVhmrnNjBp09+HNNli5F1x1esquCmZdYvrc8E oWm/SNOB6GED7VINq/31lngRiKR9m+RsZsR+fDgrDGuyv7dZ7zK8prRC5m8N0Q+Yyom9 U0ug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HV4a5+bE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168796-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id k11-20020a05620a414b00b00790f453c5b1si6412107qko.467.2024.05.04.11.36.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 11:36:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HV4a5+bE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168796-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0E3681C20E49 for ; Sat, 4 May 2024 18:36:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 511AD84047; Sat, 4 May 2024 18:34:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HV4a5+bE" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7916486246; Sat, 4 May 2024 18:34:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714847661; cv=none; b=pO43+pF4gA7t9n1lux0BfR9XeyDZqh2PZ4dC/8lFoCBW7pGbvXGKljkZCnGUMmbw7v3cNsrMAYwkZcM/hAZ5H2Nw9SQZPH+MdcDlecdg54sUYlOejKIDUP2egiKPAqQAZcPFqp0J/6u8pnaizviL6PLTtaMwEMb9OoK+TDXWxWo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714847661; c=relaxed/simple; bh=XMH+AE/Klmn9DMqBahtTcW2r5APi9nvotzI6xvIKwkM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pUIeEsZ4pxTfwUXBmTfBL38H9qOkWN6ZIE2HX8D+bG2Kjl4tOe7qm4VoE+RDM65OIxUBy0emoe7zxJRyAuWiN6b85z1nMMdm8BPMEtO14F8ur+9HmgoBEtJJ9wDYd6McloacOdOA2v510nuNX4uCqsaap54030gzdE8Dz1ECiWk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HV4a5+bE; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F69BC4AF18; Sat, 4 May 2024 18:34:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714847661; bh=XMH+AE/Klmn9DMqBahtTcW2r5APi9nvotzI6xvIKwkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HV4a5+bEoFroBVyEmLVu/jIdqDyZ08rYKs/9wlQjSuXCXYns7ZX/t5robna8UCPqC iq8gKnoIYXesAZ2XXIGIBjUyc9pmKnAT/zal/J+DhS/xZBZG48jDBiqVWSyiWoc7NU hRNmrY8BnaBCCQ7oZU49K6HwwMO34SrYE6EGfVQRnBl3JeigaBOg030MCutCSWcaHC u9TsaduYy5LOJcY83Mau5bQhkFROcnmnuxzZMNrC3JZKzD9qxjQhCvv9CU+lGodmJm RZJfb6mosgx6myFQ8wHk5YZ6fhy9e+2pDYgyxX4FF1BIvEuvV1b0UgirkLPqlJSWG9 b0POmvtOII0Tw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 10/10] kconfig: turn defaults and additional prompt for choice members into error Date: Sun, 5 May 2024 03:33:33 +0900 Message-Id: <20240504183333.2031860-10-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240504183333.2031860-1-masahiroy@kernel.org> References: <20240504183333.2031860-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit menu_finalize() warns default properties for choice members and prompts outside the choice block. These should be hard errors. While I was here, I moved the checks to slim down menu_finalize(). Signed-off-by: Masahiro Yamada --- scripts/kconfig/menu.c | 10 ---------- scripts/kconfig/parser.y | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index a9b1e451dfe7..bee96c9964fd 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -507,16 +507,6 @@ static void _menu_finalize(struct menu *parent, bool inside_choice) menu->sym && !sym_is_choice_value(menu->sym)) { current_entry = menu; menu->sym->flags |= SYMBOL_CHOICEVAL; - for (prop = menu->sym->prop; prop; prop = prop->next) { - if (prop->type == P_DEFAULT) - prop_warn(prop, "defaults for choice " - "values not supported"); - if (prop->menu == menu) - continue; - if (prop->type == P_PROMPT && - prop->menu->parent->sym != sym) - prop_warn(prop, "choice value used outside its choice group"); - } /* Non-tristate choice values of tristate choices must * depend on the choice being set to Y. The choice * values' dependencies were propagated to their diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index ed86869e5ed0..0a9e249b5dcc 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -476,6 +476,37 @@ assign_val: %% +/** + * choice_check_sanity - check sanity of a choice member + * + * @menu: menu of the choice member + * + * Return: -1 if an error is found, 0 otherwise. + */ +static int choice_check_sanity(struct menu *menu) +{ + struct property *prop; + int ret = 0; + + for (prop = menu->sym->prop; prop; prop = prop->next) { + if (prop->type == P_DEFAULT) { + fprintf(stderr, "%s:%d: error: %s", + prop->filename, prop->lineno, + "defaults for choice values not supported\n"); + ret = -1; + } + + if (prop->menu != menu && prop->type == P_PROMPT) { + fprintf(stderr, "%s:%d: error: %s", + prop->filename, prop->lineno, + "choice value has a prompt outside its choice group\n"); + ret = -1; + } + } + + return ret; +} + void conf_parse(const char *name) { struct menu *menu; @@ -523,8 +554,16 @@ void conf_parse(const char *name) menu_finalize(); menu_for_each_entry(menu) { + struct menu *child; + if (menu->sym && sym_check_deps(menu->sym)) yynerrs++; + + if (menu->sym && sym_is_choice(menu->sym)) { + menu_for_each_sub_entry(child, menu) + if (child->sym && choice_check_sanity(child)) + yynerrs++; + } } if (yynerrs) -- 2.40.1