yin parser CHANGE remove dead code after previous changes
diff --git a/src/parser_yin.c b/src/parser_yin.c
index bb967c8..192cad7 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -100,7 +100,7 @@
  * @param[in] xml_ctx XML parser context.
  * @param[in, out] data Data to read from.
  * @param[in] arg_type Type of argument that is expected in parsed element (use YIN_ARG_NONE for elements without special arguments).
- * @param[out] arg_val Where value of argument should be stored. Can be NULL if arg_type is spedified as YIN_ARG_NONE.
+ * @param[out] arg_val Where value of argument should be stored. Can be NULL if arg_type is specified as YIN_ARG_NONE.
  */
 static LY_ERR
 yin_parse_attribute(struct lyxml_context *xml_ctx, const char **data, enum YIN_ARGUMENT arg_type, const char **arg_val)
@@ -157,7 +157,7 @@
     int dynamic;
 
     ret = yin_parse_attribute(xml_ctx, data, YIN_ARG_NONE, NULL);
-    LY_CHECK_RET(ret != LY_SUCCESS, ret);
+    LY_CHECK_RET(ret);
     LY_CHECK_RET(xml_ctx->status != LYXML_ELEM_CONTENT, LY_EVALID);
 
     if (xml_ctx->status == LYXML_ELEM_CONTENT) {
@@ -170,38 +170,6 @@
     return LY_SUCCESS;
 }
 
-LY_ERR
-parse_namespace(struct lyxml_context *xml_ctx, const char **data, const char **namespace)
-{
-    LY_ERR ret = LY_SUCCESS;
-
-    ret = yin_parse_attribute(xml_ctx, data, YIN_ARG_URI, namespace);
-    LY_CHECK_RET(ret != LY_SUCCESS, ret);
-
-    return ret;
-}
-
-/**
- * @brief Parse prefix statement.
- *
- * @param[in] xml_ctx Xml context.
- * @param[in, out] data Data to reda from.
- * @param[out] prefix Where to store prefix value.
- *
- * @return LY_ERR values.
- */
-LY_ERR
-parse_prefix(struct lyxml_context *xml_ctx, const char **data, const char **prefix)
-{
-    LY_ERR ret = LY_SUCCESS;
-
-    /* parse attributes */
-    ret = yin_parse_attribute(xml_ctx, data, YIN_ARG_VALUE, prefix);
-    LY_CHECK_RET(ret != LY_SUCCESS, ret);
-
-    return ret;
-}
-
 static LY_ERR
 yin_parse_revision_date(struct lyxml_context *xml_ctx, const char **data, char *rev, struct lysp_ext_instance **exts)
 {
@@ -213,7 +181,7 @@
         return LY_EVALID;
     }
 
-    ret = yin_parse_attribute(xml_ctx, data, YIN_ARG_DATE, &temp_rev);
+    LY_CHECK_RET(yin_parse_attribute(xml_ctx, data, YIN_ARG_DATE, &temp_rev))
     LY_CHECK_RET(ret != LY_SUCCESS, ret);
     LY_CHECK_RET(lysp_check_date((struct lys_parser_ctx *)xml_ctx, temp_rev, strlen(temp_rev), "revision-date") != LY_SUCCESS, LY_EVALID);
 
@@ -237,13 +205,14 @@
     LY_ARRAY_NEW_RET(xml_ctx->ctx, *imports, imp, LY_EVALID);
 
     /* parse import attributes  */
-    ret = yin_parse_attribute(xml_ctx, data, YIN_ARG_MODULE, &imp->name);
+    LY_CHECK_RET(yin_parse_attribute(xml_ctx, data, YIN_ARG_MODULE, &imp->name));
+
     while ((ret = lyxml_get_element(xml_ctx, data, &prefix, &prefix_len, &name, &name_len) == LY_SUCCESS && name != NULL)) {
         kw = match_keyword(name, name_len, prefix_len);
         switch (kw) {
         case YANG_PREFIX:
             LY_CHECK_ERR_RET(imp->prefix, LOGVAL_YANG(xml_ctx, LY_VCODE_DUPSTMT, "prefix"), LY_EVALID);
-            parse_prefix(xml_ctx, data, &imp->prefix);
+            LY_CHECK_RET(yin_parse_attribute(xml_ctx, data, YIN_ARG_VALUE, &imp->prefix));
             LY_CHECK_RET(lysp_check_prefix((struct lys_parser_ctx *)xml_ctx, *imports, module_prefix, &imp->prefix), LY_EVALID);
             break;
         case YANG_DESCRIPTION:
@@ -394,8 +363,7 @@
         }
 #undef CHECK_ORDER
 
-        ret = lyxml_get_element(xml_ctx, data, &prefix, &prefix_len, &name, &name_len);
-        LY_CHECK_RET(ret != LY_SUCCESS, LY_EMEM);
+        LY_CHECK_RET(lyxml_get_element(xml_ctx, data, &prefix, &prefix_len, &name, &name_len));
 
         if (name) {
             kw = match_keyword(name, name_len, prefix_len);
@@ -403,10 +371,10 @@
 
             /* module header */
             case YANG_NAMESPACE:
-                LY_CHECK_RET(parse_namespace(xml_ctx, data, &(*mod)->mod->ns));
+                LY_CHECK_RET(yin_parse_attribute(xml_ctx, data, YIN_ARG_URI, &(*mod)->mod->ns));
                 break;
             case YANG_PREFIX:
-                LY_CHECK_RET(parse_prefix(xml_ctx, data, &(*mod)->mod->prefix));
+                LY_CHECK_RET(yin_parse_attribute(xml_ctx, data, YIN_ARG_VALUE, &(*mod)->mod->prefix));
                 break;
 
             /* linkage */
@@ -435,7 +403,7 @@
         }
     }
 
-    return ret;
+    return LY_SUCCESS;
 }
 
 /**
diff --git a/src/parser_yin.h b/src/parser_yin.h
index aa19506..ac198da 100644
--- a/src/parser_yin.h
+++ b/src/parser_yin.h
@@ -20,7 +20,7 @@
     YIN_ARG_DATE,          /**< argument data */
     YIN_ARG_TAG,           /**< argument tag */
     YIN_ARG_XMLNS,         /**< argument xmlns */
-    YIN_ARG_NONE,          /**< special value to specify no valid argument except xmlns, do not confuse with YIN_ARG_NONE */
+    YIN_ARG_NONE,          /**< special value to specify no valid argument except xmlns, do not confuse with YIN_ARG_UNKNOWN */
 };
 
 /**
@@ -43,17 +43,6 @@
 LY_ERR parse_text_element(struct lyxml_context *xml_ctx, const char **data, const char **value);
 
 /**
- * @brief Parse namespace statement.
- *
- * @param[in] xml_ctx xml context.
- * @param[in, out] data Data to read from.
- * @param[in, out] namespace Where namespace value should be stored.
- *
- * @return LY_ERR values.
- */
-LY_ERR parse_namespace(struct lyxml_context *xml_ctx, const char **data, const char **namespace);
-
-/**
  * @brief Parse import element
  *
  * @param[in] xml_ctx Xml context.
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index 8a96726..dcb5236 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -1318,10 +1318,6 @@
 enum yang_keyword
 match_keyword(const char *data, size_t len, size_t prefix_len)
 {
-    if (prefix_len != 0) {
-        return YANG_CUSTOM;
-    }
-
     if (!data || len == 0) {
         return YANG_NONE;
     }
@@ -1505,6 +1501,10 @@
 #undef IF_KEYWORD_PREFIX
 #undef IF_KEYWORD_PREFIX_END
 
+    if (prefix_len != 0) {
+        return YANG_CUSTOM;
+    }
+
     if (data - start == (long int)len) {
         return kw;
     } else {
diff --git a/src/tree_schema_internal.h b/src/tree_schema_internal.h
index db61beb..699f1e5 100644
--- a/src/tree_schema_internal.h
+++ b/src/tree_schema_internal.h
@@ -680,7 +680,7 @@
  * @param[in] data Input data to be parsed.
  * @param[in, out] mod Prepared module structure where the parsed information, including the parsed
  * module structure, will be filled in.
- * @return LY_ERR value - LY_SUCCESS, LY_EINVAL or LY_EVALID.
+ * @return LY_ERR values.
  */
 LY_ERR yin_parse_module(struct ly_ctx *ctx, const char *data, struct lys_module *mod);
 
diff --git a/tests/src/test_parser_yin.c b/tests/src/test_parser_yin.c
index af8ffd1..07761d8 100644
--- a/tests/src/test_parser_yin.c
+++ b/tests/src/test_parser_yin.c
@@ -224,6 +224,12 @@
     assert_string_equal(st->mod->parsed->mod->contact, "contact...");
     assert_string_equal(st->mod->parsed->mod->dsc, "description...");
     assert_string_equal(st->mod->parsed->mod->ref, "reference...");
+
+    st = reset_state(state);
+    ret = yin_parse_module(st->ctx,"<module name=\"example-foo\">\
+                                        <organization test=\"invalid-argument\">organization...</organization>\
+                                    </module>", st->mod);
+    assert_int_equal(ret, LY_EVALID);
 }
 
 static void
@@ -253,27 +259,6 @@
 }
 
 static void
-test_parse_namespace(void **state)
-{
-    struct state *st = *state;
-    const char *res = NULL, *prefix = NULL, *name = NULL;
-    size_t prefix_len = 0, name_len = 0;
-    LY_ERR ret = LY_SUCCESS;
-
-    const char *data = "<namespace uri=\"urn:example:foo\"/>\
-                        <namespace urr=\"urn:example:foo\"/>";
-    lyxml_get_element(st->xml_ctx, &data, &prefix, &prefix_len, &name, &name_len);
-    ret = parse_namespace(st->xml_ctx, &data, &res);
-    assert_int_equal(ret, LY_SUCCESS);
-    assert_string_equal(res, "urn:example:foo");
-    lydict_remove(st->ctx, "urn:example:foo");
-
-    lyxml_get_element(st->xml_ctx, &data, &prefix, &prefix_len, &name, &name_len);
-    ret = parse_namespace(st->xml_ctx, &data, &res);
-    assert_int_equal(ret, LY_EVALID);
-}
-
-static void
 test_yin_parse_import(void **state)
 {
     struct state *st = *state;
@@ -319,7 +304,6 @@
         cmocka_unit_test_setup_teardown(test_yin_parse_module, setup_f, teardown_f),
         cmocka_unit_test_setup_teardown(test_meta, setup_f, teardown_f),
         cmocka_unit_test_setup_teardown(test_parse_text_element, setup_f, teardown_f),
-        cmocka_unit_test_setup_teardown(test_parse_namespace, setup_f, teardown_f),
         cmocka_unit_test_setup_teardown(test_yin_parse_import, setup_f, teardown_f),
         cmocka_unit_test(test_match_keyword),
         cmocka_unit_test(test_match_argument),