Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bootconfig: Change array value to use child node

It is not possible to put an array value with subkeys under
a key node, because both of subkeys and the array elements
are using "next" field of the xbc_node.

Thus this changes the array values to use "child" field in
the array case. The reason why split this change is to
test it easily.

Link: https://lkml.kernel.org/r/162262193838.264090.16044473274501498656.stgit@devnote2

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Masami Hiramatsu and committed by
Steven Rostedt (VMware)
ca24306d ee0a0701

+24 -9
+1 -1
fs/proc/bootconfig.c
··· 49 49 else 50 50 q = '"'; 51 51 ret = snprintf(dst, rest(dst, end), "%c%s%c%s", 52 - q, val, q, vnode->next ? ", " : "\n"); 52 + q, val, q, xbc_node_is_array(vnode) ? ", " : "\n"); 53 53 if (ret < 0) 54 54 goto out; 55 55 dst += ret;
+3 -3
include/linux/bootconfig.h
··· 71 71 */ 72 72 static inline __init bool xbc_node_is_array(struct xbc_node *node) 73 73 { 74 - return xbc_node_is_value(node) && node->next != 0; 74 + return xbc_node_is_value(node) && node->child != 0; 75 75 } 76 76 77 77 /** ··· 140 140 */ 141 141 #define xbc_array_for_each_value(anode, value) \ 142 142 for (value = xbc_node_get_data(anode); anode != NULL ; \ 143 - anode = xbc_node_get_next(anode), \ 143 + anode = xbc_node_get_child(anode), \ 144 144 value = anode ? xbc_node_get_data(anode) : NULL) 145 145 146 146 /** ··· 171 171 */ 172 172 #define xbc_node_for_each_array_value(node, key, anode, value) \ 173 173 for (value = xbc_node_find_value(node, key, &anode); value != NULL; \ 174 - anode = xbc_node_get_next(anode), \ 174 + anode = xbc_node_get_child(anode), \ 175 175 value = anode ? xbc_node_get_data(anode) : NULL) 176 176 177 177 /**
+19 -4
lib/bootconfig.c
··· 367 367 return node; 368 368 } 369 369 370 + static inline __init struct xbc_node *xbc_last_child(struct xbc_node *node) 371 + { 372 + while (node->child) 373 + node = xbc_node_get_child(node); 374 + 375 + return node; 376 + } 377 + 370 378 static struct xbc_node * __init xbc_add_sibling(char *data, u32 flag) 371 379 { 372 380 struct xbc_node *sib, *node = xbc_add_node(data, flag); ··· 525 517 char *next; 526 518 int c = 0; 527 519 520 + if (last_parent->child) 521 + last_parent = xbc_node_get_child(last_parent); 522 + 528 523 do { 529 524 c = __xbc_parse_value(__v, &next); 530 525 if (c < 0) 531 526 return c; 532 527 533 - node = xbc_add_sibling(*__v, XBC_VALUE); 528 + node = xbc_add_child(*__v, XBC_VALUE); 534 529 if (!node) 535 530 return -ENOMEM; 536 531 *__v = next; 537 532 } while (c == ','); 538 - node->next = 0; 533 + node->child = 0; 539 534 540 535 return c; 541 536 } ··· 626 615 627 616 if (op == ':' && child) { 628 617 xbc_init_node(child, v, XBC_VALUE); 629 - } else if (!xbc_add_sibling(v, XBC_VALUE)) 630 - return -ENOMEM; 618 + } else { 619 + if (op == '+' && child) 620 + last_parent = xbc_last_child(child); 621 + if (!xbc_add_sibling(v, XBC_VALUE)) 622 + return -ENOMEM; 623 + } 631 624 632 625 if (c == ',') { /* Array */ 633 626 c = xbc_parse_array(&next);
+1 -1
tools/bootconfig/main.c
··· 27 27 q = '\''; 28 28 else 29 29 q = '"'; 30 - printf("%c%s%c%s", q, val, q, node->next ? ", " : eol); 30 + printf("%c%s%c%s", q, val, q, xbc_node_is_array(node) ? ", " : eol); 31 31 i++; 32 32 } 33 33 return i;