[PATCH 1/2] kconfig: add prop_err function to simplify property error handling

From: Julian Braha

Date: Tue Sep 22 2026 - 12:49:42 EST


As suggested by Nicolas while reviewing another Kconfig property error [1],
we can add a prop_err() function to simplify the tracking and display of
Kconfig property errors.

Note that the formatting of the error printing is changed slightly
(removing a space) to better match the formatting of warnings. This causes
a change to the expected test output for the existing errors that now call
prop_err().

Link: https://lore.kernel.org/all/20260917-proficient-swift-of-masquerade-0ff7ce@l-nschier-aarch64/ [1]
Assisted-by: LLM
Suggested-by: Nicolas Schier <n.schier@xxxxxxxxx>
Signed-off-by: Julian Braha <julianbraha@xxxxxxxxx>
---
scripts/kconfig/menu.c | 23 ++++++++-----
.../tests/err_num_bounds/expected_stderr | 20 ++++++------
.../tests/err_num_mismatch/expected_stderr | 8 ++---
.../err_num_non_numeric_ref/expected_stderr | 32 +++++++++----------
4 files changed, 45 insertions(+), 38 deletions(-)

diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index bda3e2650216..118af2dde722 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -59,6 +59,16 @@ static void prop_warn(const struct property *prop, const char *fmt, ...)
va_end(ap);
}

+static void prop_err(const struct property *prop, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ fprintf(stderr, "%s:%d:error: ", prop->filename, prop->lineno);
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
+}
+
void _menu_init(void)
{
current_entry = current_menu = &rootmenu;
@@ -246,18 +256,15 @@ static int menu_validate_number(struct symbol *sym, struct symbol *sym2,

if (sym2->type != S_UNKNOWN ||
!sym_string_valid(sym, sym2->name)) {
- fprintf(stderr, "%s:%d: error: '%s' is an invalid value for '%s'\n",
- prop->filename, prop->lineno, sym2->name,
- sym_type_name(sym->type));
+ prop_err(prop, "'%s' is an invalid value for '%s'",
+ sym2->name, sym_type_name(sym->type));
return 1;
}

if (!sym_string_check_bounds(sym, sym2->name)) {
- fprintf(stderr,
- "%s:%d: error: %s constant '%s' is outside the 64-bit %s bounds\n",
- prop->filename, prop->lineno, sym_type_name(sym->type),
- sym2->name, sym->type == S_INT ? "signed" : "unsigned");
-
+ prop_err(prop, "%s constant '%s' is outside the 64-bit %s bounds",
+ sym_type_name(sym->type), sym2->name,
+ sym->type == S_INT ? "signed" : "unsigned");
return 1;
}

diff --git a/scripts/kconfig/tests/err_num_bounds/expected_stderr b/scripts/kconfig/tests/err_num_bounds/expected_stderr
index 5f89cf4afff8..c012b10bae25 100644
--- a/scripts/kconfig/tests/err_num_bounds/expected_stderr
+++ b/scripts/kconfig/tests/err_num_bounds/expected_stderr
@@ -1,10 +1,10 @@
-Kconfig:51: error: integer constant '10000000000000000000' is outside the 64-bit signed bounds
-Kconfig:55: error: integer constant '-9223372036854775809' is outside the 64-bit signed bounds
-Kconfig:59: error: integer constant '10000000000000000000' is outside the 64-bit signed bounds
-Kconfig:63: error: integer constant '-10000000000000000000' is outside the 64-bit signed bounds
-Kconfig:67: error: integer constant '-9223372036854775809' is outside the 64-bit signed bounds
-Kconfig:67: error: integer constant '10000000000000000000' is outside the 64-bit signed bounds
-Kconfig:71: error: hex constant '0x10000000000000000' is outside the 64-bit unsigned bounds
-Kconfig:75: error: hex constant '0x10000000000000000' is outside the 64-bit unsigned bounds
-Kconfig:79: error: hex constant '0x10000000000000000' is outside the 64-bit unsigned bounds
-Kconfig:79: error: hex constant '0x20000000000000000' is outside the 64-bit unsigned bounds
+Kconfig:51:error: integer constant '10000000000000000000' is outside the 64-bit signed bounds
+Kconfig:55:error: integer constant '-9223372036854775809' is outside the 64-bit signed bounds
+Kconfig:59:error: integer constant '10000000000000000000' is outside the 64-bit signed bounds
+Kconfig:63:error: integer constant '-10000000000000000000' is outside the 64-bit signed bounds
+Kconfig:67:error: integer constant '-9223372036854775809' is outside the 64-bit signed bounds
+Kconfig:67:error: integer constant '10000000000000000000' is outside the 64-bit signed bounds
+Kconfig:71:error: hex constant '0x10000000000000000' is outside the 64-bit unsigned bounds
+Kconfig:75:error: hex constant '0x10000000000000000' is outside the 64-bit unsigned bounds
+Kconfig:79:error: hex constant '0x10000000000000000' is outside the 64-bit unsigned bounds
+Kconfig:79:error: hex constant '0x20000000000000000' is outside the 64-bit unsigned bounds
diff --git a/scripts/kconfig/tests/err_num_mismatch/expected_stderr b/scripts/kconfig/tests/err_num_mismatch/expected_stderr
index 587c34467ae6..058b507396f4 100644
--- a/scripts/kconfig/tests/err_num_mismatch/expected_stderr
+++ b/scripts/kconfig/tests/err_num_mismatch/expected_stderr
@@ -1,4 +1,4 @@
-Kconfig:14: error: 'HEX_SOURCE' is an invalid value for 'integer'
-Kconfig:18: error: 'HEX_SOURCE' is an invalid value for 'integer'
-Kconfig:24: error: 'INT_SOURCE' is an invalid value for 'hex'
-Kconfig:28: error: 'INT_SOURCE' is an invalid value for 'hex'
+Kconfig:14:error: 'HEX_SOURCE' is an invalid value for 'integer'
+Kconfig:18:error: 'HEX_SOURCE' is an invalid value for 'integer'
+Kconfig:24:error: 'INT_SOURCE' is an invalid value for 'hex'
+Kconfig:28:error: 'INT_SOURCE' is an invalid value for 'hex'
diff --git a/scripts/kconfig/tests/err_num_non_numeric_ref/expected_stderr b/scripts/kconfig/tests/err_num_non_numeric_ref/expected_stderr
index 005f855ecbdd..48d78b5c18b1 100644
--- a/scripts/kconfig/tests/err_num_non_numeric_ref/expected_stderr
+++ b/scripts/kconfig/tests/err_num_non_numeric_ref/expected_stderr
@@ -1,16 +1,16 @@
-Kconfig:17: error: 'BOOL_SOURCE' is an invalid value for 'integer'
-Kconfig:21: error: 'TRISTATE_SOURCE' is an invalid value for 'integer'
-Kconfig:25: error: 'STRING_SOURCE' is an invalid value for 'integer'
-Kconfig:31: error: 'BOOL_SOURCE' is an invalid value for 'hex'
-Kconfig:35: error: 'TRISTATE_SOURCE' is an invalid value for 'hex'
-Kconfig:39: error: 'STRING_SOURCE' is an invalid value for 'hex'
-Kconfig:45: error: 'BOOL_SOURCE' is an invalid value for 'integer'
-Kconfig:49: error: 'TRISTATE_SOURCE' is an invalid value for 'integer'
-Kconfig:53: error: 'STRING_SOURCE' is an invalid value for 'integer'
-Kconfig:57: error: 'BOOL_SOURCE' is an invalid value for 'integer'
-Kconfig:57: error: 'TRISTATE_SOURCE' is an invalid value for 'integer'
-Kconfig:63: error: 'BOOL_SOURCE' is an invalid value for 'hex'
-Kconfig:67: error: 'TRISTATE_SOURCE' is an invalid value for 'hex'
-Kconfig:71: error: 'STRING_SOURCE' is an invalid value for 'hex'
-Kconfig:75: error: 'BOOL_SOURCE' is an invalid value for 'hex'
-Kconfig:75: error: 'TRISTATE_SOURCE' is an invalid value for 'hex'
+Kconfig:17:error: 'BOOL_SOURCE' is an invalid value for 'integer'
+Kconfig:21:error: 'TRISTATE_SOURCE' is an invalid value for 'integer'
+Kconfig:25:error: 'STRING_SOURCE' is an invalid value for 'integer'
+Kconfig:31:error: 'BOOL_SOURCE' is an invalid value for 'hex'
+Kconfig:35:error: 'TRISTATE_SOURCE' is an invalid value for 'hex'
+Kconfig:39:error: 'STRING_SOURCE' is an invalid value for 'hex'
+Kconfig:45:error: 'BOOL_SOURCE' is an invalid value for 'integer'
+Kconfig:49:error: 'TRISTATE_SOURCE' is an invalid value for 'integer'
+Kconfig:53:error: 'STRING_SOURCE' is an invalid value for 'integer'
+Kconfig:57:error: 'BOOL_SOURCE' is an invalid value for 'integer'
+Kconfig:57:error: 'TRISTATE_SOURCE' is an invalid value for 'integer'
+Kconfig:63:error: 'BOOL_SOURCE' is an invalid value for 'hex'
+Kconfig:67:error: 'TRISTATE_SOURCE' is an invalid value for 'hex'
+Kconfig:71:error: 'STRING_SOURCE' is an invalid value for 'hex'
+Kconfig:75:error: 'BOOL_SOURCE' is an invalid value for 'hex'
+Kconfig:75:error: 'TRISTATE_SOURCE' is an invalid value for 'hex'
--
2.55.0