Re: [PATCH] tools/bootconfig: Preserve arrays starting with an empty value

From: Masami Hiramatsu (Google)

Date: Sat Nov 21 2026 - 21:02:28 EST


On Wed, 18 Nov 2026 00:07:57 +0100, Eduardo Mucelli Rezende Oliveira <edumucelli@xxxxxxxxx> 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@xxxxxxxxx>
> ---
> 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@xxxxxxxxxx>