From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
Masahiro Yamada <masahiroy@kernel.org>
Subject: [PATCH 5/5] kconfig: refactor error messages in sym_check_print_recursive()
Date: Thu, 27 Jun 2024 03:22:04 +0900 [thread overview]
Message-ID: <20240626182212.3758235-6-masahiroy@kernel.org> (raw)
In-Reply-To: <20240626182212.3758235-1-masahiroy@kernel.org>
Improve the error messages and clean up redundant code.
[1] remove redundant next_sym->name checks
If 'next_sym' is a choice, the first 'if' block is executed. In the
subsequent 'else if' blocks, 'next_sym" is not a choice, hence
next_sym->name is not NULL.
[2] remove redundant sym->name checks
A choice is never selected or implied by anyone because it has no name
(it is syntactically impossible). If it is, sym->name is not NULL.
[3] Show the location of choice instead of "<choice>"
"part of choice <choice>" does not convey useful information. Since a
choice has no name, it is more informative to display the file name and
line number.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/kconfig/symbol.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 787f0667836b..c05d188a1857 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -1107,37 +1107,37 @@ static void sym_check_print_recursive(struct symbol *last_sym)
prop->filename, prop->lineno);
if (sym_is_choice(next_sym)) {
- fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
+ choice = list_first_entry(&next_sym->menus, struct menu, link);
+
+ fprintf(stderr, "%s:%d:\tsymbol %s is part of choice block at %s:%d\n",
menu->filename, menu->lineno,
sym->name ? sym->name : "<choice>",
- next_sym->name ? next_sym->name : "<choice>");
+ choice->filename, choice->lineno);
} else if (stack->expr == &sym->dir_dep.expr) {
fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
prop->filename, prop->lineno,
sym->name ? sym->name : "<choice>",
- next_sym->name ? next_sym->name : "<choice>");
+ next_sym->name);
} else if (stack->expr == &sym->rev_dep.expr) {
fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
prop->filename, prop->lineno,
- sym->name ? sym->name : "<choice>",
- next_sym->name ? next_sym->name : "<choice>");
+ sym->name, next_sym->name);
} else if (stack->expr == &sym->implied.expr) {
fprintf(stderr, "%s:%d:\tsymbol %s is implied by %s\n",
prop->filename, prop->lineno,
- sym->name ? sym->name : "<choice>",
- next_sym->name ? next_sym->name : "<choice>");
+ sym->name, next_sym->name);
} else if (stack->expr) {
fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
prop->filename, prop->lineno,
sym->name ? sym->name : "<choice>",
prop_get_type_name(prop->type),
- next_sym->name ? next_sym->name : "<choice>");
+ next_sym->name);
} else {
fprintf(stderr, "%s:%d:\tsymbol %s %s is visible depending on %s\n",
prop->filename, prop->lineno,
sym->name ? sym->name : "<choice>",
prop_get_type_name(prop->type),
- next_sym->name ? next_sym->name : "<choice>");
+ next_sym->name);
}
}
--
2.43.0
prev parent reply other threads:[~2024-06-26 18:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 18:21 [PATCH 0/5] kconfig: fix conditional prompt for choice and recursive error messages Masahiro Yamada
2024-06-26 18:22 ` [PATCH 1/5] treewide: change conditional prompt for choices to 'depends on' Masahiro Yamada
2024-06-26 18:22 ` [PATCH 2/5] kconfig: fix conditional prompt behavior for choice Masahiro Yamada
2024-06-26 18:22 ` [PATCH 3/5] kconfig: improve error message for dependency between choice members Masahiro Yamada
2024-06-26 18:22 ` [PATCH 4/5] kconfig: improve error message for recursive dependency in choice Masahiro Yamada
2024-06-26 18:22 ` Masahiro Yamada [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240626182212.3758235-6-masahiroy@kernel.org \
--to=masahiroy@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox