projects
/
linux-2.6-microblaze.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge tag 'socfpga_dts_update_for_v5.7' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git]
/
lib
/
bootconfig.c
diff --git
a/lib/bootconfig.c
b/lib/bootconfig.c
index
3ea601a
..
ec3ce7f
100644
(file)
--- a/
lib/bootconfig.c
+++ b/
lib/bootconfig.c
@@
-533,7
+533,7
@@
struct xbc_node *find_match_node(struct xbc_node *node, char *k)
static int __init __xbc_add_key(char *k)
{
static int __init __xbc_add_key(char *k)
{
- struct xbc_node *node;
+ struct xbc_node *node
, *child
;
if (!xbc_valid_keyword(k))
return xbc_parse_error("Invalid keyword", k);
if (!xbc_valid_keyword(k))
return xbc_parse_error("Invalid keyword", k);
@@
-543,8
+543,12
@@
static int __init __xbc_add_key(char *k)
if (!last_parent) /* the first level */
node = find_match_node(xbc_nodes, k);
if (!last_parent) /* the first level */
node = find_match_node(xbc_nodes, k);
- else
- node = find_match_node(xbc_node_get_child(last_parent), k);
+ else {
+ child = xbc_node_get_child(last_parent);
+ if (child && xbc_node_is_value(child))
+ return xbc_parse_error("Subkey is mixed with value", k);
+ node = find_match_node(child, k);
+ }
if (node)
last_parent = node;
if (node)
last_parent = node;
@@
-574,10
+578,10
@@
static int __init __xbc_parse_keys(char *k)
return __xbc_add_key(k);
}
return __xbc_add_key(k);
}
-static int __init xbc_parse_kv(char **k, char *v)
+static int __init xbc_parse_kv(char **k, char *v
, int op
)
{
struct xbc_node *prev_parent = last_parent;
{
struct xbc_node *prev_parent = last_parent;
- struct xbc_node *
node
;
+ struct xbc_node *
child
;
char *next;
int c, ret;
char *next;
int c, ret;
@@
-585,12
+589,19
@@
static int __init xbc_parse_kv(char **k, char *v)
if (ret)
return ret;
if (ret)
return ret;
+ child = xbc_node_get_child(last_parent);
+ if (child) {
+ if (xbc_node_is_key(child))
+ return xbc_parse_error("Value is mixed with subkey", v);
+ else if (op == '=')
+ return xbc_parse_error("Value is redefined", v);
+ }
+
c = __xbc_parse_value(&v, &next);
if (c < 0)
return c;
c = __xbc_parse_value(&v, &next);
if (c < 0)
return c;
- node = xbc_add_sibling(v, XBC_VALUE);
- if (!node)
+ if (!xbc_add_sibling(v, XBC_VALUE))
return -ENOMEM;
if (c == ',') { /* Array */
return -ENOMEM;
if (c == ',') { /* Array */
@@
-763,7
+774,7
@@
int __init xbc_init(char *buf)
p = buf;
do {
p = buf;
do {
- q = strpbrk(p, "{}=;\n#");
+ q = strpbrk(p, "{}=
+
;\n#");
if (!q) {
p = skip_spaces(p);
if (*p != '\0')
if (!q) {
p = skip_spaces(p);
if (*p != '\0')
@@
-774,8
+785,15
@@
int __init xbc_init(char *buf)
c = *q;
*q++ = '\0';
switch (c) {
c = *q;
*q++ = '\0';
switch (c) {
+ case '+':
+ if (*q++ != '=') {
+ ret = xbc_parse_error("Wrong '+' operator",
+ q - 2);
+ break;
+ }
+ /* Fall through */
case '=':
case '=':
- ret = xbc_parse_kv(&p, q);
+ ret = xbc_parse_kv(&p, q
, c
);
break;
case '{':
ret = xbc_open_brace(&p, q);
break;
case '{':
ret = xbc_open_brace(&p, q);