parser xml REFACTOR move status check into func
diff --git a/src/parser_xml.c b/src/parser_xml.c
index 506bf18..1914e76 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -1097,7 +1097,11 @@
const char *prefix;
size_t prefix_len;
- assert(xmlctx->status == LYXML_ELEMENT);
+ if (xmlctx->status != LYXML_ELEMENT) {
+ /* nothing to parse */
+ return LY_ENOT;
+ }
+
if (ly_strncmp(name, xmlctx->name, xmlctx->name_len)) {
/* not the expected element */
return LY_ENOT;
@@ -1274,12 +1278,6 @@
assert(envp && !*envp);
- if (xmlctx->status != LYXML_ELEMENT) {
- /* nothing to parse */
- assert(xmlctx->status == LYXML_END);
- goto cleanup;
- }
-
/* parse "rpc" */
r = lydxml_envelope(xmlctx, "rpc", "urn:ietf:params:xml:ns:netconf:base:1.0", 0, envp);
LY_CHECK_ERR_GOTO(r, rc = r, cleanup);
@@ -1328,12 +1326,6 @@
assert(envp && !*envp);
- if (xmlctx->status != LYXML_ELEMENT) {
- /* nothing to parse */
- assert(xmlctx->status == LYXML_END);
- goto cleanup;
- }
-
/* parse "notification" */
r = lydxml_envelope(xmlctx, "notification", "urn:ietf:params:xml:ns:netconf:notification:1.0", 0, envp);
LY_CHECK_ERR_GOTO(r, rc = r, cleanup);
@@ -1749,12 +1741,6 @@
assert(envp && !*envp);
- if (xmlctx->status != LYXML_ELEMENT) {
- /* nothing to parse */
- assert(xmlctx->status == LYXML_END);
- goto cleanup;
- }
-
/* parse "rpc-reply" */
r = lydxml_envelope(xmlctx, "rpc-reply", "urn:ietf:params:xml:ns:netconf:base:1.0", 0, envp);
LY_CHECK_ERR_GOTO(r, rc = r, cleanup);