Commit f3668cde authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Steven Rostedt (VMware)

bootconfig: Split parse-tree part from xbc_init

Split bootconfig data parser to build tree code from
xbc_init(). This is an internal cosmetic change.

Link: https://lkml.kernel.org/r/163187296647.2366983.15590065167920474865.stgit@devnote2Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 115d4d08
...@@ -801,6 +801,58 @@ static int __init xbc_verify_tree(void) ...@@ -801,6 +801,58 @@ static int __init xbc_verify_tree(void)
return 0; return 0;
} }
/* Need to setup xbc_data and xbc_nodes before call this. */
static int __init xbc_parse_tree(void)
{
char *p, *q;
int ret, c;
last_parent = NULL;
p = xbc_data;
do {
q = strpbrk(p, "{}=+;:\n#");
if (!q) {
p = skip_spaces(p);
if (*p != '\0')
ret = xbc_parse_error("No delimiter", p);
break;
}
c = *q;
*q++ = '\0';
switch (c) {
case ':':
case '+':
if (*q++ != '=') {
ret = xbc_parse_error(c == '+' ?
"Wrong '+' operator" :
"Wrong ':' operator",
q - 2);
break;
}
fallthrough;
case '=':
ret = xbc_parse_kv(&p, q, c);
break;
case '{':
ret = xbc_open_brace(&p, q);
break;
case '#':
q = skip_comment(q);
fallthrough;
case ';':
case '\n':
ret = xbc_parse_key(&p, q);
break;
case '}':
ret = xbc_close_brace(&p, q);
break;
}
} while (!ret);
return ret;
}
/** /**
* xbc_exit() - Clean up all parsed bootconfig * xbc_exit() - Clean up all parsed bootconfig
* *
...@@ -836,8 +888,7 @@ void __init xbc_exit(void) ...@@ -836,8 +888,7 @@ void __init xbc_exit(void)
*/ */
int __init xbc_init(const char *data, size_t size, const char **emsg, int *epos) int __init xbc_init(const char *data, size_t size, const char **emsg, int *epos)
{ {
char *p, *q; int ret;
int ret, c;
if (epos) if (epos)
*epos = -1; *epos = -1;
...@@ -874,49 +925,7 @@ int __init xbc_init(const char *data, size_t size, const char **emsg, int *epos) ...@@ -874,49 +925,7 @@ int __init xbc_init(const char *data, size_t size, const char **emsg, int *epos)
} }
memset(xbc_nodes, 0, sizeof(struct xbc_node) * XBC_NODE_MAX); memset(xbc_nodes, 0, sizeof(struct xbc_node) * XBC_NODE_MAX);
last_parent = NULL; ret = xbc_parse_tree();
p = xbc_data;
do {
q = strpbrk(p, "{}=+;:\n#");
if (!q) {
p = skip_spaces(p);
if (*p != '\0')
ret = xbc_parse_error("No delimiter", p);
break;
}
c = *q;
*q++ = '\0';
switch (c) {
case ':':
case '+':
if (*q++ != '=') {
ret = xbc_parse_error(c == '+' ?
"Wrong '+' operator" :
"Wrong ':' operator",
q - 2);
break;
}
fallthrough;
case '=':
ret = xbc_parse_kv(&p, q, c);
break;
case '{':
ret = xbc_open_brace(&p, q);
break;
case '#':
q = skip_comment(q);
fallthrough;
case ';':
case '\n':
ret = xbc_parse_key(&p, q);
break;
case '}':
ret = xbc_close_brace(&p, q);
break;
}
} while (!ret);
if (!ret) if (!ret)
ret = xbc_verify_tree(); ret = xbc_verify_tree();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment