Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp552594lqh; Sat, 4 May 2024 11:35:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbw8hTVxawdB58iU6fuqxhvbSnA8/JGH4hPwvUVj7txMXFHS1k3m9zACOX8FAHS53dVcbFUI3RW6L8v9PcmH+oi9G/g0fG7QSdaS4r/w== X-Google-Smtp-Source: AGHT+IGBQZCuLN9hSg33DXI2wKm7rwF91WQRXw74Ow3IVyllIO4NkHJqLJ6IrDVgi+TxxgBKo96Z X-Received: by 2002:a05:6a00:130a:b0:6f3:e6e0:d9fb with SMTP id j10-20020a056a00130a00b006f3e6e0d9fbmr6216600pfu.11.1714847747727; Sat, 04 May 2024 11:35:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714847747; cv=pass; d=google.com; s=arc-20160816; b=NK7DOwz5/JTLtohU6ONojqNIrnre0Dv42MDG9Q/L0ghqUpvjD8IbMnNG77/nrznWkh U+HU+/HAaKjMlJgJtPs1bP/ZNchYM/nOmzcnJhClgSFv39SwsVLnW4yrswOkI/UoCjlw jvFa775XC/8IfDzzCFY/g//ZLiQr+WuMvbp7RzKVK6F17N25No6A0AQJ7YaiNT2MHRg5 rgxC8aX4cowvHxwobxkw6LMatD/OYw+BYdLvODog7PVP3dIrYDw2wHvLyLYtVQ4ztoY5 OOSOB2n+ZKO7WDvytjv0WRoTBX4R2Htfg5qsC1lF7jWhv+OyxLmQYhTHMqCe7uFCQz+p ophg== 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=hKtXFgLeyVAFJPB3bA/tdqcKCZRmOu63wAcEEVtXqis=; fh=oQbvuNnOUeIuBT5siQdg+euUHNNdn+CeEwAg69/1RSo=; b=ev9cJTiAR4lHvFEEQAOs+aptTNKtoW6teaBz1o3R5jcdwHWFfrIQPLEJIf4voIrU3d 1vhj5zfZ6yvCgH+oB3UX3orTcF4h3skiTj0KgTDQrG70YX8I2ZWBz8HwBLYbeodG4lyR MhQztk++ssMBW8vS6kchAFipr7EBsqdysBDLQDjw2rJqq3qSj3VA2r/1qOTNxL48cqAP JJpVscDze0X6keGJibT3FKVUk6gNN2mojlgOS31XeAz8fdJtolA79Y97mbbw7nirSM9A bzQInkHi24Szu3ge9L9lRyqTRT3aaBNQHbOzy0OvMPAWUKMWExGCIw/L/66I1s4AtSkh rSqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pyqA3Bm6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168795-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168795-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c66-20020a633545000000b0061c2f4c8265si4133994pga.784.2024.05.04.11.35.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 11:35:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168795-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pyqA3Bm6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168795-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168795-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5FA39281ECD for ; Sat, 4 May 2024 18:35:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DCC0283CD6; Sat, 4 May 2024 18:34:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pyqA3Bm6" 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 0E3F285953; Sat, 4 May 2024 18:34:19 +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=1714847660; cv=none; b=OumMr0lWQcjjlzvT2cPQa+Lph5K93xsfYw+bhz8M+uU3/jrNp4NsAsQ6M40EumGxlr2rmcjOkcbxD4D5Uk8yjv03NJFiXXh3O1sweBjKYiMtnTR1lb58zNpUUYzaW2Ytl4qEAxocjKQrLMncNEq2NsQW3SSITZjdzRC5Py7pDkI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714847660; c=relaxed/simple; bh=IjS/X0Zg7nzLrbnNApIqBryuz3RpzFI+6nuPMvnXyQY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b9wXXVvzcVn8YbL+V8uXjE3LcVVWlPAMOUEnXAhZn49y6kQnDHt+MWtCc0YXL6o1Zp1c26IEzgj76/eJX33ZBBp83QNWoSkh/0bItmz9+SlwIjVgZUMf+KWj85gn7/EgjUyws9/ShVDXhxNKcDR2iDDHNbyRCaWmXx7uB/1pq0Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pyqA3Bm6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2C0DC4AF1B; Sat, 4 May 2024 18:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714847659; bh=IjS/X0Zg7nzLrbnNApIqBryuz3RpzFI+6nuPMvnXyQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pyqA3Bm6fsbLqFuCLaJ1FTzdxPwvjd9T3kZymn37zTC9zvyF8qjT0HAdKveohvoor nYKvTEcTrUmbEbDPP5IuGKnGbYNANtRD+eRY5HBFbhgM5FkJ0eT6UT62JPFWzjgf1+ FRJ9Ew6tpXAe/ed/b7Yfr8judF+Io/YYqUAbqSDgmfCl2Tss9Z+x7w5avYk74klux7 i4/XlrvzXPHmKFsnUryrC2P9jK/iv79VPD8gWBZ01+SRZ7u1TuhuwFuvnrK79VZAst f1BNoh57M2GLu8q0nwrYBP6GpjKwMlaCtcDJKcCw5jyKX2Z7xP7Ym58X4/+69n8w2Z vhOCy5u4YvY0A== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 09/10] kconfig: turn missing prompt for choice members into error Date: Sun, 5 May 2024 03:33:32 +0900 Message-Id: <20240504183333.2031860-9-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 Choice members must have a prompt; hence make it an error. While I was here, I moved the check to the parser to slim down _menu_finalize(). Signed-off-by: Masahiro Yamada --- scripts/kconfig/menu.c | 2 -- scripts/kconfig/parser.y | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index e01b9ee87c05..a9b1e451dfe7 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -507,8 +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; - if (!menu->prompt) - menu_warn(menu, "choice value must have a prompt"); for (prop = menu->sym->prop; prop; prop = prop->next) { if (prop->type == P_DEFAULT) prop_warn(prop, "defaults for choice " diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 613fa8c9c2d0..ed86869e5ed0 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -30,6 +30,8 @@ static bool zconf_endtoken(const char *tokenname, struct menu *current_menu, *current_entry; +static bool inside_choice = false; + %} %union @@ -145,6 +147,14 @@ config_entry_start: T_CONFIG nonconst_symbol T_EOL config_stmt: config_entry_start config_option_list { + if (inside_choice) { + if (!current_entry->prompt) { + fprintf(stderr, "%s:%d: error: choice member must have a prompt\n", + current_entry->filename, current_entry->lineno); + yynerrs++; + } + } + printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno); }; @@ -237,10 +247,14 @@ choice_entry: choice choice_option_list } $$ = menu_add_menu(); + + inside_choice = true; }; choice_end: end { + inside_choice = false; + if (zconf_endtoken($1, "choice")) { menu_end_menu(); printd(DEBUG_PARSE, "%s:%d:endchoice\n", cur_filename, cur_lineno); -- 2.40.1