mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
Merge tag 'bootconfig-fixes-v7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull bootconfig fixes from Masami Hiramatsu: - bootconfig: Allow keys with the maximum supported depth Check the array capacity before storing the next key component in xbc_node_compose_key_after() so keys at XBC_DEPTH_MAX (16) are composed instead of failing with -ERANGE when listing keys or creating /proc/bootconfig. - bootconfig: Trim unquoted values at end of file Trim trailing whitespace from unquoted values in __xbc_parse_value() after scanning finishes so values at end of input without a trailing newline do not retain extra whitespace. - tools/bootconfig: Close only opened braces in compact output Check key children while skipping value nodes when backtracking in xbc_show_compact_tree() so a brace is not closed when a single subkey under a valued key was printed in dotted notation. - tools/bootconfig: Test listing keys at the maximum depth Add regression tests verifying that a 16-component key can be attached and listed in full while a 17-component key is rejected. * tag 'bootconfig-fixes-v7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: bootconfig: Trim unquoted values at end of file tools/bootconfig: Close only opened braces in compact output tools/bootconfig: Test listing keys at the maximum depth bootconfig: Allow keys with the maximum supported depth
This commit is contained in:
+4
-3
@@ -428,9 +428,9 @@ int __init xbc_node_compose_key_after(struct xbc_node *root,
|
||||
node = xbc_node_get_parent(node);
|
||||
|
||||
while (node && node != root) {
|
||||
keys[depth++] = xbc_node_index(node);
|
||||
if (depth == XBC_DEPTH_MAX)
|
||||
return -ERANGE;
|
||||
keys[depth++] = xbc_node_index(node);
|
||||
node = xbc_node_get_parent(node);
|
||||
}
|
||||
if (!node && root)
|
||||
@@ -793,16 +793,17 @@ static int __init __xbc_parse_value(char **__v, char **__n)
|
||||
return xbc_parse_error("No value delimiter", p);
|
||||
if (*p)
|
||||
p++;
|
||||
break;
|
||||
goto skip_trim;
|
||||
}
|
||||
if (strchr(",;\n#}", c)) {
|
||||
*p++ = '\0';
|
||||
v = strim(v);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (quotes)
|
||||
return xbc_parse_error("No closing quotes", p);
|
||||
v = strim(v);
|
||||
skip_trim:
|
||||
if (c == '#') {
|
||||
p = skip_comment(p);
|
||||
c = '\n'; /* A comment must be treated as a newline */
|
||||
|
||||
+22
-7
@@ -68,6 +68,23 @@ static int xbc_show_value(struct xbc_node *node, bool semicolon)
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Match the conditions under which the compact formatter opens braces. */
|
||||
static bool xbc_node_needs_braces(struct xbc_node *node)
|
||||
{
|
||||
struct xbc_node *child = xbc_node_get_child(node);
|
||||
|
||||
if (child && xbc_node_is_value(child))
|
||||
child = xbc_node_get_next(child);
|
||||
if (!child)
|
||||
return false;
|
||||
if (child->next)
|
||||
return true;
|
||||
|
||||
/* A single subkey with both a value and subkeys is not compacted. */
|
||||
child = xbc_node_get_child(child);
|
||||
return child && xbc_node_is_value(child) && child->next;
|
||||
}
|
||||
|
||||
static void xbc_show_compact_tree(void)
|
||||
{
|
||||
struct xbc_node *node, *cnode = NULL, *vnode;
|
||||
@@ -128,14 +145,12 @@ static void xbc_show_compact_tree(void)
|
||||
node = xbc_node_get_parent(node);
|
||||
if (!node)
|
||||
return;
|
||||
if (!xbc_node_get_child(node)->next)
|
||||
if (!depth || !xbc_node_needs_braces(node))
|
||||
continue;
|
||||
if (depth) {
|
||||
depth--;
|
||||
for (i = 0; i < depth; i++)
|
||||
printf("\t");
|
||||
printf("}\n");
|
||||
}
|
||||
depth--;
|
||||
for (i = 0; i < depth; i++)
|
||||
printf("\t");
|
||||
printf("}\n");
|
||||
}
|
||||
node = xbc_node_get_next(node);
|
||||
}
|
||||
|
||||
@@ -1,2 +1,7 @@
|
||||
key = "value";
|
||||
key.subkey = "another-value";
|
||||
a {
|
||||
b = "v";
|
||||
b.c = "w";
|
||||
z = "q";
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
# value -> subkey pattern
|
||||
key = value
|
||||
key.subkey = another-value
|
||||
|
||||
# A valued parent with one subkey must not close its enclosing brace.
|
||||
a.b = v
|
||||
a.b.c = w
|
||||
a.z = q
|
||||
|
||||
@@ -100,6 +100,16 @@ xpass $BOOTCONF -a $TEMPCONF $INITRD
|
||||
printf "badnode\n" >> $TEMPCONF
|
||||
xfail $BOOTCONF -a $TEMPCONF $INITRD
|
||||
|
||||
echo "Max key depth check"
|
||||
|
||||
printf 'a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p = "value"\n' > $TEMPCONF
|
||||
xpass $BOOTCONF -a $TEMPCONF $INITRD
|
||||
$BOOTCONF -l $INITRD > $OUTFILE
|
||||
xpass cmp $TEMPCONF $OUTFILE
|
||||
|
||||
printf 'a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q = "value"\n' > $TEMPCONF
|
||||
xfail $BOOTCONF -a $TEMPCONF $INITRD
|
||||
|
||||
echo "Max filesize check"
|
||||
|
||||
# Max size is 32767 (including terminal byte)
|
||||
@@ -171,6 +181,24 @@ $BOOTCONF $INITRD > $OUTFILE
|
||||
xfail grep -q 'val[[:space:]]' $OUTFILE
|
||||
xpass grep -q 'val2[[:space:]]' $OUTFILE
|
||||
|
||||
echo "Remove unquoted trailing whitespace at end of file"
|
||||
printf 'foo = val \t' > $TEMPCONF
|
||||
$BOOTCONF -l $TEMPCONF > $OUTFILE
|
||||
printf 'foo = "val"\n' > $TEMPCONF
|
||||
xpass cmp $TEMPCONF $OUTFILE
|
||||
|
||||
echo "Remove trailing whitespace from the last array value at end of file"
|
||||
printf 'foo = first, last \t' > $TEMPCONF
|
||||
$BOOTCONF -l $TEMPCONF > $OUTFILE
|
||||
printf 'foo = "first", "last"\n' > $TEMPCONF
|
||||
xpass cmp $TEMPCONF $OUTFILE
|
||||
|
||||
echo "Keep quoted trailing whitespace at end of file"
|
||||
printf 'foo = "val "' > $TEMPCONF
|
||||
$BOOTCONF -l $TEMPCONF > $OUTFILE
|
||||
printf 'foo = "val "\n' > $TEMPCONF
|
||||
xpass cmp $TEMPCONF $OUTFILE
|
||||
|
||||
echo "Showing correct line:column of no closing brace"
|
||||
cat > $TEMPCONF << EOF
|
||||
foo {
|
||||
|
||||
Reference in New Issue
Block a user