* [PATCH] tools/bootconfig: Preserve arrays starting with an empty value
@ 2026-11-17 23:07 Eduardo Mucelli Rezende Oliveira
2026-11-22 2:02 ` Masami Hiramatsu (Google)
0 siblings, 1 reply; 3+ messages in thread
From: Eduardo Mucelli Rezende Oliveira @ 2026-11-17 23:07 UTC (permalink / raw)
To: mhiramat; +Cc: rostedt, linux-trace-kernel, linux-kernel
bootconfig -l treats an empty first value as a key without a value.
When the value is an array, this drops every subsequent entry from the
output. For example, 'key = "", "value"' is printed as 'key = ""'.
Reading the list output back loses the second entry.
Check for a child value node instead of checking the contents of the
first string. This lets xbc_show_value() print all the array entries
and keeps the existing output for keys without a value.
Add tests for direct arrays, appended values, nested keys, empty
scalars and keys without values. Exercise list output from both a
configuration file and a test initrd.
Fixes: e4f70b7badb4 ("tools/bootconfig: Add list option")
Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
---
Hi Masami,
Thanks again for reviewing the earlier bootconfig fixes.
I tested the list output on my Ubuntu machine using plain bootconfig
files and a temporary initrd image. The two new output comparisons fail
on the original tool and pass with this change. The full bootconfig
test suite also passes with the patch applied.
Thanks,
Eduardo
tools/bootconfig/main.c | 2 +-
tools/bootconfig/test-bootconfig.sh | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
index d3f840c5adce..b189ca0935b9 100644
--- a/tools/bootconfig/main.c
+++ b/tools/bootconfig/main.c
@@ -170,7 +170,7 @@ static void xbc_show_list(void)
break;
}
printf("%s = ", key);
- if (!val || val[0] == '\0') {
+ if (!val || !xbc_node_get_child(leaf)) {
printf("\"\"\n");
continue;
}
diff --git a/tools/bootconfig/test-bootconfig.sh b/tools/bootconfig/test-bootconfig.sh
index f584f7637e12..85d56b7e4ac7 100755
--- a/tools/bootconfig/test-bootconfig.sh
+++ b/tools/bootconfig/test-bootconfig.sh
@@ -156,6 +156,30 @@ $BOOTCONF $INITRD > $TEMPCONF
cat $TEMPCONF
xpass grep \'\"string\"\' $TEMPCONF
+echo "List output preserves arrays starting with an empty value"
+cat > $TEMPCONF << EOF
+flag
+empty = ""
+array = "", "value", ""
+append = ""
+append += "value"
+nested.array = "", "value"
+EOF
+$BOOTCONF -l $TEMPCONF > $OUTFILE
+cat > $TEMPCONF << EOF
+flag = ""
+empty = ""
+array = "", "value", ""
+append = "", "value"
+nested.array = "", "value"
+EOF
+xpass diff -u $TEMPCONF $OUTFILE
+
+echo "List output preserves empty array values in an initrd"
+xpass $BOOTCONF -a $TEMPCONF $INITRD
+$BOOTCONF -l $INITRD > $OUTFILE
+xpass diff -u $TEMPCONF $OUTFILE
+
echo "Repeat same-key tree"
cat > $TEMPCONF << EOF
foo
base-commit: 381b391bfaa3f10d52da4740529804b0b6b8160d
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tools/bootconfig: Preserve arrays starting with an empty value
2026-11-17 23:07 [PATCH] tools/bootconfig: Preserve arrays starting with an empty value Eduardo Mucelli Rezende Oliveira
@ 2026-11-22 2:02 ` Masami Hiramatsu (Google)
2026-11-22 14:11 ` [PATCH v2] " Eduardo Mucelli Rezende Oliveira
0 siblings, 1 reply; 3+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-11-22 2:02 UTC (permalink / raw)
To: Eduardo Mucelli Rezende Oliveira
Cc: rostedt, linux-trace-kernel, linux-kernel
On Wed, 18 Nov 2026 00:07:57 +0100, Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com> wrote:
> bootconfig -l treats an empty first value as a key without a value.
> When the value is an array, this drops every subsequent entry from the
> output. For example, 'key = "", "value"' is printed as 'key = ""'.
> Reading the list output back loses the second entry.
>
> Check for a child value node instead of checking the contents of the
> first string. This lets xbc_show_value() print all the array entries
> and keeps the existing output for keys without a value.
>
> Add tests for direct arrays, appended values, nested keys, empty
> scalars and keys without values. Exercise list output from both a
> configuration file and a test initrd.
>
> Fixes: e4f70b7badb4 ("tools/bootconfig: Add list option")
> Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
> ---
> Hi Masami,
>
> Thanks again for reviewing the earlier bootconfig fixes.
>
> I tested the list output on my Ubuntu machine using plain bootconfig
> files and a temporary initrd image. The two new output comparisons fail
> on the original tool and pass with this change. The full bootconfig
> test suite also passes with the patch applied.
Thanks, the fix itself looks good to me. However your test case looks a bit
wrong.
>
> Thanks,
> Eduardo
>
> tools/bootconfig/main.c | 2 +-
> tools/bootconfig/test-bootconfig.sh | 24 ++++++++++++++++++++++++
> 2 files changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
> index d3f840c5adce..b189ca0935b9 100644
> --- a/tools/bootconfig/main.c
> +++ b/tools/bootconfig/main.c
> @@ -170,7 +170,7 @@ static void xbc_show_list(void)
> break;
> }
> printf("%s = ", key);
> - if (!val || val[0] == '\0') {
> + if (!val || !xbc_node_get_child(leaf)) {
> printf("\"\"\n");
> continue;
> }
> diff --git a/tools/bootconfig/test-bootconfig.sh b/tools/bootconfig/test-bootconfig.sh
> index f584f7637e12..85d56b7e4ac7 100755
> --- a/tools/bootconfig/test-bootconfig.sh
> +++ b/tools/bootconfig/test-bootconfig.sh
> @@ -156,6 +156,30 @@ $BOOTCONF $INITRD > $TEMPCONF
> cat $TEMPCONF
> xpass grep \'\"string\"\' $TEMPCONF
>
> +echo "List output preserves arrays starting with an empty value"
> +cat > $TEMPCONF << EOF
> +flag
> +empty = ""
> +array = "", "value", ""
> +append = ""
> +append += "value"
> +nested.array = "", "value"
> +EOF
> +$BOOTCONF -l $TEMPCONF > $OUTFILE
> +cat > $TEMPCONF << EOF
> +flag = ""
> +empty = ""
> +array = "", "value", ""
> +append = "", "value"
> +nested.array = "", "value"
> +EOF
> +xpass diff -u $TEMPCONF $OUTFILE
> +
> +echo "List output preserves empty array values in an initrd"
> +xpass $BOOTCONF -a $TEMPCONF $INITRD
> +$BOOTCONF -l $INITRD > $OUTFILE
> +xpass diff -u $TEMPCONF $OUTFILE
This second case actually reuses the $TEMPCONF which
already overwritten by canonicalized expected one.
Thanks,
> +
> echo "Repeat same-key tree"
> cat > $TEMPCONF << EOF
> foo
>
> base-commit: 381b391bfaa3f10d52da4740529804b0b6b8160d
> --
> 2.53.0
>
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] tools/bootconfig: Preserve arrays starting with an empty value
2026-11-22 2:02 ` Masami Hiramatsu (Google)
@ 2026-11-22 14:11 ` Eduardo Mucelli Rezende Oliveira
0 siblings, 0 replies; 3+ messages in thread
From: Eduardo Mucelli Rezende Oliveira @ 2026-11-22 14:11 UTC (permalink / raw)
To: mhiramat; +Cc: rostedt, linux-trace-kernel, linux-kernel
bootconfig -l treats an empty first value as a key without a value.
When the value is an array, this drops every subsequent entry from the
output. For example, 'key = "", "value"' is printed as 'key = ""'.
Reading the list output back loses the second entry.
Check for a child value node instead of checking the contents of the
first string. This lets xbc_show_value() print all the array entries
and keeps the existing output for keys without a value.
Add tests for direct arrays, appended values, nested keys, empty
scalars and keys without values. Exercise list output from both a
configuration file and a test initrd.
Fixes: e4f70b7badb4 ("tools/bootconfig: Add list option")
Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
---
Hi Masami,
Thanks for catching the test issue. The plain-file and initrd cases now
use the same original input and compare against a separate expected
output file. I reran the bootconfig test suite on my Ubuntu machine.
Thanks,
Eduardo
Changes in v2
- Keep the input file intact for the initrd case.
- Rebase onto the current bootconfig/fixes.
tools/bootconfig/main.c | 2 +-
tools/bootconfig/test-bootconfig.sh | 27 ++++++++++++++++++++++++++-
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
index c32fb1e2140cf..256d2ba7523c8 100644
--- a/tools/bootconfig/main.c
+++ b/tools/bootconfig/main.c
@@ -170,7 +170,7 @@ static void xbc_show_list(void)
break;
}
printf("%s = ", key);
- if (!val || val[0] == '\0') {
+ if (!val || !xbc_node_get_child(leaf)) {
printf("\"\"\n");
continue;
}
diff --git a/tools/bootconfig/test-bootconfig.sh b/tools/bootconfig/test-bootconfig.sh
index a93a40d11d278..1f41ccd9ed3b2 100755
--- a/tools/bootconfig/test-bootconfig.sh
+++ b/tools/bootconfig/test-bootconfig.sh
@@ -14,10 +14,11 @@ ALIGN=4
INITRD=`mktemp ${TESTDIR}/initrd-XXXX`
TEMPCONF=`mktemp ${TESTDIR}/temp-XXXX.bconf`
OUTFILE=`mktemp ${TESTDIR}/tempout-XXXX`
+EXPECTED=`mktemp ${TESTDIR}/expected-XXXX`
NG=0
cleanup() {
- rm -f $INITRD $TEMPCONF $OUTFILE
+ rm -f $INITRD $TEMPCONF $OUTFILE $EXPECTED
exit $NG
}
@@ -169,6 +170,30 @@ $BOOTCONF $INITRD > $TEMPCONF
cat $TEMPCONF
xpass grep \'\"string\"\' $TEMPCONF
+echo "List output preserves arrays starting with an empty value"
+cat > $TEMPCONF << EOF
+flag
+empty = ""
+array = "", "value", ""
+append = ""
+append += "value"
+nested.array = "", "value"
+EOF
+$BOOTCONF -l $TEMPCONF > $OUTFILE
+cat > $EXPECTED << EOF
+flag = ""
+empty = ""
+array = "", "value", ""
+append = "", "value"
+nested.array = "", "value"
+EOF
+xpass diff -u $EXPECTED $OUTFILE
+
+echo "List output preserves empty array values in an initrd"
+xpass $BOOTCONF -a $TEMPCONF $INITRD
+$BOOTCONF -l $INITRD > $OUTFILE
+xpass diff -u $EXPECTED $OUTFILE
+
echo "Repeat same-key tree"
cat > $TEMPCONF << EOF
foo
base-commit: 51934668ca98f1b23c51ce4edea3c61018da342c
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-22 14:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 23:07 [PATCH] tools/bootconfig: Preserve arrays starting with an empty value Eduardo Mucelli Rezende Oliveira
2026-11-22 2:02 ` Masami Hiramatsu (Google)
2026-11-22 14:11 ` [PATCH v2] " Eduardo Mucelli Rezende Oliveira
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®