uncrustify FORMAT set various uncrustify options

PR #1228
diff --git a/src/common.c b/src/common.c
index 163119b..b923bb3 100644
--- a/src/common.c
+++ b/src/common.c
@@ -178,7 +178,8 @@
 ly_strncmp(const char *refstr, const char *str, size_t str_len)
 {
     int rc = strncmp(refstr, str, str_len);
-    if (!rc && refstr[str_len] == '\0') {
+
+    if (!rc && (refstr[str_len] == '\0')) {
         return 0;
     } else {
         return rc ? rc : 1;
@@ -202,7 +203,7 @@
         /* one byte character */
         len = 1;
 
-        if (c < 0x20 && c != 0x9 && c != 0xa && c != 0xd) {
+        if ((c < 0x20) && (c != 0x9) && (c != 0xa) && (c != 0xd)) {
             return LY_EINVAL;
         }
     } else if ((c & 0xe0) == 0xc0) {
@@ -232,7 +233,7 @@
             c = (c << 6) | (aux & 0x3f);
         }
 
-        if (c < 0x800 || (c > 0xd7ff && c < 0xe000) || c > 0xfffd) {
+        if ((c < 0x800) || ((c > 0xd7ff) && (c < 0xe000)) || (c > 0xfffd)) {
             return LY_EINVAL;
         }
     } else if ((c & 0xf8) == 0xf0) {
@@ -249,7 +250,7 @@
             c = (c << 6) | (aux & 0x3f);
         }
 
-        if (c < 0x1000 || c > 0x10ffff) {
+        if ((c < 0x1000) || (c > 0x10ffff)) {
             return LY_EINVAL;
         }
     } else {
@@ -269,10 +270,10 @@
 {
     if (value < 0x80) {
         /* one byte character */
-        if (value < 0x20 &&
-                value != 0x09 &&
-                value != 0x0a &&
-                value != 0x0d) {
+        if ((value < 0x20) &&
+                (value != 0x09) &&
+                (value != 0x0a) &&
+                (value != 0x0d)) {
             return LY_EINVAL;
         }
 
@@ -286,7 +287,7 @@
     } else if (value < 0xfffe) {
         /* three bytes character */
         if (((value & 0xf800) == 0xd800) ||
-                (value >= 0xfdd0 && value <= 0xfdef)) {
+                ((value >= 0xfdd0) && (value <= 0xfdef))) {
             /* exclude surrogate blocks %xD800-DFFF */
             /* exclude noncharacters %xFDD0-FDEF */
             return LY_EINVAL;
@@ -356,6 +357,7 @@
 LY_VCODE_INSTREXP_len(const char *str)
 {
     size_t len = 0;
+
     if (!str) {
         return len;
     } else if (!str[0]) {
@@ -391,7 +393,7 @@
     pagesize = sysconf(_SC_PAGESIZE);
 
     m = sb.st_size % pagesize;
-    if (m && pagesize - m >= 1) {
+    if (m && (pagesize - m >= 1)) {
         /* there will be enough space (at least 1 byte) after the file content mapping to provide zeroed NULL-termination byte */
         *length = sb.st_size + 1;
         *addr = mmap(NULL, *length, PROT_READ, MAP_PRIVATE, fd, 0);
@@ -463,7 +465,7 @@
 
     /* parse the value */
     i = strtoll(val_str, &strptr, base);
-    if (errno || strptr == val_str) {
+    if (errno || (strptr == val_str)) {
         return LY_EVALID;
     } else if ((i < min) || (i > max)) {
         return LY_EDENIED;
@@ -471,7 +473,7 @@
         while (isspace(*strptr)) {
             ++strptr;
         }
-        if (*strptr && strptr < val_str + val_len) {
+        if (*strptr && (strptr < val_str + val_len)) {
             return LY_EVALID;
         }
     }
@@ -491,15 +493,15 @@
     errno = 0;
     strptr = NULL;
     u = strtoull(val_str, &strptr, base);
-    if (errno || strptr == val_str) {
+    if (errno || (strptr == val_str)) {
         return LY_EVALID;
-    } else if ((u > max) || (u && val_str[0] == '-')) {
+    } else if ((u > max) || (u && (val_str[0] == '-'))) {
         return LY_EDENIED;
     } else if (strptr && *strptr) {
         while (isspace(*strptr)) {
             ++strptr;
         }
-        if (*strptr && strptr < val_str + val_len) {
+        if (*strptr && (strptr < val_str + val_len)) {
             return LY_EVALID;
         }
     }
@@ -614,7 +616,7 @@
             *errmsg = "Invalid node-identifier.";
             goto error;
         }
-        if (format == LYD_XML && !(*prefix)) {
+        if ((format == LYD_XML) && !(*prefix)) {
             /* all node names MUST be qualified with explicit namespace prefix */
             *errmsg = "Missing prefix of a node name.";
             goto error;
@@ -641,7 +643,7 @@
 
         /* quoted-string */
         quot = in[offset++];
-        if (quot != '\'' && quot != '\"') {
+        if ((quot != '\'') && (quot != '\"')) {
             *errmsg = "String value is not quoted.";
             goto error;
         }
diff --git a/src/context.c b/src/context.c
index 771a310..85ae0d1 100644
--- a/src/context.c
+++ b/src/context.c
@@ -39,12 +39,12 @@
 #include "tree_schema_internal.h"
 #include "xpath.h"
 
-#include "../models/ietf-yang-metadata@2016-08-05.h"
-#include "../models/yang@2020-06-17.h"
-#include "../models/ietf-inet-types@2013-07-15.h"
-#include "../models/ietf-yang-types@2013-07-15.h"
 #include "../models/ietf-datastores@2018-02-14.h"
+#include "../models/ietf-inet-types@2013-07-15.h"
 #include "../models/ietf-yang-library@2019-01-04.h"
+#include "../models/ietf-yang-metadata@2016-08-05.h"
+#include "../models/ietf-yang-types@2013-07-15.h"
+#include "../models/yang@2020-06-17.h"
 #define IETF_YANG_LIB_REV "2019-01-04"
 
 static struct internal_modules_s {
@@ -76,20 +76,20 @@
     if (search_dir) {
         new_dir = realpath(search_dir, NULL);
         LY_CHECK_ERR_RET(!new_dir,
-                         LOGERR(ctx, LY_ESYS, "Unable to use search directory \"%s\" (%s).", search_dir, strerror(errno)),
-                         LY_EINVAL);
+                LOGERR(ctx, LY_ESYS, "Unable to use search directory \"%s\" (%s).", search_dir, strerror(errno)),
+                LY_EINVAL);
         if (strcmp(search_dir, new_dir)) {
             LOGVRB("Canonicalizing search directory string from \"%s\" to \"%s\".", search_dir, new_dir);
         }
         LY_CHECK_ERR_RET(access(new_dir, R_OK | X_OK),
-                         LOGERR(ctx, LY_ESYS, "Unable to fully access search directory \"%s\" (%s).", new_dir, strerror(errno)); free(new_dir),
-                         LY_EINVAL);
+                LOGERR(ctx, LY_ESYS, "Unable to fully access search directory \"%s\" (%s).", new_dir, strerror(errno)); free(new_dir),
+                LY_EINVAL);
         LY_CHECK_ERR_RET(stat(new_dir, &st),
-                         LOGERR(ctx, LY_ESYS, "stat() failed for \"%s\" (%s).", new_dir, strerror(errno)); free(new_dir),
-                         LY_ESYS);
+                LOGERR(ctx, LY_ESYS, "stat() failed for \"%s\" (%s).", new_dir, strerror(errno)); free(new_dir),
+                LY_ESYS);
         LY_CHECK_ERR_RET(!S_ISDIR(st.st_mode),
-                         LOGERR(ctx, LY_ESYS, "Given search directory \"%s\" is not a directory.", new_dir); free(new_dir),
-                         LY_EINVAL);
+                LOGERR(ctx, LY_ESYS, "Given search directory \"%s\" is not a directory.", new_dir); free(new_dir),
+                LY_EINVAL);
         /* avoid path duplication */
         for (uint32_t u = 0; u < ctx->search_paths.count; ++u) {
             if (!strcmp(new_dir, ctx->search_paths.objs[u])) {
@@ -229,7 +229,7 @@
                 rc = LY_SUCCESS;
             }
         }
-        if (*dir && rc == LY_SUCCESS) {
+        if (*dir && (rc == LY_SUCCESS)) {
             rc = ly_ctx_set_searchdir(ctx, dir);
             if (rc == LY_EEXIST) {
                 /* ignore duplication */
@@ -253,7 +253,7 @@
     for (i = 0; i < ((options & LY_CTX_NOYANGLIBRARY) ? (LY_INTERNAL_MODS_COUNT - 2) : LY_INTERNAL_MODS_COUNT); i++) {
         ly_in_memory(in, internal_modules[i].data);
         LY_CHECK_GOTO(rc = lys_create_module(ctx, in, internal_modules[i].format, internal_modules[i].implemented,
-                                             NULL, NULL, &module), error);
+                NULL, NULL, &module), error);
     }
 
     ly_in_free(in, 0);
@@ -358,7 +358,7 @@
     for ( ; *index < ctx->list.count; ++(*index)) {
         mod = ctx->list.objs[*index];
         value = *(const char **)(((int8_t *)(mod)) + key_offset);
-        if ((!key_size && !strcmp(key, value)) || (key_size && !strncmp(key, value, key_size) && value[key_size] == '\0')) {
+        if ((!key_size && !strcmp(key, value)) || (key_size && !strncmp(key, value, key_size) && (value[key_size] == '\0'))) {
             /* increment index for the next run */
             ++(*index);
             return mod;
@@ -565,7 +565,7 @@
     /* compile */
     oper = output ? LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT;
     ret = ly_path_compile(ctx, NULL, ctx_node, exp, LY_PATH_LREF_FALSE, oper, LY_PATH_TARGET_MANY,
-                          LY_PREF_JSON, NULL, &p);
+            LY_PREF_JSON, NULL, &p);
     LY_CHECK_GOTO(ret, cleanup);
 
     /* get last node */
@@ -762,7 +762,7 @@
 
         /* conformance-type */
         LY_CHECK_GOTO(ret = lyd_new_term(cont, NULL, "conformance-type", mod->implemented ? "implement" : "import",
-                                         NULL), error);
+                NULL), error);
 
         /* submodule list */
         LY_CHECK_GOTO(ret = ylib_submodules(cont, mod, 0), error);
diff --git a/src/diff.c b/src/diff.c
index dff6acb..7e7782d 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -103,7 +103,7 @@
 
     /* duplicate the subtree (and connect to the diff if possible) */
     LY_CHECK_RET(lyd_dup_single(node, (struct lyd_node_inner *)diff_parent,
-                                LYD_DUP_RECURSIVE | LYD_DUP_NO_META | LYD_DUP_WITH_PARENTS, &dup));
+            LYD_DUP_RECURSIVE | LYD_DUP_NO_META | LYD_DUP_WITH_PARENTS, &dup));
 
     /* find the first duplicated parent */
     if (!diff_parent) {
@@ -293,9 +293,9 @@
      */
 
     /* orig-default */
-    if ((options & LYD_DIFF_DEFAULTS) && (schema->nodetype == LYS_LEAFLIST)
-            && ((*op == LYD_DIFF_OP_REPLACE) || (*op == LYD_DIFF_OP_NONE))
-            && ((first->flags & LYD_DEFAULT) != (second->flags & LYD_DEFAULT))) {
+    if ((options & LYD_DIFF_DEFAULTS) && (schema->nodetype == LYS_LEAFLIST) &&
+            ((*op == LYD_DIFF_OP_REPLACE) || (*op == LYD_DIFF_OP_NONE)) &&
+            ((first->flags & LYD_DEFAULT) != (second->flags & LYD_DEFAULT))) {
         if (first->flags & LYD_DEFAULT) {
             *orig_default = "true";
         } else {
@@ -353,7 +353,7 @@
     if (*op == LYD_DIFF_OP_CREATE) {
         /* insert the instance */
         LY_ARRAY_RESIZE_ERR_RET(schema->module->ctx, userord_item->inst, LY_ARRAY_COUNT(userord_item->inst) + 1,
-                                ; , LY_EMEM);
+                ; , LY_EMEM);
         if (second_pos < LY_ARRAY_COUNT(userord_item->inst)) {
             memmove(userord_item->inst + second_pos + 1, userord_item->inst + second_pos,
                     (LY_ARRAY_COUNT(userord_item->inst) - second_pos) * sizeof *userord_item->inst);
@@ -454,9 +454,9 @@
      */
 
     /* orig-default */
-    if ((options & LYD_DIFF_DEFAULTS) && (schema->nodetype & LYD_NODE_TERM)
-            && ((*op == LYD_DIFF_OP_REPLACE) || (*op == LYD_DIFF_OP_NONE))
-            && ((first->flags & LYD_DEFAULT) != (second->flags & LYD_DEFAULT))) {
+    if ((options & LYD_DIFF_DEFAULTS) && (schema->nodetype & LYD_NODE_TERM) &&
+            ((*op == LYD_DIFF_OP_REPLACE) || (*op == LYD_DIFF_OP_NONE)) &&
+            ((first->flags & LYD_DEFAULT) != (second->flags & LYD_DEFAULT))) {
         if (first->flags & LYD_DEFAULT) {
             *orig_default = "true";
         } else {
@@ -557,7 +557,7 @@
 
             /* get all the attributes */
             LY_CHECK_GOTO(lyd_diff_userord_attrs(iter_first, match_second, options, &userord, &op, &orig_default,
-                                                 &value, &orig_value, &key, &orig_key), cleanup);
+                    &value, &orig_value, &key, &orig_key), cleanup);
 
             /* there must be changes, it is deleted */
             assert(op == LYD_DIFF_OP_DELETE);
@@ -592,7 +592,7 @@
         /* check descendants, if any, recursively */
         if (match_second) {
             LY_CHECK_GOTO(lyd_diff_siblings_r(lyd_child_no_keys(iter_first), lyd_child_no_keys(match_second), options,
-                                              0, diff), cleanup);
+                    0, diff), cleanup);
         }
 
         if (nosiblings) {
@@ -627,7 +627,7 @@
         if (lysc_is_userordered(iter_second->schema)) {
             /* get all the attributes */
             ret = lyd_diff_userord_attrs(match_first, iter_second, options, &userord, &op, &orig_default,
-                                         &value, &orig_value, &key, &orig_key);
+                    &value, &orig_value, &key, &orig_key);
 
             /* add into diff if there are any changes */
             if (!ret) {
@@ -788,7 +788,7 @@
         /* simply insert into parent, no other children */
         if (key_or_value) {
             LOGERR(LYD_CTX(new_node), LY_EINVAL, "Node \"%s\" instance to insert next to not found.",
-                   new_node->schema->name);
+                    new_node->schema->name);
             return LY_EINVAL;
         }
         return lyd_insert_child(parent_node, new_node);
@@ -806,7 +806,7 @@
         ret = lyd_find_sibling_val(*first_node, new_node->schema, key_or_value, 0, &anchor);
         if (ret == LY_ENOTFOUND) {
             LOGERR(LYD_CTX(new_node), LY_EINVAL, "Node \"%s\" instance to insert next to not found.",
-                   new_node->schema->name);
+                    new_node->schema->name);
             return LY_EINVAL;
         } else if (ret) {
             return ret;
@@ -1199,15 +1199,15 @@
             sleaf = NULL;
         }
 
-        if (sleaf && sleaf->dflt
-                && !sleaf->dflt->realtype->plugin->compare(sleaf->dflt, &((struct lyd_node_term *)src_diff)->value)) {
+        if (sleaf && sleaf->dflt &&
+                !sleaf->dflt->realtype->plugin->compare(sleaf->dflt, &((struct lyd_node_term *)src_diff)->value)) {
             /* we deleted it, so a default value was in-use, and it matches the created value -> operation NONE */
             LY_CHECK_RET(lyd_diff_change_op(diff_match, LYD_DIFF_OP_NONE));
 
             if (diff_match->schema->nodetype & LYD_NODE_TERM) {
                 /* add orig-dflt metadata */
                 LY_CHECK_RET(lyd_new_meta(diff_match, NULL, "yang:orig-default",
-                                          diff_match->flags & LYD_DEFAULT ? "true" : "false", NULL));
+                        diff_match->flags & LYD_DEFAULT ? "true" : "false", NULL));
             }
         } else if (!lyd_compare_single(diff_match, src_diff, 0)) {
             /* deleted + created -> operation NONE */
@@ -1216,7 +1216,7 @@
             if (diff_match->schema->nodetype & LYD_NODE_TERM) {
                 /* add orig-dflt metadata */
                 LY_CHECK_RET(lyd_new_meta(diff_match, NULL, "yang:orig-default",
-                                          diff_match->flags & LYD_DEFAULT ? "true" : "false", NULL));
+                        diff_match->flags & LYD_DEFAULT ? "true" : "false", NULL));
             }
         } else {
             assert(sleaf);
@@ -1275,7 +1275,7 @@
         if (diff_match->schema->nodetype & LYD_NODE_TERM) {
             /* add orig-default meta because it is expected */
             LY_CHECK_RET(lyd_new_meta(diff_match, NULL, "yang:orig-default",
-                                      diff_match->flags & LYD_DEFAULT ? "true" : "false", NULL));
+                    diff_match->flags & LYD_DEFAULT ? "true" : "false", NULL));
         } else {
             /* keep operation for all descendants (for now) */
             LY_LIST_FOR(lyd_child_no_keys(diff_match), child) {
diff --git a/src/diff.h b/src/diff.h
index dbfa37c..b50e91b 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -37,7 +37,7 @@
     LYD_DIFF_OP_CREATE,    /**< Subtree created. */
     LYD_DIFF_OP_DELETE,    /**< Subtree deleted. */
     LYD_DIFF_OP_REPLACE,   /**< Node value changed or (leaf-)list instance moved. */
-    LYD_DIFF_OP_NONE,      /**< No change of an existing inner node or default flag change of a term node. */
+    LYD_DIFF_OP_NONE       /**< No change of an existing inner node or default flag change of a term node. */
 };
 
 /**
diff --git a/src/hash_table.c b/src/hash_table.c
index cc6fbd0..1aef476 100644
--- a/src/hash_table.c
+++ b/src/hash_table.c
@@ -14,14 +14,14 @@
 
 #include "hash_table.h"
 
-#include <string.h>
+#include <assert.h>
+#include <pthread.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <pthread.h>
-#include <assert.h>
+#include <string.h>
 
-#include "compat.h"
 #include "common.h"
+#include "compat.h"
 #include "dict.h"
 #include "log.h"
 
@@ -693,7 +693,7 @@
             /* enlarge */
             ret = lyht_resize(ht, 1);
             /* if hash_table was resized, we need to find new matching value */
-            if (ret == LY_SUCCESS && match_p) {
+            if ((ret == LY_SUCCESS) && match_p) {
                 lyht_find(ht, val_p, hash, match_p);
             }
 
diff --git a/src/json.c b/src/json.c
index 0a4b59d..450e1d6 100644
--- a/src/json.c
+++ b/src/json.c
@@ -104,22 +104,22 @@
 {
     if (jsonctx->status.count == 1) {
         /* top level value (JSON-text), ws expected */
-        if (*jsonctx->in->current == '\0' || is_jsonws(*jsonctx->in->current)) {
+        if ((*jsonctx->in->current == '\0') || is_jsonws(*jsonctx->in->current)) {
             return LY_SUCCESS;
         }
     } else if (lyjson_ctx_status(jsonctx, 1) == LYJSON_OBJECT) {
         LY_CHECK_RET(skip_ws(jsonctx));
-        if (*jsonctx->in->current == ',' || *jsonctx->in->current == '}') {
+        if ((*jsonctx->in->current == ',') || (*jsonctx->in->current == '}')) {
             return LY_SUCCESS;
         }
     } else if (lyjson_ctx_status(jsonctx, 1) == LYJSON_ARRAY) {
         LY_CHECK_RET(skip_ws(jsonctx));
-        if (*jsonctx->in->current == ',' || *jsonctx->in->current == ']') {
+        if ((*jsonctx->in->current == ',') || (*jsonctx->in->current == ']')) {
             return LY_SUCCESS;
         }
     } else {
         LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LYVE_SYNTAX,
-               "Unexpected character \"%c\" after JSON %s.", *jsonctx->in->current, lyjson_token2str(lyjson_ctx_status(jsonctx, 0)));
+                "Unexpected character \"%c\" after JSON %s.", *jsonctx->in->current, lyjson_token2str(lyjson_ctx_status(jsonctx, 0)));
     }
 
     return LY_EVALID;
@@ -232,16 +232,16 @@
             default:
                 /* invalid escape sequence */
                 LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LYVE_SYNTAX,
-                       "Invalid character escape sequence \\%c.", in[offset]);
+                        "Invalid character escape sequence \\%c.", in[offset]);
                 goto error;
 
             }
 
             offset += i;   /* add read escaped characters */
             LY_CHECK_ERR_GOTO(ly_pututf8(&buf[len], value, &u),
-                              LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LYVE_SYNTAX,
-                                     "Invalid character reference \"%.*s\" (0x%08x).", offset - slash, &in[slash], value),
-                              error);
+                    LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LYVE_SYNTAX,
+                    "Invalid character reference \"%.*s\" (0x%08x).", offset - slash, &in[slash], value),
+                    error);
             len += u;      /* update number of bytes in buffer */
             in += offset;  /* move the input by the processed bytes stored in the buffer ... */
             offset = 0;    /* ... and reset the offset index for future moving data into buffer */
@@ -269,12 +269,12 @@
             size_t code_len = 0;
 
             LY_CHECK_ERR_GOTO(ly_getutf8(&c, &code, &code_len),
-                              LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LY_VCODE_INCHAR, in[offset]), error);
+                    LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LY_VCODE_INCHAR, in[offset]), error);
 
             LY_CHECK_ERR_GOTO(!is_jsonstrchar(code),
-                              LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LYVE_SYNTAX,
-                                     "Invalid character in JSON string \"%.*s\" (0x%08x).", &in[offset] - start + code_len, start, code),
-                              error);
+                    LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LYVE_SYNTAX,
+                    "Invalid character in JSON string \"%.*s\" (0x%08x).", &in[offset] - start + code_len, start, code),
+                    error);
 
             /* character is ok, continue */
             offset += code_len;
@@ -382,7 +382,7 @@
         e_val = strtol(e_ptr, &ptr, 10);
         if (errno) {
             LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LYVE_SEMANTICS,
-                   "Exponent out-of-bounds in a JSON Number value (%.*s).", offset - minus - (e_ptr - in), e_ptr);
+                    "Exponent out-of-bounds in a JSON Number value (%.*s).", offset - minus - (e_ptr - in), e_ptr);
             return LY_EVALID;
         }
 
@@ -484,7 +484,7 @@
 {
     if (*jsonctx->in->current != '"') {
         LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LY_VCODE_INSTREXP, LY_VCODE_INSTREXP_len(jsonctx->in->current),
-               jsonctx->in->current, "a JSON object's member");
+                jsonctx->in->current, "a JSON object's member");
         return LY_EVALID;
     }
     ly_in_skip(jsonctx->in, 1);
@@ -553,25 +553,25 @@
 static LY_ERR
 lyjson_value(struct lyjson_ctx *jsonctx)
 {
-    if (jsonctx->status.count && lyjson_ctx_status(jsonctx, 0) == LYJSON_END) {
+    if (jsonctx->status.count && (lyjson_ctx_status(jsonctx, 0) == LYJSON_END)) {
         return LY_SUCCESS;
     }
 
-    if (*jsonctx->in->current == 'f' && !strncmp(jsonctx->in->current, "false", 5)) {
+    if ((*jsonctx->in->current == 'f') && !strncmp(jsonctx->in->current, "false", 5)) {
         /* false */
         lyjson_ctx_set_value(jsonctx, jsonctx->in->current, 5, 0);
         ly_in_skip(jsonctx->in, 5);
         JSON_PUSH_STATUS_RET(jsonctx, LYJSON_FALSE);
         LY_CHECK_RET(lyjson_check_next(jsonctx));
 
-    } else if (*jsonctx->in->current == 't' && !strncmp(jsonctx->in->current, "true", 4)) {
+    } else if ((*jsonctx->in->current == 't') && !strncmp(jsonctx->in->current, "true", 4)) {
         /* true */
         lyjson_ctx_set_value(jsonctx, jsonctx->in->current, 4, 0);
         ly_in_skip(jsonctx->in, 4);
         JSON_PUSH_STATUS_RET(jsonctx, LYJSON_TRUE);
         LY_CHECK_RET(lyjson_check_next(jsonctx));
 
-    } else if (*jsonctx->in->current == 'n' && !strncmp(jsonctx->in->current, "null", 4)) {
+    } else if ((*jsonctx->in->current == 'n') && !strncmp(jsonctx->in->current, "null", 4)) {
         /* none */
         lyjson_ctx_set_value(jsonctx, jsonctx->in->current, 0, 0);
         ly_in_skip(jsonctx->in, 4);
@@ -593,14 +593,14 @@
         ly_in_skip(jsonctx->in, 1);
         LY_CHECK_RET(lyjson_object(jsonctx));
 
-    } else if (*jsonctx->in->current == '-' || (*jsonctx->in->current >= '0' && *jsonctx->in->current <= '9')) {
+    } else if ((*jsonctx->in->current == '-') || ((*jsonctx->in->current >= '0') && (*jsonctx->in->current <= '9'))) {
         /* number */
         LY_CHECK_RET(lyjson_number(jsonctx));
 
     } else {
         /* unexpected value */
         LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LY_VCODE_INSTREXP, LY_VCODE_INSTREXP_len(jsonctx->in->current),
-               jsonctx->in->current, "a JSON value");
+                jsonctx->in->current, "a JSON value");
         return LY_EVALID;
     }
 
@@ -633,7 +633,7 @@
 
     ret = lyjson_value(jsonctx);
 
-    if (jsonctx->status.count > 1 && lyjson_ctx_status(jsonctx, 0) == LYJSON_END) {
+    if ((jsonctx->status.count > 1) && (lyjson_ctx_status(jsonctx, 0) == LYJSON_END)) {
         LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LY_VCODE_EOF);
         ret = LY_EVALID;
     }
@@ -688,7 +688,7 @@
 
     prev = lyjson_ctx_status(jsonctx, 0);
 
-    if (prev == LYJSON_OBJECT || prev == LYJSON_ARRAY) {
+    if ((prev == LYJSON_OBJECT) || (prev == LYJSON_ARRAY)) {
         /* get value for the object's member OR the first value in the array */
         ret = lyjson_value(jsonctx);
         goto result;
@@ -706,7 +706,7 @@
     if (toplevel && !jsonctx->status.count) {
         /* EOF expected, but there are some data after the top level token */
         LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LYVE_SYNTAX,
-               "Expecting end-of-input, but some data follows the top level JSON value.");
+                "Expecting end-of-input, but some data follows the top level JSON value.");
         return LY_EVALID;
     }
 
@@ -730,24 +730,24 @@
             /* ... array - get another complete value */
             ret = lyjson_value(jsonctx);
         }
-    } else if ((prev == LYJSON_OBJECT && *jsonctx->in->current == '}') || (prev == LYJSON_ARRAY && *jsonctx->in->current == ']')) {
+    } else if (((prev == LYJSON_OBJECT) && (*jsonctx->in->current == '}')) || ((prev == LYJSON_ARRAY) && (*jsonctx->in->current == ']'))) {
         ly_in_skip(jsonctx->in, 1);
         JSON_POP_STATUS_RET(jsonctx);
         JSON_PUSH_STATUS_RET(jsonctx, prev + 1);
     } else {
         /* unexpected value */
         LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LY_VCODE_INSTREXP, LY_VCODE_INSTREXP_len(jsonctx->in->current),
-               jsonctx->in->current, prev == LYJSON_ARRAY ? "another JSON value in array" : "another JSON object's member");
+                jsonctx->in->current, prev == LYJSON_ARRAY ? "another JSON value in array" : "another JSON object's member");
         return LY_EVALID;
     }
 
 result:
-    if (ret == LY_SUCCESS && jsonctx->status.count > 1 && lyjson_ctx_status(jsonctx, 0) == LYJSON_END) {
+    if ((ret == LY_SUCCESS) && (jsonctx->status.count > 1) && (lyjson_ctx_status(jsonctx, 0) == LYJSON_END)) {
         LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LY_VCODE_EOF);
         ret = LY_EVALID;
     }
 
-    if (ret == LY_SUCCESS && status) {
+    if ((ret == LY_SUCCESS) && status) {
         *status = lyjson_ctx_status(jsonctx, 0);
     }
 
diff --git a/src/parser.c b/src/parser.c
index c915fc1..6cc0824 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -190,7 +190,7 @@
 
     fd = open(fp, O_RDONLY);
     LY_CHECK_ERR_RET(fd == -1, LOGERR(NULL, LY_ESYS, "Failed to open file \"%s\" (%s).", fp, strerror(errno)); free(fp),
-                     LY_ESYS);
+            LY_ESYS);
 
     LY_CHECK_ERR_RET(ret = ly_in_new_fd(fd, in), free(fp), ret);
 
@@ -243,6 +243,7 @@
 lys_parser_fill_filepath(struct ly_ctx *ctx, struct ly_in *in, const char **filepath)
 {
     char path[PATH_MAX];
+
 #ifndef __APPLE__
     char proc_path[32];
     int len;
@@ -378,26 +379,26 @@
         if (lydctx->int_opts & LYD_INTOPT_RPC) {
             if (lydctx->op_node) {
                 LOGVAL(lydctx->data_ctx->ctx, LY_VLOG_LYSC, snode, LYVE_DATA, "Unexpected %s element \"%s\", %s \"%s\" already parsed.",
-                       lys_nodetype2str(snode->nodetype), snode->name,
-                       lys_nodetype2str(lydctx->op_node->schema->nodetype), lydctx->op_node->schema->name);
+                        lys_nodetype2str(snode->nodetype), snode->name,
+                        lys_nodetype2str(lydctx->op_node->schema->nodetype), lydctx->op_node->schema->name);
                 return LY_EVALID;
             }
         } else {
             LOGVAL(lydctx->data_ctx->ctx, LY_VLOG_LYSC, snode, LYVE_DATA, "Unexpected %s element \"%s\".",
-                   lys_nodetype2str(snode->nodetype), snode->name);
+                    lys_nodetype2str(snode->nodetype), snode->name);
             return LY_EVALID;
         }
     } else if (snode->nodetype == LYS_NOTIF) {
         if (lydctx->int_opts & LYD_INTOPT_NOTIF) {
             if (lydctx->op_node) {
                 LOGVAL(lydctx->data_ctx->ctx, LY_VLOG_LYSC, snode, LYVE_DATA, "Unexpected %s element \"%s\", %s \"%s\" already parsed.",
-                       lys_nodetype2str(snode->nodetype), snode->name,
-                       lys_nodetype2str(lydctx->op_node->schema->nodetype), lydctx->op_node->schema->name);
+                        lys_nodetype2str(snode->nodetype), snode->name,
+                        lys_nodetype2str(lydctx->op_node->schema->nodetype), lydctx->op_node->schema->name);
                 return LY_EVALID;
             }
         } else {
             LOGVAL(lydctx->data_ctx->ctx, LY_VLOG_LYSC, snode, LYVE_DATA, "Unexpected %s element \"%s\".",
-                   lys_nodetype2str(snode->nodetype), snode->name);
+                    lys_nodetype2str(snode->nodetype), snode->name);
             return LY_EVALID;
         }
     }
diff --git a/src/parser_json.c b/src/parser_json.c
index 9d0b801..5d36915 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -207,7 +207,7 @@
         }
     } else {
         LOGVAL(lydctx->jsonctx->ctx, LY_VLOG_LYD, parent, LYVE_SYNTAX_JSON, "Top-level JSON object member \"%.*s\" must be namespace-qualified.",
-               is_attr ? name_len + 1 : name_len, is_attr ? name - 1 : name);
+                is_attr ? name_len + 1 : name_len, is_attr ? name - 1 : name);
         return LY_EVALID;
     }
     if (!mod) {
@@ -231,7 +231,7 @@
         if (!*snode_p) {
             if (lydctx->parse_options & LYD_PARSE_STRICT) {
                 LOGVAL(lydctx->jsonctx->ctx, LY_VLOG_LYD, parent, LYVE_REFERENCE, "Node \"%.*s\" not found in the \"%s\" module.",
-                    name_len, name, mod->name);
+                        name_len, name, mod->name);
                 return LY_EVALID;
             } else if (!(lydctx->parse_options & LYD_PARSE_OPAQ)) {
                 /* skip element with children */
@@ -454,7 +454,7 @@
         *type_hint_p = LYD_VALHINT_STRING | LYD_VALHINT_NUM64;
     } else if (*status_p == LYJSON_NUMBER) {
         *type_hint_p = LYD_VALHINT_DECNUM;
-    } else if (*status_p == LYJSON_FALSE || *status_p == LYJSON_TRUE) {
+    } else if ((*status_p == LYJSON_FALSE) || (*status_p == LYJSON_TRUE)) {
         *type_hint_p = LYD_VALHINT_BOOLEAN;
     } else if (*status_p == LYJSON_NULL) {
         *type_hint_p = 0;
@@ -561,7 +561,7 @@
         size_t name_len, prefix_len;
         const struct lysc_node *snode;
 
-        if (attr->schema || meta_container->name[0] != '@') {
+        if (attr->schema || (meta_container->name[0] != '@')) {
             /* not an opaq metadata node */
             continue;
         }
@@ -585,7 +585,7 @@
 
                 if (((struct lyd_node_opaq *)node)->hints & LYD_NODEHINT_LIST) {
                     LOGVAL(lydctx->jsonctx->ctx, LY_VLOG_LYD, node, LYVE_SYNTAX,
-                           "Metadata container references a sibling list node %s.", ((struct lyd_node_opaq *)node)->name);
+                            "Metadata container references a sibling list node %s.", ((struct lyd_node_opaq *)node)->name);
                     ret = LY_EVALID;
                     goto cleanup;
                 }
@@ -641,13 +641,13 @@
                     mod = ly_ctx_get_module_implemented(lydctx->jsonctx->ctx, meta->prefix.id);
                     if (mod) {
                         ret = lyd_parser_create_meta((struct lyd_ctx *)lydctx, node, NULL, mod,
-                                                     meta->name, strlen(meta->name), meta->value, ly_strlen(meta->value),
-                                                     &dynamic, LY_PREF_JSON, NULL, meta->hints);
+                                meta->name, strlen(meta->name), meta->value, ly_strlen(meta->value),
+                                &dynamic, LY_PREF_JSON, NULL, meta->hints);
                         LY_CHECK_GOTO(ret, cleanup);
                     } else if (lydctx->parse_options & LYD_PARSE_STRICT) {
                         LOGVAL(lydctx->jsonctx->ctx, LY_VLOG_LYD, node, LYVE_REFERENCE,
-                               "Unknown (or not implemented) YANG module \"%s\" for metadata \"%s%s%s\".",
-                               meta->prefix.id, meta->prefix.id, ly_strlen(meta->prefix.id) ? ":" : "", meta->name);
+                                "Unknown (or not implemented) YANG module \"%s\" for metadata \"%s%s%s\".",
+                                meta->prefix.id, meta->prefix.id, ly_strlen(meta->prefix.id) ? ":" : "", meta->name);
                         ret = LY_EVALID;
                         goto cleanup;
                     }
@@ -664,11 +664,11 @@
             /* there is no corresponding data node for the metadata */
             if (instance > 1) {
                 LOGVAL(lydctx->jsonctx->ctx, LY_VLOG_LYD, *first_p ? (*first_p)->parent : NULL, LYVE_REFERENCE,
-                       "Missing %d%s JSON data instance to be coupled with %s metadata.", instance,
-                       instance == 2 ? "nd" : (instance == 3 ? "rd" : "th"), meta_container->name);
+                        "Missing %d%s JSON data instance to be coupled with %s metadata.", instance,
+                        instance == 2 ? "nd" : (instance == 3 ? "rd" : "th"), meta_container->name);
             } else {
                 LOGVAL(lydctx->jsonctx->ctx, LY_VLOG_LYD, *first_p ? (*first_p)->parent : NULL, LYVE_REFERENCE,
-                       "Missing JSON data instance to be coupled with %s metadata.", meta_container->name);
+                        "Missing JSON data instance to be coupled with %s metadata.", meta_container->name);
             }
             ret = LY_EVALID;
         } else {
@@ -743,10 +743,10 @@
         }
         LY_CHECK_GOTO(status != LYJSON_OBJECT && status != LYJSON_NULL, representation_error);
 
-        if (!node || node->schema != prev->schema) {
+        if (!node || (node->schema != prev->schema)) {
             LOGVAL(lydctx->jsonctx->ctx, LY_VLOG_LYD, prev->parent, LYVE_REFERENCE,
-                   "Missing JSON data instance no. %u of %s:%s to be coupled with metadata.",
-                   instance, prev->schema->module->name, prev->schema->name);
+                    "Missing JSON data instance no. %u of %s:%s to be coupled with metadata.",
+                    instance, prev->schema->module->name, prev->schema->name);
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -785,14 +785,14 @@
         lydjson_parse_name(lydctx->jsonctx->value, lydctx->jsonctx->value_len, &name, &name_len, &prefix, &prefix_len, &is_attr);
         if (!prefix) {
             LOGVAL(ctx, LY_VLOG_LYD, (void *)node, LYVE_SYNTAX_JSON,
-                   "Metadata in JSON must be namespace-qualified, missing prefix for \"%.*s\".",
-                   lydctx->jsonctx->value_len, lydctx->jsonctx->value);
+                    "Metadata in JSON must be namespace-qualified, missing prefix for \"%.*s\".",
+                    lydctx->jsonctx->value_len, lydctx->jsonctx->value);
             ret = LY_EVALID;
             goto cleanup;
         } else if (is_attr) {
             LOGVAL(ctx, LY_VLOG_LYD, (void *)node, LYVE_SYNTAX_JSON,
-                   "Invalid format of the Metadata identifier in JSON, unexpected '@' in \"%.*s\"",
-                   lydctx->jsonctx->value_len, lydctx->jsonctx->value);
+                    "Invalid format of the Metadata identifier in JSON, unexpected '@' in \"%.*s\"",
+                    lydctx->jsonctx->value_len, lydctx->jsonctx->value);
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -802,8 +802,8 @@
         if (!mod) {
             if (lydctx->parse_options & LYD_PARSE_STRICT) {
                 LOGVAL(ctx, LY_VLOG_LYD, (void *)node, LYVE_REFERENCE,
-                       "Prefix \"%.*s\" of the metadata \"%.*s\" does not match any module in the context.",
-                       prefix_len, prefix, name_len, name);
+                        "Prefix \"%.*s\" of the metadata \"%.*s\" does not match any module in the context.",
+                        prefix_len, prefix, name_len, name);
                 ret = LY_EVALID;
                 goto cleanup;
             }
@@ -825,8 +825,8 @@
             /* create metadata */
             meta = NULL;
             ret = lyd_parser_create_meta((struct lyd_ctx *)lydctx, node, &meta, mod, name, name_len, lydctx->jsonctx->value,
-                                         lydctx->jsonctx->value_len, &lydctx->jsonctx->dynamic, LY_PREF_JSON, NULL,
-                                         LYD_HINT_DATA);
+                    lydctx->jsonctx->value_len, &lydctx->jsonctx->dynamic, LY_PREF_JSON, NULL,
+                    LYD_HINT_DATA);
             LY_CHECK_GOTO(ret, cleanup);
 
             /* add/correct flags */
@@ -844,7 +844,7 @@
 
             /* attr2 is always changed to the created attribute */
             ret = lyd_create_attr(node, NULL, lydctx->jsonctx->ctx, name, name_len, lydctx->jsonctx->value, lydctx->jsonctx->value_len,
-                                  &lydctx->jsonctx->dynamic, LYD_JSON, 0, val_prefs, prefix, prefix_len, module_name, module_name_len);
+                    &lydctx->jsonctx->dynamic, LYD_JSON, 0, val_prefs, prefix, prefix_len, module_name, module_name_len);
             LY_CHECK_GOTO(ret, cleanup);
         }
         /* next member */
@@ -869,9 +869,9 @@
 
 representation_error:
     LOGVAL(ctx, LY_VLOG_LYD, (void *)node, LYVE_SYNTAX_JSON,
-           "The attribute(s) of %s \"%s\" is expected to be represented as JSON %s, but input data contains @%s/%s.",
-           lys_nodetype2str(nodetype), node->schema ? node->schema->name : ((struct lyd_node_opaq *)node)->name,
-           expected, lyjson_token2str(status), in_parent ? "" : "name");
+            "The attribute(s) of %s \"%s\" is expected to be represented as JSON %s, but input data contains @%s/%s.",
+            lys_nodetype2str(nodetype), node->schema ? node->schema->name : ((struct lyd_node_opaq *)node)->name,
+            expected, lyjson_token2str(status), in_parent ? "" : "name");
 
     return LY_EVALID;
 }
@@ -936,7 +936,7 @@
     ly_bool dynamic = 0;
     uint32_t type_hint = 0;
 
-    if (*status_inner_p != LYJSON_OBJECT && *status_inner_p != LYJSON_OBJECT_EMPTY) {
+    if ((*status_inner_p != LYJSON_OBJECT) && (*status_inner_p != LYJSON_OBJECT_EMPTY)) {
         /* prepare for creating opaq node with a value */
         value = lydctx->jsonctx->value;
         value_len = lydctx->jsonctx->value_len;
@@ -960,18 +960,18 @@
     }
     LY_CHECK_RET(ret);
 
-    if (*status_p == LYJSON_OBJECT || *status_p == LYJSON_OBJECT_EMPTY) {
+    if ((*status_p == LYJSON_OBJECT) || (*status_p == LYJSON_OBJECT_EMPTY)) {
         /* process children */
         while (*status_p != LYJSON_OBJECT_CLOSED && *status_p != LYJSON_OBJECT_EMPTY) {
             LY_CHECK_RET(lydjson_subtree_r(lydctx, (struct lyd_node_inner *)(*node_p), lyd_node_children_p(*node_p)));
             *status_p = lyjson_ctx_status(lydctx->jsonctx, 0);
         }
-    } else if (*status_p == LYJSON_ARRAY || *status_p == LYJSON_ARRAY_EMPTY) {
+    } else if ((*status_p == LYJSON_ARRAY) || (*status_p == LYJSON_ARRAY_EMPTY)) {
         /* process another instance of the same node */
         /* but first mark the node to be expected a list or a leaf-list */
         ((struct lyd_node_opaq *)*node_p)->hints |= LYD_NODEHINT_LIST | LYD_NODEHINT_LEAFLIST;
 
-        if (*status_inner_p == LYJSON_OBJECT || *status_inner_p == LYJSON_OBJECT_EMPTY) {
+        if ((*status_inner_p == LYJSON_OBJECT) || (*status_inner_p == LYJSON_OBJECT_EMPTY)) {
             /* but first process children of the object in the array */
             while (*status_inner_p != LYJSON_OBJECT_CLOSED && *status_inner_p != LYJSON_OBJECT_EMPTY) {
                 LY_CHECK_RET(lydjson_subtree_r(lydctx, (struct lyd_node_inner *)(*node_p), lyd_node_children_p(*node_p)));
@@ -1056,7 +1056,7 @@
         lydctx->parse_options |= LYD_PARSE_OPAQ;
 
         ret = lydjson_parse_opaq(lydctx, prefix ? prefix - 1 : name - 1, prefix ? prefix_len + name_len + 2 : name_len + 1,
-                                 NULL, 0, parent, status_p, status_inner == LYJSON_ERROR ? status_p : &status_inner, first_p, node_p);
+                NULL, 0, parent, status_p, status_inner == LYJSON_ERROR ? status_p : &status_inner, first_p, node_p);
 
         /* restore the parser options */
         lydctx->parse_options = prev_opts;
@@ -1101,8 +1101,8 @@
         if (snode->nodetype & LYD_NODE_TERM) {
             /* create terminal node */
             ret = lyd_parser_create_term((struct lyd_ctx *)lydctx, snode, lydctx->jsonctx->value,
-                                         lydctx->jsonctx->value_len, &lydctx->jsonctx->dynamic, LY_PREF_JSON, NULL,
-                                         type_hints, node);
+                    lydctx->jsonctx->value_len, &lydctx->jsonctx->dynamic, LY_PREF_JSON, NULL,
+                    type_hints, node);
             LY_CHECK_RET(ret);
 
             /* move JSON parser */
@@ -1139,8 +1139,8 @@
 
                 /* add any missing default children */
                 ret = lyd_new_implicit_r(*node, lyd_node_children_p(*node), NULL, NULL, &lydctx->unres_node_type,
-                                         &lydctx->when_check, (lydctx->validate_options & LYD_VALIDATE_NO_STATE)
-                                            ? LYD_IMPLICIT_NO_STATE : 0, NULL);
+                        &lydctx->when_check, (lydctx->validate_options & LYD_VALIDATE_NO_STATE) ?
+                        LYD_IMPLICIT_NO_STATE : 0, NULL);
                 LY_CHECK_RET(ret);
             }
 
@@ -1177,7 +1177,7 @@
     } else if (ret == LY_ENOT) {
         /* parse it again as an opaq node */
         ret = lydjson_parse_opaq(lydctx, name, name_len, prefix, prefix_len, parent,
-                                 status, status, first_p, node);
+                status, status, first_p, node);
         LY_CHECK_RET(ret);
 
         if (snode->nodetype == LYS_LIST) {
@@ -1243,7 +1243,7 @@
             /* parent's metadata without a name - use the schema from the parent */
             if (!parent) {
                 LOGVAL(ctx, LY_VLOG_LYD, NULL, LYVE_SYNTAX_JSON,
-                       "Invalid metadata format - \"@\" can be used only inside anydata, container or list entries.");
+                        "Invalid metadata format - \"@\" can be used only inside anydata, container or list entries.");
                 ret = LY_EVALID;
                 goto cleanup;
             }
@@ -1251,7 +1251,7 @@
             snode = attr_node->schema;
         }
         ret = lydjson_parse_attribute(lydctx, attr_node, snode, name, name_len, prefix, prefix_len, parent, &status,
-                                      first_p, &node);
+                first_p, &node);
         LY_CHECK_GOTO(ret, cleanup);
     } else if (!snode) {
         /* parse as an opaq node */
@@ -1271,7 +1271,7 @@
         }
 
         ret = lydjson_parse_opaq(lydctx, name, name_len, prefix, prefix_len,
-                                 parent, &status, status_inner == LYJSON_ERROR ? &status : &status_inner, first_p, &node);
+                parent, &status, status_inner == LYJSON_ERROR ? &status : &status_inner, first_p, &node);
         LY_CHECK_GOTO(ret, cleanup);
     } else {
         /* parse as a standard lyd_node but it can still turn out to be an opaque node */
@@ -1301,7 +1301,7 @@
                 lydjson_maintain_children(parent, first_p, &node);
 
                 ret = lydjson_parse_instance(lydctx, parent, first_p, snode, name, name_len, prefix, prefix_len,
-                                             &status, &node);
+                        &status, &node);
                 if (ret == LY_EINVAL) {
                     goto representation_error;
                 } else if (ret) {
@@ -1357,8 +1357,8 @@
 
 representation_error:
     LOGVAL(ctx, LY_VLOG_LYD, parent, LYVE_SYNTAX_JSON,
-           "The %s \"%s\" is expected to be represented as JSON %s, but input data contains name/%s.",
-           lys_nodetype2str(snode->nodetype), snode->name, expected, lyjson_token2str(status));
+            "The %s \"%s\" is expected to be represented as JSON %s, but input data contains name/%s.",
+            lys_nodetype2str(snode->nodetype), snode->name, expected, lyjson_token2str(status));
 
     ret = LY_EVALID;
     goto cleanup;
@@ -1438,8 +1438,8 @@
 
 cleanup:
     /* there should be no unresolved types stored */
-    assert(!(parse_options & LYD_PARSE_ONLY) || (!lydctx->unres_node_type.count && !lydctx->unres_meta_type.count
-            && !lydctx->when_check.count));
+    assert(!(parse_options & LYD_PARSE_ONLY) || (!lydctx->unres_node_type.count && !lydctx->unres_meta_type.count &&
+            !lydctx->when_check.count));
 
     if (ret) {
         lyd_json_ctx_free((struct lyd_ctx *)lydctx);
@@ -1508,11 +1508,11 @@
 
     /* create notification envelope */
     ret = lyd_create_opaq(jsonctx->ctx, "notification", 12, "", 0, NULL, LYD_JSON, LYD_NODEHINT_ENVELOPE, NULL, NULL,
-                          0, "ietf-restconf", 13, envp_p);
+            0, "ietf-restconf", 13, envp_p);
     LY_CHECK_GOTO(ret, cleanup);
     /* create notification envelope */
     ret = lyd_create_opaq(jsonctx->ctx, "eventTime", 9, value, value_len, &dynamic, LYD_JSON, LYD_VALHINT_STRING, NULL,
-                          NULL, 0, "ietf-restconf", 13, &et);
+            NULL, 0, "ietf-restconf", 13, &et);
     LY_CHECK_GOTO(ret, cleanup);
     /* insert eventTime into notification */
     lyd_insert_node(*envp_p, NULL, et);
@@ -1567,9 +1567,9 @@
         LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_DATA, "Missing the \"notification\" node.");
         ret = LY_EVALID;
         goto cleanup;
-    } else if (lydctx->jsonctx->in->current[0] && lyjson_ctx_status(lydctx->jsonctx, 0) != LYJSON_OBJECT_CLOSED) {
+    } else if (lydctx->jsonctx->in->current[0] && (lyjson_ctx_status(lydctx->jsonctx, 0) != LYJSON_OBJECT_CLOSED)) {
         LOGVAL(ctx, LY_VLOG_LINE, &lydctx->jsonctx->line, LYVE_SYNTAX, "Unexpected sibling element of \"%s\".",
-               tree->schema->name);
+                tree->schema->name);
         ret = LY_EVALID;
         goto cleanup;
     }
@@ -1584,7 +1584,7 @@
             goto cleanup;
         } else if (status != LYJSON_OBJECT_CLOSED) {
             LOGVAL(ctx, LY_VLOG_LINE, &lydctx->jsonctx->line, LYVE_SYNTAX, "Unexpected sibling member \"%.*s\" of \"notification\".",
-                   lydctx->jsonctx->value_len, lydctx->jsonctx->value);
+                    lydctx->jsonctx->value_len, lydctx->jsonctx->value);
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -1652,7 +1652,7 @@
 
     /* create the object envelope */
     ret = lyd_create_opaq(jsonctx->ctx, object_id, strlen(object_id), "", 0, NULL, LYD_JSON, LYD_NODEHINT_ENVELOPE,
-                          NULL, NULL, 0, module_key, ly_strlen(module_key), envp_p);
+            NULL, NULL, 0, module_key, ly_strlen(module_key), envp_p);
     LY_CHECK_GOTO(ret, cleanup);
 
     if (parent) {
@@ -1675,7 +1675,7 @@
         return LY_EVALID;
     } else if (status != LYJSON_OBJECT_CLOSED) {
         LOGVAL(jsonctx->ctx, LY_VLOG_LINE, &jsonctx->line, LYVE_SYNTAX, "Unexpected sibling member \"%.*s\" of \"%s\".",
-               jsonctx->value_len, jsonctx->value, object_id);
+                jsonctx->value_len, jsonctx->value, object_id);
         return LY_EVALID;
     }
     return LY_SUCCESS;
@@ -1730,12 +1730,12 @@
     /* make sure we have parsed some operation */
     if (!lydctx->op_node) {
         LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_DATA, "Missing the %s node.",
-               act_e ? "action" : (rpc_e ? "rpc" : "rpc/action"));
+                act_e ? "action" : (rpc_e ? "rpc" : "rpc/action"));
         ret = LY_EVALID;
         goto cleanup;
-    } else if (lydctx->jsonctx->in->current[0] && lyjson_ctx_status(lydctx->jsonctx, 0) != LYJSON_OBJECT_CLOSED) {
+    } else if (lydctx->jsonctx->in->current[0] && (lyjson_ctx_status(lydctx->jsonctx, 0) != LYJSON_OBJECT_CLOSED)) {
         LOGVAL(ctx, LY_VLOG_LINE, &lydctx->jsonctx->line, LYVE_SYNTAX, "Unexpected sibling element of \"%s\".",
-               tree->schema->name);
+                tree->schema->name);
         ret = LY_EVALID;
         goto cleanup;
     }
@@ -1746,7 +1746,7 @@
         LY_CHECK_GOTO(ret, cleanup);
         if (lydctx->op_node->schema->nodetype != LYS_ACTION) {
             LOGVAL(ctx, LY_VLOG_LYD, lydctx->op_node, LYVE_DATA, "Unexpected %s element, an \"action\" expected.",
-                   lys_nodetype2str(lydctx->op_node->schema->nodetype));
+                    lys_nodetype2str(lydctx->op_node->schema->nodetype));
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -1755,9 +1755,9 @@
         /* finish rpc envelope */
         ret = lydjson_object_envelope_close(lydctx->jsonctx, "rpc");
         LY_CHECK_GOTO(ret, cleanup);
-        if (!act_e && lydctx->op_node->schema->nodetype != LYS_RPC) {
+        if (!act_e && (lydctx->op_node->schema->nodetype != LYS_RPC)) {
             LOGVAL(ctx, LY_VLOG_LYD, lydctx->op_node, LYVE_DATA, "Unexpected %s element, an \"rpc\" expected.",
-                   lys_nodetype2str(lydctx->op_node->schema->nodetype));
+                    lys_nodetype2str(lydctx->op_node->schema->nodetype));
             ret = LY_EVALID;
             goto cleanup;
         }
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index ea2a7aa..84d9957 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -317,10 +317,10 @@
         if (parse_options & LYD_PARSE_STRICT) {
             if (!*mod) {
                 LOGERR(lybctx->ctx, LY_EINVAL, "Invalid context for LYB data parsing, missing module \"%s%s%s\".",
-                    mod_name, rev ? "@" : "", rev ? mod_rev : "");
+                        mod_name, rev ? "@" : "", rev ? mod_rev : "");
             } else if (!(*mod)->implemented) {
                 LOGERR(lybctx->ctx, LY_EINVAL, "Invalid context for LYB data parsing, module \"%s%s%s\" not implemented.",
-                    mod_name, rev ? "@" : "", rev ? mod_rev : "");
+                        mod_name, rev ? "@" : "", rev ? mod_rev : "");
             }
             ret = LY_EINVAL;
             goto cleanup;
@@ -380,7 +380,7 @@
 
         /* create metadata */
         ret = lyd_parser_create_meta((struct lyd_ctx *)lybctx, NULL, meta, mod, meta_name, strlen(meta_name), meta_value,
-                                     ly_strlen(meta_value), &dynamic, LY_PREF_JSON, NULL, LYD_HINT_DATA);
+                ly_strlen(meta_value), &dynamic, LY_PREF_JSON, NULL, LYD_HINT_DATA);
 
         /* free strings */
         free(meta_name);
@@ -507,7 +507,7 @@
 
         /* attr2 is always changed to the created attribute */
         ret = lyd_create_attr(NULL, &attr2, lybctx->ctx, name, strlen(name), value, ly_strlen(value), &dynamic, format,
-                              0, val_prefs, prefix, ly_strlen(prefix), module_name, ly_strlen(module_name));
+                0, val_prefs, prefix, ly_strlen(prefix), module_name, ly_strlen(module_name));
         LY_CHECK_GOTO(ret, cleanup);
 
         free(prefix);
@@ -622,8 +622,8 @@
     sibling = NULL;
     while ((sibling = lys_getnext(sibling, sparent, mod ? mod->compiled : NULL, getnext_opts))) {
         /* skip schema nodes from models not present during printing */
-        if (lyb_has_schema_model(sibling, lybctx->lybctx->models)
-                && lyb_is_schema_hash_match((struct lysc_node *)sibling, hash, i + 1)) {
+        if (lyb_has_schema_model(sibling, lybctx->lybctx->models) &&
+                lyb_is_schema_hash_match((struct lysc_node *)sibling, hash, i + 1)) {
             /* match found */
             break;
         }
@@ -632,10 +632,10 @@
     if (!sibling && (lybctx->parse_options & LYD_PARSE_STRICT)) {
         if (mod) {
             LOGVAL(lybctx->lybctx->ctx, LY_VLOG_NONE, NULL, LYVE_REFERENCE, "Failed to find matching hash for a top-level node"
-                   " from \"%s\".", mod->name);
+                    " from \"%s\".", mod->name);
         } else {
             LOGVAL(lybctx->lybctx->ctx, LY_VLOG_LYSC, sparent, LYVE_REFERENCE, "Failed to find matching hash for a child node"
-                   " of \"%s\".", sparent->name);
+                    " of \"%s\".", sparent->name);
         }
         return LY_EVALID;
     } else if (sibling && (ret = lyd_parser_check_schema((struct lyd_ctx *)lybctx, sibling))) {
@@ -747,7 +747,7 @@
 
         /* create node */
         ret = lyd_create_opaq(ctx, name, strlen(name), value, strlen(value), &dynamic, format, 0, val_prefs, prefix,
-                              ly_strlen(prefix), module_key, ly_strlen(module_key), &node);
+                ly_strlen(prefix), module_key, ly_strlen(module_key), &node);
         LY_CHECK_GOTO(ret, cleanup);
 
         /* process children */
@@ -763,7 +763,7 @@
 
         /* create node */
         ret = lyd_parser_create_term((struct lyd_ctx *)lybctx, snode, value, ly_strlen(value), &dynamic, LY_PREF_JSON,
-                                     NULL, LYD_HINT_DATA, &node);
+                NULL, LYD_HINT_DATA, &node);
         if (dynamic) {
             free(value);
             dynamic = 0;
@@ -788,8 +788,8 @@
 
             /* add any missing default children */
             ret = lyd_new_implicit_r(node, lyd_node_children_p(node), NULL, NULL, &lybctx->unres_node_type,
-                                     &lybctx->when_check, (lybctx->validate_options & LYD_VALIDATE_NO_STATE)
-                                        ? LYD_IMPLICIT_NO_STATE : 0, NULL);
+                    &lybctx->when_check, (lybctx->validate_options & LYD_VALIDATE_NO_STATE) ?
+                    LYD_IMPLICIT_NO_STATE : 0, NULL);
             LY_CHECK_GOTO(ret, cleanup);
         }
 
@@ -961,7 +961,7 @@
 
     if ((byte & LYB_VERSION_MASK) != LYB_VERSION_NUM) {
         LOGERR(lybctx->ctx, LY_EINVAL, "Invalid LYB format version \"0x%02x\", expected \"0x%02x\".",
-               byte & LYB_VERSION_MASK, LYB_VERSION_NUM);
+                byte & LYB_VERSION_MASK, LYB_VERSION_NUM);
         return LY_EINVAL;
     }
 
diff --git a/src/parser_stmt.c b/src/parser_stmt.c
index 07faa32..d66f410 100644
--- a/src/parser_stmt.c
+++ b/src/parser_stmt.c
@@ -22,9 +22,9 @@
 #include "common.h"
 #include "dict.h"
 #include "log.h"
-#include "path.h"
 #include "parser.h"
 #include "parser_schema.h"
+#include "path.h"
 #include "tree.h"
 #include "tree_schema.h"
 #include "tree_schema_internal.h"
@@ -39,7 +39,7 @@
 
     while (*val) {
         LY_CHECK_ERR_RET(ly_getutf8(&val, &c, &utf8_char_len),
-                         LOGVAL_PARSER(ctx, LY_VCODE_INCHAR, (val)[-utf8_char_len]), LY_EVALID);
+                LOGVAL_PARSER(ctx, LY_VCODE_INCHAR, (val)[-utf8_char_len]), LY_EVALID);
 
         switch (val_type) {
         case Y_IDENTIF_ARG:
@@ -386,7 +386,7 @@
     errno = 0;
     if (val_kw == LY_STMT_VALUE) {
         num = strtol(stmt->arg, &ptr, 10);
-        if (num < INT64_C(-2147483648) || num > INT64_C(2147483647)) {
+        if ((num < INT64_C(-2147483648)) || (num > INT64_C(2147483647))) {
             LOGVAL_PARSER(ctx, LY_VCODE_INVAL, arg_len, stmt->arg, ly_stmt2str(val_kw));
             goto error;
         }
@@ -482,12 +482,12 @@
             break;
         case LY_STMT_VALUE:
             LY_CHECK_ERR_RET(enum_kw == LY_STMT_BIT, LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw),
-                             ly_stmt2str(enum_kw)), LY_EVALID);
+                    ly_stmt2str(enum_kw)), LY_EVALID);
             LY_CHECK_RET(lysp_stmt_type_enum_value_pos(ctx, child, kw, &enm->value, &enm->flags, &enm->exts));
             break;
         case LY_STMT_POSITION:
             LY_CHECK_ERR_RET(enum_kw == LY_STMT_ENUM, LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw),
-                             ly_stmt2str(enum_kw)), LY_EVALID);
+                    ly_stmt2str(enum_kw)), LY_EVALID);
             LY_CHECK_RET(lysp_stmt_type_enum_value_pos(ctx, child, kw, &enm->value, &enm->flags, &enm->exts));
             break;
         case LY_STMT_EXTENSION_INSTANCE:
@@ -795,7 +795,7 @@
         case LY_STMT_PATH:
             LY_CHECK_RET(lysp_stmt_text_field(ctx, child, LYEXT_SUBSTMT_PATH, 0, &str_path, Y_STR_ARG, &type->exts));
             ret = ly_path_parse(PARSER_CTX(ctx), NULL, str_path, 0, LY_PATH_BEGIN_EITHER, LY_PATH_LREF_TRUE,
-                                LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &type->path);
+                    LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &type->path);
             lydict_remove(PARSER_CTX(ctx), str_path);
             LY_CHECK_RET(ret);
             type->flags |= LYS_SET_PATH;
@@ -848,10 +848,9 @@
     pctx.path = ctx->path;
 
     switch (kw) {
-    case LY_STMT_STATUS: {
+    case LY_STMT_STATUS:
         ret = lysp_stmt_status((struct lys_parser_ctx *)&pctx, stmt, *(uint16_t **)result, exts);
         break;
-    }
     case LY_STMT_TYPE: {
         struct lysp_type *type;
         type = calloc(1, sizeof *type);
diff --git a/src/parser_xml.c b/src/parser_xml.c
index c4f0229..4882a31 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -12,10 +12,10 @@
  *     https://opensource.org/licenses/BSD-3-Clause
  */
 
+#include <assert.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
-#include <assert.h>
 
 #include "common.h"
 #include "context.h"
@@ -79,7 +79,7 @@
              * TODO exception for NETCONF filters which are supposed to map to the ietf-netconf without prefix */
             if (lydctx->parse_options & LYD_PARSE_STRICT) {
                 LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_REFERENCE, "Missing mandatory prefix for XML metadata \"%.*s\".",
-                       xmlctx->name_len, xmlctx->name);
+                        xmlctx->name_len, xmlctx->name);
                 goto cleanup;
             }
 
@@ -95,7 +95,7 @@
         if (!ns) {
             /* unknown namespace, XML error */
             LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_REFERENCE, "Unknown XML prefix \"%.*s\".",
-                   xmlctx->prefix_len, xmlctx->prefix);
+                    xmlctx->prefix_len, xmlctx->prefix);
             goto cleanup;
         }
         mod = ly_ctx_get_module_implemented_ns(xmlctx->ctx, ns->uri);
@@ -103,9 +103,9 @@
             /* module is not implemented or not present in the schema */
             if (lydctx->parse_options & LYD_PARSE_STRICT) {
                 LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_REFERENCE,
-                       "Unknown (or not implemented) YANG module with namespace \"%s\" for metadata \"%.*s%s%.*s\".",
-                       ns->uri, xmlctx->prefix_len, xmlctx->prefix, xmlctx->prefix_len ? ":" : "", xmlctx->name_len,
-                       xmlctx->name);
+                        "Unknown (or not implemented) YANG module with namespace \"%s\" for metadata \"%.*s%s%.*s\".",
+                        ns->uri, xmlctx->prefix_len, xmlctx->prefix, xmlctx->prefix_len ? ":" : "", xmlctx->name_len,
+                        xmlctx->name);
                 goto cleanup;
             }
             goto skip_attr;
@@ -156,7 +156,7 @@
             ns = lyxml_ns_get(&xmlctx->ns, xmlctx->prefix, xmlctx->prefix_len);
             if (!ns) {
                 LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_REFERENCE, "Unknown XML prefix \"%.*s\".",
-                       xmlctx->prefix_len, xmlctx->prefix);
+                        xmlctx->prefix_len, xmlctx->prefix);
                 ret = LY_EVALID;
                 goto cleanup;
             }
@@ -181,8 +181,8 @@
 
         /* attr2 is always changed to the created attribute */
         ret = lyd_create_attr(NULL, &attr2, xmlctx->ctx, name, name_len, xmlctx->value, xmlctx->value_len,
-                              &xmlctx->dynamic, LYD_XML, 0, val_prefs, prefix, prefix_len,
-                              ns ? ns->uri : NULL, ns ? strlen(ns->uri) : 0);
+                &xmlctx->dynamic, LYD_XML, 0, val_prefs, prefix, prefix_len,
+                ns ? ns->uri : NULL, ns ? strlen(ns->uri) : 0);
         LY_CHECK_GOTO(ret, cleanup);
 
         if (!*attr) {
@@ -401,7 +401,7 @@
     ns = lyxml_ns_get(&xmlctx->ns, prefix, prefix_len);
     if (!ns) {
         LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_REFERENCE, "Unknown XML prefix \"%.*s\".",
-               prefix_len, prefix);
+                prefix_len, prefix);
         ret = LY_EVALID;
         goto error;
     }
@@ -409,7 +409,7 @@
     if (!mod) {
         if (lydctx->parse_options & LYD_PARSE_STRICT) {
             LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_REFERENCE, "No module with namespace \"%s\" in the context.",
-                   ns->uri);
+                    ns->uri);
             ret = LY_EVALID;
             goto error;
         }
@@ -430,7 +430,7 @@
         if (!snode) {
             if (lydctx->parse_options & LYD_PARSE_STRICT) {
                 LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_REFERENCE, "Element \"%.*s\" not found in the \"%s\" module.",
-                       name_len, name, mod->name);
+                        name_len, name, mod->name);
                 ret = LY_EVALID;
                 goto error;
             } else if (!(lydctx->parse_options & LYD_PARSE_OPAQ)) {
@@ -473,7 +473,7 @@
 
         /* create node */
         ret = lyd_create_opaq(ctx, name, name_len, xmlctx->value, xmlctx->value_len, &xmlctx->dynamic, LYD_XML,
-                              LYD_HINT_DATA, val_prefs, prefix, prefix_len, ns->uri, strlen(ns->uri), &node);
+                LYD_HINT_DATA, val_prefs, prefix, prefix_len, ns->uri, strlen(ns->uri), &node);
         LY_CHECK_GOTO(ret, error);
 
         /* parser next */
@@ -487,7 +487,7 @@
     } else if (snode->nodetype & LYD_NODE_TERM) {
         /* create node */
         LY_CHECK_GOTO(ret = lyd_parser_create_term((struct lyd_ctx *)lydctx, snode, xmlctx->value, xmlctx->value_len,
-                                        &xmlctx->dynamic, LY_PREF_XML, &xmlctx->ns, LYD_HINT_DATA, &node), error);
+                &xmlctx->dynamic, LY_PREF_XML, &xmlctx->ns, LYD_HINT_DATA, &node), error);
 
         if (parent && (node->schema->flags & LYS_KEY)) {
             /* check the key order, the anchor must never be a key */
@@ -495,7 +495,7 @@
             if (anchor && (anchor->schema->flags & LYS_KEY)) {
                 if (lydctx->parse_options & LYD_PARSE_STRICT) {
                     LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_DATA, "Invalid position of the key \"%s\" in a list.",
-                           node->schema->name);
+                            node->schema->name);
                     ret = LY_EVALID;
                     goto error;
                 } else {
@@ -510,7 +510,7 @@
         /* no children expected */
         if (xmlctx->status == LYXML_ELEMENT) {
             LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX, "Child element \"%.*s\" inside a terminal node \"%s\" found.",
-                   xmlctx->name_len, xmlctx->name, snode->name);
+                    xmlctx->name_len, xmlctx->name, snode->name);
             ret = LY_EVALID;
             goto error;
         }
@@ -518,7 +518,7 @@
         if (!xmlctx->ws_only) {
             /* value in inner node */
             LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX, "Text value \"%.*s\" inside an inner node \"%s\" found.",
-                   xmlctx->value_len, xmlctx->value, snode->name);
+                    xmlctx->value_len, xmlctx->value, snode->name);
             ret = LY_EVALID;
             goto error;
         }
@@ -548,7 +548,7 @@
 
             /* add any missing default children */
             ret = lyd_new_implicit_r(node, lyd_node_children_p(node), NULL, NULL, &lydctx->unres_node_type, &lydctx->when_check,
-                            (lydctx->validate_options & LYD_VALIDATE_NO_STATE) ? LYD_IMPLICIT_NO_STATE : 0, NULL);
+                    (lydctx->validate_options & LYD_VALIDATE_NO_STATE) ? LYD_IMPLICIT_NO_STATE : 0, NULL);
             LY_CHECK_GOTO(ret, error);
         }
 
@@ -560,7 +560,7 @@
         if (!xmlctx->ws_only) {
             /* value in inner node */
             LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX, "Text value \"%.*s\" inside an any node \"%s\" found.",
-                   xmlctx->value_len, xmlctx->value, snode->name);
+                    xmlctx->value_len, xmlctx->value, snode->name);
             ret = LY_EVALID;
             goto error;
         }
@@ -641,8 +641,8 @@
 
 cleanup:
     /* there should be no unresolved types stored */
-    assert(!(parse_options & LYD_PARSE_ONLY) || (!lydctx->unres_node_type.count && !lydctx->unres_meta_type.count
-            && !lydctx->when_check.count));
+    assert(!(parse_options & LYD_PARSE_ONLY) || (!lydctx->unres_node_type.count && !lydctx->unres_meta_type.count &&
+            !lydctx->when_check.count));
 
     if (ret) {
         lyd_xml_ctx_free((struct lyd_ctx *)lydctx);
@@ -676,7 +676,7 @@
     ns = lyxml_ns_get(&xmlctx->ns, prefix, prefix_len);
     if (!ns) {
         LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_REFERENCE, "Unknown XML prefix \"%.*s\".",
-               prefix_len, prefix);
+                prefix_len, prefix);
         return LY_EVALID;
     } else if (strcmp(ns->uri, uri)) {
         /* different namespace */
@@ -692,7 +692,7 @@
 
     if (!xmlctx->ws_only) {
         LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX, "Unexpected value \"%.*s\" in the \"%s\" element.",
-               xmlctx->value_len, xmlctx->value, name);
+                xmlctx->value_len, xmlctx->value, name);
         ret = LY_EVALID;
         goto cleanup;
     }
@@ -745,7 +745,7 @@
         goto cleanup;
     } else if (lydctx.xmlctx->status == LYXML_ELEMENT) {
         LOGVAL(ctx, LY_VLOG_LINE, &lydctx.xmlctx->line, LYVE_SYNTAX, "Unexpected sibling element of \"%s\".",
-               tree->schema->name);
+                tree->schema->name);
         ret = LY_EVALID;
         goto cleanup;
     }
@@ -755,12 +755,12 @@
         if (lydctx.xmlctx->status != LYXML_ELEM_CLOSE) {
             assert(lydctx.xmlctx->status == LYXML_ELEMENT);
             LOGVAL(ctx, LY_VLOG_LINE, &lydctx.xmlctx->line, LYVE_SYNTAX, "Unexpected sibling element \"%.*s\" of \"action\".",
-                   lydctx.xmlctx->name_len, lydctx.xmlctx->name);
+                    lydctx.xmlctx->name_len, lydctx.xmlctx->name);
             ret = LY_EVALID;
             goto cleanup;
         } else if (lydctx.op_node->schema->nodetype != LYS_ACTION) {
             LOGVAL(ctx, LY_VLOG_LYD, lydctx.op_node, LYVE_DATA, "Unexpected %s element, an \"action\" expected.",
-                   lys_nodetype2str(lydctx.op_node->schema->nodetype));
+                    lys_nodetype2str(lydctx.op_node->schema->nodetype));
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -770,12 +770,12 @@
         if (lydctx.xmlctx->status != LYXML_ELEM_CLOSE) {
             assert(lydctx.xmlctx->status == LYXML_ELEMENT);
             LOGVAL(ctx, LY_VLOG_LINE, &lydctx.xmlctx->line, LYVE_SYNTAX, "Unexpected sibling element \"%.*s\" of \"rpc\".",
-                   lydctx.xmlctx->name_len, lydctx.xmlctx->name);
+                    lydctx.xmlctx->name_len, lydctx.xmlctx->name);
             ret = LY_EVALID;
             goto cleanup;
         } else if (!act_e && (lydctx.op_node->schema->nodetype != LYS_RPC)) {
             LOGVAL(ctx, LY_VLOG_LYD, lydctx.op_node, LYVE_DATA, "Unexpected %s element, an \"rpc\" expected.",
-                   lys_nodetype2str(lydctx.op_node->schema->nodetype));
+                    lys_nodetype2str(lydctx.op_node->schema->nodetype));
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -826,7 +826,7 @@
 
     /* container envelope */
     LY_CHECK_GOTO(ret = lydxml_envelope(xmlctx, "notification", "urn:ietf:params:xml:ns:netconf:notification:1.0",
-                                        envp), cleanup);
+            envp), cleanup);
 
     /* no envelope, fine */
     if (!*envp) {
@@ -845,12 +845,12 @@
     ns = lyxml_ns_get(&xmlctx->ns, prefix, prefix_len);
     if (!ns) {
         LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_REFERENCE, "Unknown XML prefix \"%.*s\".",
-               prefix_len, prefix);
+                prefix_len, prefix);
         ret = LY_EVALID;
         goto cleanup;
     } else if (strcmp(ns->uri, "urn:ietf:params:xml:ns:netconf:notification:1.0")) {
         LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_REFERENCE, "Invalid namespace \"%s\" of \"eventTime\".",
-               ns->uri);
+                ns->uri);
         ret = LY_EVALID;
         goto cleanup;
     }
@@ -888,7 +888,7 @@
     if (xmlctx->status != LYXML_ELEM_CLOSE) {
         assert(xmlctx->status == LYXML_ELEMENT);
         LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX, "Unexpected sibling element \"%.*s\" of \"eventTime\".",
-               xmlctx->name_len, xmlctx->name);
+                xmlctx->name_len, xmlctx->name);
         ret = LY_EVALID;
         goto cleanup;
     }
@@ -928,7 +928,7 @@
         goto cleanup;
     } else if (lydctx.xmlctx->status == LYXML_ELEMENT) {
         LOGVAL(ctx, LY_VLOG_LINE, &lydctx.xmlctx->line, LYVE_SYNTAX, "Unexpected sibling element of \"%s\".",
-               tree->schema->name);
+                tree->schema->name);
         ret = LY_EVALID;
         goto cleanup;
     }
@@ -938,7 +938,7 @@
         if (lydctx.xmlctx->status != LYXML_ELEM_CLOSE) {
             assert(lydctx.xmlctx->status == LYXML_ELEMENT);
             LOGVAL(ctx, LY_VLOG_LINE, &lydctx.xmlctx->line, LYVE_SYNTAX, "Unexpected sibling element \"%.*s\" of \"notification\".",
-                   lydctx.xmlctx->name_len, lydctx.xmlctx->name);
+                    lydctx.xmlctx->name_len, lydctx.xmlctx->name);
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -999,7 +999,7 @@
 
     /* parse "rpc-reply", if any */
     LY_CHECK_GOTO(ret = lydxml_envelope(lydctx.xmlctx, "rpc-reply", "urn:ietf:params:xml:ns:netconf:base:1.0", &rpcr_e),
-                  cleanup);
+            cleanup);
 
     /* parse the rest of data normally but connect them to the duplicated operation */
     while (lydctx.xmlctx->status == LYXML_ELEMENT) {
@@ -1012,7 +1012,7 @@
         if (lydctx.xmlctx->status != LYXML_ELEM_CLOSE) {
             assert(lydctx.xmlctx->status == LYXML_ELEMENT);
             LOGVAL(LYD_CTX(request), LY_VLOG_LINE, &lydctx.xmlctx->line, LYVE_SYNTAX,
-                   "Unexpected sibling element \"%.*s\" of \"rpc-reply\".", lydctx.xmlctx->name_len, lydctx.xmlctx->name);
+                    "Unexpected sibling element \"%.*s\" of \"rpc-reply\".", lydctx.xmlctx->name_len, lydctx.xmlctx->name);
             ret = LY_EVALID;
             goto cleanup;
         }
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 18c76bc..15ae77c 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -25,8 +25,8 @@
 #include "context.h"
 #include "dict.h"
 #include "log.h"
-#include "path.h"
 #include "parser_schema.h"
+#include "path.h"
 #include "set.h"
 #include "tree.h"
 #include "tree_schema.h"
@@ -149,7 +149,7 @@
 
     /* get UTF8 code point (and number of bytes coding the character) */
     LY_CHECK_ERR_RET(ly_getutf8(&in->current, &c, &len),
-                     LOGVAL_PARSER(ctx, LY_VCODE_INCHAR, in->current[-len]), LY_EVALID);
+            LOGVAL_PARSER(ctx, LY_VCODE_INCHAR, in->current[-len]), LY_EVALID);
     in->current -= len;
     if (c == '\n') {
         ctx->indent = 0;
@@ -431,7 +431,7 @@
                 break;
             default:
                 LOGVAL_PARSER(ctx, LYVE_SYNTAX_YANG, "Double-quoted string unknown special character '\\%c'.",
-                              in->current[0]);
+                        in->current[0]);
                 return LY_EVALID;
             }
 
@@ -489,7 +489,7 @@
     }
 
 string_end:
-    if (arg <= Y_PREF_IDENTIF_ARG && !(*word_len)) {
+    if ((arg <= Y_PREF_IDENTIF_ARG) && !(*word_len)) {
         /* empty identifier */
         LOGVAL_PARSER(ctx, LYVE_SYNTAX_YANG, "Statement argument is required.");
         return LY_EVALID;
@@ -517,6 +517,7 @@
 {
     size_t buf_len = 0;
     uint8_t prefix = 0;
+
     /* word buffer - dynamically allocated */
     *word_b = NULL;
 
@@ -531,7 +532,7 @@
             if (*word_len) {
                 /* invalid - quotes cannot be in unquoted string and only optsep, ; or { can follow it */
                 LOGVAL_PARSER(ctx, LY_VCODE_INSTREXP, 1, in->current,
-                            "unquoted string character, optsep, semicolon or opening brace");
+                        "unquoted string character, optsep, semicolon or opening brace");
                 return LY_EVALID;
             }
             if (flags) {
@@ -595,7 +596,7 @@
         case '}':
             /* invalid - braces cannot be in unquoted string (opening braces terminates the string and can follow it) */
             LOGVAL_PARSER(ctx, LY_VCODE_INSTREXP, 1, in->current,
-                        "unquoted string character, optsep, semicolon or opening brace");
+                    "unquoted string character, optsep, semicolon or opening brace");
             return LY_EVALID;
         default:
             LY_CHECK_RET(buf_store_char(ctx, in, arg, word_p, word_len, word_b, &buf_len, 0, &prefix));
@@ -685,7 +686,7 @@
     word_start = in->current;
     *kw = lysp_match_kw(ctx, in);
 
-    if (*kw == LY_STMT_SYNTAX_SEMICOLON || *kw == LY_STMT_SYNTAX_LEFT_BRACE || *kw == LY_STMT_SYNTAX_RIGHT_BRACE) {
+    if ((*kw == LY_STMT_SYNTAX_SEMICOLON) || (*kw == LY_STMT_SYNTAX_LEFT_BRACE) || (*kw == LY_STMT_SYNTAX_RIGHT_BRACE)) {
         goto success;
     }
 
@@ -706,30 +707,30 @@
             goto extension;
         case '{':
             /* allowed only for input and output statements which can be without arguments */
-            if (*kw == LY_STMT_INPUT || *kw == LY_STMT_OUTPUT) {
+            if ((*kw == LY_STMT_INPUT) || (*kw == LY_STMT_OUTPUT)) {
                 break;
             }
         /* fallthrough */
         default:
             MOVE_INPUT(ctx, in, 1);
             LOGVAL_PARSER(ctx, LY_VCODE_INSTREXP, (int)(in->current - word_start), word_start,
-                        "a keyword followed by a separator");
+                    "a keyword followed by a separator");
             return LY_EVALID;
         }
     } else {
         /* still can be an extension */
         prefix = 0;
 extension:
-        while (in->current[0] && (in->current[0] != ' ') && (in->current[0] != '\t') && (in->current[0] != '\n')
-                && (in->current[0] != '{') && (in->current[0] != ';')) {
+        while (in->current[0] && (in->current[0] != ' ') && (in->current[0] != '\t') && (in->current[0] != '\n') &&
+                (in->current[0] != '{') && (in->current[0] != ';')) {
             uint32_t c = 0;
 
             LY_CHECK_ERR_RET(ly_getutf8(&in->current, &c, &len),
-                             LOGVAL_PARSER(ctx, LY_VCODE_INCHAR, in->current[-len]), LY_EVALID);
+                    LOGVAL_PARSER(ctx, LY_VCODE_INCHAR, in->current[-len]), LY_EVALID);
             ++ctx->indent;
             /* check character validity */
             LY_CHECK_RET(lysp_check_identifierchar((struct lys_parser_ctx *)ctx, c,
-                                                   in->current - len == word_start ? 1 : 0, &prefix));
+                    in->current - len == word_start ? 1 : 0, &prefix));
         }
         if (!in->current[0]) {
             LOGVAL_PARSER(ctx, LY_VCODE_EOF);
@@ -1679,7 +1680,7 @@
     errno = 0;
     if (val_kw == LY_STMT_VALUE) {
         num = strtol(word, &ptr, 10);
-        if (num < INT64_C(-2147483648) || num > INT64_C(2147483647)) {
+        if ((num < INT64_C(-2147483648)) || (num > INT64_C(2147483647))) {
             LOGVAL_PARSER(ctx, LY_VCODE_INVAL, word_len, word, ly_stmt2str(val_kw));
             goto error;
         }
@@ -1771,12 +1772,12 @@
             break;
         case LY_STMT_VALUE:
             LY_CHECK_ERR_RET(enum_kw == LY_STMT_BIT, LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw),
-                             ly_stmt2str(enum_kw)), LY_EVALID);
+                    ly_stmt2str(enum_kw)), LY_EVALID);
             LY_CHECK_RET(parse_type_enum_value_pos(ctx, in, kw, &enm->value, &enm->flags, &enm->exts));
             break;
         case LY_STMT_POSITION:
             LY_CHECK_ERR_RET(enum_kw == LY_STMT_ENUM, LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw),
-                             ly_stmt2str(enum_kw)), LY_EVALID);
+                    ly_stmt2str(enum_kw)), LY_EVALID);
             LY_CHECK_RET(parse_type_enum_value_pos(ctx, in, kw, &enm->value, &enm->flags, &enm->exts));
             break;
         case LY_STMT_EXTENSION_INSTANCE:
@@ -2094,7 +2095,7 @@
 
             LY_CHECK_RET(parse_text_field(ctx, in, LYEXT_SUBSTMT_PATH, 0, &str_path, Y_STR_ARG, &type->exts));
             ret = ly_path_parse(ctx->ctx, NULL, str_path, 0, LY_PATH_BEGIN_EITHER, LY_PATH_LREF_TRUE,
-                                LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &type->path);
+                    LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &type->path);
             lydict_remove(ctx->ctx, str_path);
             LY_CHECK_RET(ret);
             type->flags |= LYS_SET_PATH;
@@ -4045,7 +4046,7 @@
             LY_CHECK_RET(parse_status(ctx, in, &ident->flags, &ident->exts));
             break;
         case LY_STMT_BASE:
-            if (ident->bases && ctx->mod_version < 2) {
+            if (ident->bases && (ctx->mod_version < 2)) {
                 LOGVAL_PARSER(ctx, LYVE_SYNTAX_YANG, "Identity can be derived from multiple base identities only in YANG 1.1 modules");
                 return LY_EVALID;
             }
@@ -4461,7 +4462,7 @@
 checks:
     /* finalize parent pointers to the reallocated items */
     LY_CHECK_RET(lysp_parse_finalize_reallocated((struct lys_parser_ctx *)ctx, submod->groupings, submod->augments,
-                                                 submod->rpcs, submod->notifs));
+            submod->rpcs, submod->notifs));
 
     /* mandatory substatements */
     if (!submod->prefix) {
diff --git a/src/parser_yin.c b/src/parser_yin.c
index c435a09..8efa2de 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -25,9 +25,9 @@
 #include "common.h"
 #include "context.h"
 #include "dict.h"
-#include "path.h"
 #include "parser_internal.h"
 #include "parser_schema.h"
+#include "path.h"
 #include "set.h"
 #include "tree.h"
 #include "tree_schema.h"
@@ -65,7 +65,7 @@
     const struct lyxml_ns *ns = NULL;
     struct ly_in *in;
 
-    if (!name || name_len == 0) {
+    if (!name || (name_len == 0)) {
         return LY_STMT_NONE;
     }
 
@@ -87,7 +87,7 @@
 
     if (name - start == (long int)name_len) {
         /* this is done because of collision in yang statement value and yang argument mapped to yin element value */
-        if (kw == LY_STMT_VALUE && parent == LY_STMT_ERROR_MESSAGE) {
+        if ((kw == LY_STMT_VALUE) && (parent == LY_STMT_ERROR_MESSAGE)) {
             return LY_STMT_ARG_VALUE;
         }
         return kw;
@@ -105,6 +105,7 @@
 {
     enum yin_argument arg = YIN_ARG_UNKNOWN;
     size_t already_read = 0;
+
     LY_CHECK_RET(len == 0, YIN_ARG_NONE);
 
 #define READ_INC(LEN) already_read += LEN
@@ -250,7 +251,7 @@
             inc_meta->name = va_arg(ap, const char *);
             inc_meta->includes = va_arg(ap, struct lysp_include **);
             (*result)[i].dest = inc_meta;
-        } else if ((*result)[i].type == LY_STMT_INPUT || (*result)[i].type == LY_STMT_OUTPUT) {
+        } else if (((*result)[i].type == LY_STMT_INPUT) || ((*result)[i].type == LY_STMT_OUTPUT)) {
             struct inout_meta *inout_meta = NULL;
             inout_meta = calloc(1, sizeof *inout_meta);
             LY_CHECK_GOTO(!inout_meta, mem_err);
@@ -286,7 +287,7 @@
     val = ctx->xmlctx->value;
     while (already_read < ctx->xmlctx->value_len) {
         LY_CHECK_ERR_RET(ly_getutf8((const char **)&val, &c, &utf8_char_len),
-                         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INCHAR, (val)[-utf8_char_len]), LY_EVALID);
+                LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INCHAR, (val)[-utf8_char_len]), LY_EVALID);
         already_read += utf8_char_len;
         LY_CHECK_ERR_RET(already_read > ctx->xmlctx->value_len, LOGINT(ctx->xmlctx->ctx), LY_EINT);
 
@@ -336,7 +337,7 @@
                 LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
             } else if (arg == arg_type) {
                 LY_CHECK_ERR_RET(found, LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_DUP_ATTR,
-                                 yin_attr2str(arg), ly_stmt2str(current_element)), LY_EVALID);
+                        yin_attr2str(arg), ly_stmt2str(current_element)), LY_EVALID);
                 found = true;
 
                 /* go to value */
@@ -346,7 +347,7 @@
                 LY_CHECK_RET(!(*arg_val), LY_EMEM);
             } else {
                 LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_UNEXP_ATTR, ctx->xmlctx->name_len,
-                              ctx->xmlctx->name, ly_stmt2str(current_element));
+                        ctx->xmlctx->name, ly_stmt2str(current_element));
                 return LY_EVALID;
             }
         } else {
@@ -359,9 +360,9 @@
     }
 
     /* anything else than Y_MAYBE_STR_ARG is mandatory */
-    if (val_type != Y_MAYBE_STR_ARG && !found) {
+    if ((val_type != Y_MAYBE_STR_ARG) && !found) {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LYVE_SYNTAX_YIN, "Missing mandatory attribute %s of %s element.",
-                      yin_attr2str(arg_type), ly_stmt2str(current_element));
+                yin_attr2str(arg_type), ly_stmt2str(current_element));
         return LY_EVALID;
     }
 
@@ -406,7 +407,7 @@
         /* if there is element that is mandatory and isn't parsed log error and return LY_EVALID */
         if ((subelem_info[i].flags & YIN_SUBELEM_MANDATORY) && !(subelem_info[i].flags & YIN_SUBELEM_PARSED)) {
             LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_MAND_SUBELEM,
-                          ly_stmt2str(subelem_info[i].type), ly_stmt2str(current_element));
+                    ly_stmt2str(subelem_info[i].type), ly_stmt2str(current_element));
             return LY_EVALID;
         }
     }
@@ -433,7 +434,7 @@
     for (signed char i = 0; i < subelem_info_size; ++i) {
         if (subelem_info[i].flags & YIN_SUBELEM_PARSED) {
             LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_FIRT_SUBELEM,
-                           ly_stmt2str(exp_first->type), ly_stmt2str(current_element));
+                    ly_stmt2str(exp_first->type), ly_stmt2str(current_element));
             return LY_EVALID;
         }
     }
@@ -482,7 +483,7 @@
 
     LY_CHECK_RET(yin_parse_simple_element(ctx, kw, &str_path, YIN_ARG_VALUE, Y_STR_ARG, &type->exts));
     ret = ly_path_parse(ctx->xmlctx->ctx, NULL, str_path, 0, LY_PATH_BEGIN_EITHER, LY_PATH_LREF_TRUE,
-                        LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &type->path);
+            LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &type->path);
     lydict_remove(ctx->xmlctx->ctx, str_path);
     LY_CHECK_RET(ret);
     type->flags |= LYS_SET_PATH;
@@ -527,6 +528,7 @@
         {LY_STMT_REFERENCE, &restr->ref, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
     };
+
     return yin_parse_content(ctx, subelems, 6, LY_STMT_PATTERN, NULL, &restr->exts);
 }
 
@@ -547,7 +549,7 @@
     LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
     LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_FRACTION_DIGITS));
 
-    if (temp_val[0] == '\0' || (temp_val[0] == '0') || !isdigit(temp_val[0])) {
+    if ((temp_val[0] == '\0') || (temp_val[0] == '0') || !isdigit(temp_val[0])) {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", "fraction-digits");
         FREE_STRING(ctx->xmlctx->ctx, temp_val);
         return LY_EVALID;
@@ -571,6 +573,7 @@
     struct yin_subelement subelems[1] = {
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
     };
+
     return yin_parse_content(ctx, subelems, 1, LY_STMT_FRACTION_DIGITS, NULL, &type->exts);
 }
 
@@ -602,6 +605,7 @@
         {LY_STMT_VALUE, en, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
     };
+
     return yin_parse_content(ctx, subelems, 6, LY_STMT_ENUM, NULL, &en->exts);
 }
 
@@ -631,6 +635,7 @@
         {LY_STMT_STATUS, &en->flags, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
     };
+
     return yin_parse_content(ctx, subelems, 6, LY_STMT_BIT, NULL, &en->exts);
 }
 
@@ -651,6 +656,7 @@
         enum yang_arg arg_val_type, struct lysp_ext_instance **exts)
 {
     const char **value;
+
     LY_ARRAY_NEW_RET(ctx->xmlctx->ctx, *values, value, LY_EMEM);
     LY_ARRAY_COUNT_TYPE index = LY_ARRAY_COUNT(*values) - 1;
     struct yin_subelement subelems[1] = {
@@ -680,10 +686,10 @@
 {
     if (subinfo->flags & YIN_SUBELEM_UNIQUE) {
         LY_CHECK_RET(yin_parse_simple_element(ctx, kw, (const char **)subinfo->dest,
-                                              arg_type, arg_val_type, exts));
+                arg_type, arg_val_type, exts));
     } else {
         LY_CHECK_RET(yin_parse_simple_elements(ctx, kw, (const char ***)subinfo->dest,
-                                               arg_type, arg_val_type, exts));
+                arg_type, arg_val_type, exts));
     }
 
     return LY_SUCCESS;
@@ -706,11 +712,11 @@
     if (parent == LY_STMT_TYPE) {
         type = (struct lysp_type *)dest;
         LY_CHECK_RET(yin_parse_simple_elements(ctx, LY_STMT_BASE, &type->bases, YIN_ARG_NAME,
-                                               Y_PREF_IDENTIF_ARG, exts));
+                Y_PREF_IDENTIF_ARG, exts));
         type->flags |= LYS_SET_BASE;
     } else if (parent == LY_STMT_IDENTITY) {
         LY_CHECK_RET(yin_parse_simple_elements(ctx, LY_STMT_BASE, (const char ***)dest,
-                                               YIN_ARG_NAME, Y_PREF_IDENTIF_ARG, exts));
+                YIN_ARG_NAME, Y_PREF_IDENTIF_ARG, exts));
     } else {
         LOGINT(ctx->xmlctx->ctx);
         return LY_EINT;
@@ -741,7 +747,7 @@
         type->require_instance = 1;
     } else if (strcmp(temp_val, "false") != 0) {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS2, temp_val, "value",
-                       "require-instance", "true", "false");
+                "require-instance", "true", "false");
         FREE_STRING(ctx->xmlctx->ctx, temp_val);
         return LY_EVALID;
     }
@@ -773,7 +779,7 @@
     LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_MODIFIER));
     if (strcmp(temp_val, "invert-match") != 0) {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS1, temp_val, "value",
-                       "modifier", "invert-match");
+                "modifier", "invert-match");
         FREE_STRING(ctx->xmlctx->ctx, temp_val);
         return LY_EVALID;
     }
@@ -951,7 +957,7 @@
     /* get attribute value */
     LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
     LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, kw));
-    if (!temp_val || temp_val[0] == '\0' || (temp_val[0] == '+') ||
+    if (!temp_val || (temp_val[0] == '\0') || (temp_val[0] == '+') ||
             ((temp_val[0] == '0') && (temp_val[1] != '\0')) || ((kw == LY_STMT_POSITION) && !strcmp(temp_val, "-0"))) {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", ly_stmt2str(kw));
         goto error;
@@ -961,7 +967,7 @@
     errno = 0;
     if (kw == LY_STMT_VALUE) {
         num = strtol(temp_val, &ptr, 10);
-        if (num < INT64_C(-2147483648) || num > INT64_C(2147483647)) {
+        if ((num < INT64_C(-2147483648)) || (num > INT64_C(2147483647))) {
             LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", ly_stmt2str(kw));
             goto error;
         }
@@ -993,6 +999,7 @@
     struct yin_subelement subelems[1] = {
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0}
     };
+
     return yin_parse_content(ctx, subelems, 1, kw, NULL, &enm->exts);
 
 error:
@@ -1051,6 +1058,7 @@
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
         {LY_STMT_ARG_TEXT, value, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE | YIN_SUBELEM_FIRST}
     };
+
     /* check attributes */
     LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
     LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_NONE, NULL, Y_MAYBE_STR_ARG, elem_type));
@@ -1096,6 +1104,7 @@
 yin_parse_type(struct lys_yin_parser_ctx *ctx, enum ly_stmt parent, struct yin_subelement *subinfo)
 {
     struct lysp_type *type = NULL;
+
     if (parent == LY_STMT_DEVIATE) {
         *(struct lysp_type **)subinfo->dest = calloc(1, sizeof **(struct lysp_type **)subinfo->dest);
         LY_CHECK_ERR_RET(!(*(struct lysp_type **)subinfo->dest), LOGMEM(ctx->xmlctx->ctx), LY_EMEM);
@@ -1156,7 +1165,7 @@
     *flags |= LYS_SET_MAX;
     LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
     LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_MAX_ELEMENTS));
-    if (!temp_val || temp_val[0] == '\0' || temp_val[0] == '0' || (temp_val[0] != 'u' && !isdigit(temp_val[0]))) {
+    if (!temp_val || (temp_val[0] == '\0') || (temp_val[0] == '0') || ((temp_val[0] != 'u') && !isdigit(temp_val[0]))) {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", "max-elements");
         FREE_STRING(ctx->xmlctx->ctx, temp_val);
         return LY_EVALID;
@@ -1205,7 +1214,7 @@
     LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
     LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_VALUE, &temp_val, Y_STR_ARG, LY_STMT_MIN_ELEMENTS));
 
-    if (!temp_val || temp_val[0] == '\0' || (temp_val[0] == '0' && temp_val[1] != '\0')) {
+    if (!temp_val || (temp_val[0] == '\0') || ((temp_val[0] == '0') && (temp_val[1] != '\0'))) {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN, temp_val, "value", "min-elements");
         FREE_STRING(ctx->xmlctx->ctx, temp_val);
         return LY_EVALID;
@@ -1218,7 +1227,7 @@
         FREE_STRING(ctx->xmlctx->ctx, temp_val);
         return LY_EVALID;
     }
-    if (errno == ERANGE || num > UINT32_MAX) {
+    if ((errno == ERANGE) || (num > UINT32_MAX)) {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_OOB_YIN, temp_val, "value", "min-elements");
         FREE_STRING(ctx->xmlctx->ctx, temp_val);
         return LY_EVALID;
@@ -1299,7 +1308,7 @@
         *flags |= LYS_ORDBY_USER;
     } else {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS2, temp_val, "value",
-                       "ordered-by", "system", "user");
+                "ordered-by", "system", "user");
         FREE_STRING(ctx->xmlctx->ctx, temp_val);
         return LY_EVALID;
     }
@@ -1342,6 +1351,7 @@
         {LY_STMT_WHEN, &any->when, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
     };
+
     return yin_parse_content(ctx, subelems, 9, any_kw, NULL, &any->exts);
 }
 
@@ -1382,6 +1392,7 @@
         {LY_STMT_WHEN, &leaf->when, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
     };
+
     return yin_parse_content(ctx, subelems, 12, LY_STMT_LEAF, NULL, &leaf->exts);
 }
 
@@ -1424,6 +1435,7 @@
         {LY_STMT_WHEN, &llist->when, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
     };
+
     LY_CHECK_RET(yin_parse_content(ctx, subelems, 14, LY_STMT_LEAF_LIST, NULL, &llist->exts));
 
     /* check invalid combination of subelements */
@@ -1431,7 +1443,7 @@
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INCHILDSTMSCOMB_YIN, "min-elements", "default", "leaf-list");
         return LY_EVALID;
     }
-    if (llist->max && llist->min > llist->max) {
+    if (llist->max && (llist->min > llist->max)) {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_MINMAX, llist->min, llist->max);
         return LY_EVALID;
     }
@@ -1452,6 +1464,7 @@
 {
     struct lysp_tpdf *tpdf;
     struct lysp_tpdf **tpdfs = (struct lysp_tpdf **)typedef_meta->nodes;
+
     LY_ARRAY_NEW_RET(ctx->xmlctx->ctx, *tpdfs, tpdf, LY_EMEM);
 
     /* parse argument */
@@ -1468,11 +1481,12 @@
         {LY_STMT_UNITS, &tpdf->units, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
     };
+
     LY_CHECK_RET(yin_parse_content(ctx, subelems, 7, LY_STMT_TYPEDEF, NULL, &tpdf->exts));
 
     /* store data for collision check */
-    if (typedef_meta->parent && !(typedef_meta->parent->nodetype & (LYS_GROUPING | LYS_RPC | LYS_ACTION | LYS_INPUT
-            | LYS_OUTPUT | LYS_NOTIF))) {
+    if (typedef_meta->parent && !(typedef_meta->parent->nodetype & (LYS_GROUPING | LYS_RPC | LYS_ACTION | LYS_INPUT |
+            LYS_OUTPUT | LYS_NOTIF))) {
         LY_CHECK_RET(ly_set_add(&ctx->tpdfs_nodes, typedef_meta->parent, 0, NULL));
     }
 
@@ -1514,6 +1528,7 @@
         {LY_STMT_REFERENCE, &rf->ref, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
     };
+
     return yin_parse_content(ctx, subelems, 11, LY_STMT_REFINE, NULL, &rf->exts);
 }
 
@@ -1551,6 +1566,7 @@
         {LY_STMT_WHEN, &uses->when, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
     };
+
     LY_CHECK_RET(yin_parse_content(ctx, subelems, 8, LY_STMT_USES, NULL, &uses->exts));
     LY_CHECK_RET(lysp_parse_finalize_reallocated((struct lys_parser_ctx *)ctx, NULL, uses->augments, NULL, NULL));
 
@@ -1591,6 +1607,7 @@
         {LY_STMT_REFERENCE, &rev->ref, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
     };
+
     return yin_parse_content(ctx, subelems, 3, LY_STMT_REVISION, NULL, &rev->exts);
 }
 
@@ -1628,6 +1645,7 @@
         {LY_STMT_REVISION_DATE, &inc->rev, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
     };
+
     return yin_parse_content(ctx, subelems, 4, LY_STMT_INCLUDE, NULL, &inc->exts);
 }
 
@@ -1651,7 +1669,7 @@
     LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
     LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_DATE, &temp_rev, Y_STR_ARG, LY_STMT_REVISION_DATE));
     LY_CHECK_ERR_RET(lysp_check_date((struct lys_parser_ctx *)ctx, temp_rev, strlen(temp_rev), "revision-date") != LY_SUCCESS,
-                     FREE_STRING(ctx->xmlctx->ctx, temp_rev), LY_EVALID);
+            FREE_STRING(ctx->xmlctx->ctx, temp_rev), LY_EVALID);
 
     strcpy(rev, temp_rev);
     FREE_STRING(ctx->xmlctx->ctx, temp_rev);
@@ -1684,7 +1702,7 @@
         *flags |= LYS_CONFIG_R;
     } else {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS2, temp_val, "value", "config",
-                       "true", "false");
+                "true", "false");
         FREE_STRING(ctx->xmlctx->ctx, temp_val);
         return LY_EVALID;
     }
@@ -1718,7 +1736,7 @@
         *version = LYS_VERSION_1_1;
     } else {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS2, temp_version, "value",
-                       "yang-version", "1", "1.1");
+                "yang-version", "1", "1.1");
         FREE_STRING(ctx->xmlctx->ctx, temp_version);
         return LY_EVALID;
     }
@@ -1740,6 +1758,7 @@
 yin_parse_import(struct lys_yin_parser_ctx *ctx, struct import_meta *imp_meta)
 {
     struct lysp_import *imp;
+
     /* allocate new element in sized array for import */
     LY_ARRAY_NEW_RET(ctx->xmlctx->ctx, *imp_meta->imports, imp, LY_EMEM);
 
@@ -1786,7 +1805,7 @@
         *flags |= LYS_MAND_FALSE;
     } else {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS2, temp_val, "value",
-                       "mandatory", "true", "false");
+                "mandatory", "true", "false");
         FREE_STRING(ctx->xmlctx->ctx, temp_val);
         return LY_EVALID;
     }
@@ -1822,7 +1841,7 @@
         *flags |= LYS_STATUS_OBSLT;
     } else {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS3, value, "value",
-                       "status", "current", "deprecated", "obsolete");
+                "status", "current", "deprecated", "obsolete");
         FREE_STRING(ctx->xmlctx->ctx, value);
         return LY_EVALID;
     }
@@ -1888,7 +1907,7 @@
         *flags |= LYS_YINELEM_FALSE;
     } else {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS2, temp_val, "value",
-                       "yin-element", "true", "false");
+                "yin-element", "true", "false");
         FREE_STRING(ctx->xmlctx->ctx, temp_val);
         return LY_EVALID;
     }
@@ -1932,6 +1951,7 @@
 yin_parse_extension(struct lys_yin_parser_ctx *ctx, struct lysp_ext **extensions)
 {
     struct lysp_ext *ex;
+
     LY_ARRAY_NEW_RET(ctx->xmlctx->ctx, *extensions, ex, LY_EMEM);
     LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
     LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_NAME, &ex->name, Y_IDENTIF_ARG, LY_STMT_EXTENSION));
@@ -1976,6 +1996,7 @@
         {LY_STMT_STATUS, &feat->flags, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
     };
+
     return yin_parse_content(ctx, subelems, 5, LY_STMT_FEATURE, NULL, &feat->exts);
 }
 
@@ -2008,6 +2029,7 @@
         {LY_STMT_STATUS, &ident->flags, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
     };
+
     return yin_parse_content(ctx, subelems, 6, LY_STMT_IDENTITY, NULL, &ident->exts);
 }
 
@@ -2036,32 +2058,31 @@
 
     /* parse list content */
     LY_CHECK_RET(subelems_allocator(ctx, 25, (struct lysp_node *)list, &subelems,
-                                        LY_STMT_ACTION, &list->actions, 0,
-                                        LY_STMT_ANYDATA, &list->child, 0,
-                                        LY_STMT_ANYXML, &list->child, 0,
-                                        LY_STMT_CHOICE, &list->child, 0,
-                                        LY_STMT_CONFIG, &list->flags, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_CONTAINER, &list->child, 0,
-                                        LY_STMT_DESCRIPTION, &list->dsc, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_GROUPING, &list->groupings, 0,
-                                        LY_STMT_IF_FEATURE, &list->iffeatures, 0,
-                                        LY_STMT_KEY, &list->key, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_LEAF, &list->child, 0,
-                                        LY_STMT_LEAF_LIST, &list->child, 0,
-                                        LY_STMT_LIST, &list->child, 0,
-                                        LY_STMT_MAX_ELEMENTS, list, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_MIN_ELEMENTS, list, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_MUST, &list->musts, 0,
-                                        LY_STMT_NOTIFICATION, &list->notifs, 0,
-                                        LY_STMT_ORDERED_BY, &list->flags, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_REFERENCE, &list->ref, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_STATUS, &list->flags, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_TYPEDEF, &list->typedefs, 0,
-                                        LY_STMT_UNIQUE, &list->uniques, 0,
-                                        LY_STMT_USES, &list->child, 0,
-                                        LY_STMT_WHEN, &list->when, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_EXTENSION_INSTANCE, NULL, 0
-                                   ));
+            LY_STMT_ACTION, &list->actions, 0,
+            LY_STMT_ANYDATA, &list->child, 0,
+            LY_STMT_ANYXML, &list->child, 0,
+            LY_STMT_CHOICE, &list->child, 0,
+            LY_STMT_CONFIG, &list->flags, YIN_SUBELEM_UNIQUE,
+            LY_STMT_CONTAINER, &list->child, 0,
+            LY_STMT_DESCRIPTION, &list->dsc, YIN_SUBELEM_UNIQUE,
+            LY_STMT_GROUPING, &list->groupings, 0,
+            LY_STMT_IF_FEATURE, &list->iffeatures, 0,
+            LY_STMT_KEY, &list->key, YIN_SUBELEM_UNIQUE,
+            LY_STMT_LEAF, &list->child, 0,
+            LY_STMT_LEAF_LIST, &list->child, 0,
+            LY_STMT_LIST, &list->child, 0,
+            LY_STMT_MAX_ELEMENTS, list, YIN_SUBELEM_UNIQUE,
+            LY_STMT_MIN_ELEMENTS, list, YIN_SUBELEM_UNIQUE,
+            LY_STMT_MUST, &list->musts, 0,
+            LY_STMT_NOTIFICATION, &list->notifs, 0,
+            LY_STMT_ORDERED_BY, &list->flags, YIN_SUBELEM_UNIQUE,
+            LY_STMT_REFERENCE, &list->ref, YIN_SUBELEM_UNIQUE,
+            LY_STMT_STATUS, &list->flags, YIN_SUBELEM_UNIQUE,
+            LY_STMT_TYPEDEF, &list->typedefs, 0,
+            LY_STMT_UNIQUE, &list->uniques, 0,
+            LY_STMT_USES, &list->child, 0,
+            LY_STMT_WHEN, &list->when, YIN_SUBELEM_UNIQUE,
+            LY_STMT_EXTENSION_INSTANCE, NULL, 0));
     ret = yin_parse_content(ctx, subelems, 25, LY_STMT_LIST, NULL, &list->exts);
     subelems_deallocator(25, subelems);
     LY_CHECK_RET(ret);
@@ -2069,7 +2090,7 @@
     /* finalize parent pointers to the reallocated items */
     LY_CHECK_RET(lysp_parse_finalize_reallocated((struct lys_parser_ctx *)ctx, list->groupings, NULL, list->actions, list->notifs));
 
-    if (list->max && list->min > list->max) {
+    if (list->max && (list->min > list->max)) {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_MINMAX, list->min, list->max);
         return LY_EVALID;
     }
@@ -2104,23 +2125,22 @@
 
     /* parse notification content */
     LY_CHECK_RET(subelems_allocator(ctx, 16, (struct lysp_node *)notif, &subelems,
-                                        LY_STMT_ANYDATA, &notif->data, 0,
-                                        LY_STMT_ANYXML, &notif->data, 0,
-                                        LY_STMT_CHOICE, &notif->data, 0,
-                                        LY_STMT_CONTAINER, &notif->data, 0,
-                                        LY_STMT_DESCRIPTION, &notif->dsc, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_GROUPING, &notif->groupings, 0,
-                                        LY_STMT_IF_FEATURE, &notif->iffeatures, 0,
-                                        LY_STMT_LEAF, &notif->data, 0,
-                                        LY_STMT_LEAF_LIST, &notif->data, 0,
-                                        LY_STMT_LIST, &notif->data, 0,
-                                        LY_STMT_MUST, &notif->musts, YIN_SUBELEM_VER2,
-                                        LY_STMT_REFERENCE, &notif->ref, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_STATUS, &notif->flags, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_TYPEDEF, &notif->typedefs, 0,
-                                        LY_STMT_USES, &notif->data, 0,
-                                        LY_STMT_EXTENSION_INSTANCE, NULL, 0
-                                   ));
+            LY_STMT_ANYDATA, &notif->data, 0,
+            LY_STMT_ANYXML, &notif->data, 0,
+            LY_STMT_CHOICE, &notif->data, 0,
+            LY_STMT_CONTAINER, &notif->data, 0,
+            LY_STMT_DESCRIPTION, &notif->dsc, YIN_SUBELEM_UNIQUE,
+            LY_STMT_GROUPING, &notif->groupings, 0,
+            LY_STMT_IF_FEATURE, &notif->iffeatures, 0,
+            LY_STMT_LEAF, &notif->data, 0,
+            LY_STMT_LEAF_LIST, &notif->data, 0,
+            LY_STMT_LIST, &notif->data, 0,
+            LY_STMT_MUST, &notif->musts, YIN_SUBELEM_VER2,
+            LY_STMT_REFERENCE, &notif->ref, YIN_SUBELEM_UNIQUE,
+            LY_STMT_STATUS, &notif->flags, YIN_SUBELEM_UNIQUE,
+            LY_STMT_TYPEDEF, &notif->typedefs, 0,
+            LY_STMT_USES, &notif->data, 0,
+            LY_STMT_EXTENSION_INSTANCE, NULL, 0));
 
     ret = yin_parse_content(ctx, subelems, 16, LY_STMT_NOTIFICATION, NULL, &notif->exts);
     subelems_deallocator(16, subelems);
@@ -2159,23 +2179,22 @@
 
     /* parse grouping content */
     LY_CHECK_RET(subelems_allocator(ctx, 16, (struct lysp_node *)grp, &subelems,
-                                        LY_STMT_ACTION, &grp->actions, 0,
-                                        LY_STMT_ANYDATA, &grp->data, 0,
-                                        LY_STMT_ANYXML, &grp->data, 0,
-                                        LY_STMT_CHOICE, &grp->data, 0,
-                                        LY_STMT_CONTAINER, &grp->data, 0,
-                                        LY_STMT_DESCRIPTION, &grp->dsc, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_GROUPING, &grp->groupings, 0,
-                                        LY_STMT_LEAF, &grp->data, 0,
-                                        LY_STMT_LEAF_LIST, &grp->data, 0,
-                                        LY_STMT_LIST, &grp->data, 0,
-                                        LY_STMT_NOTIFICATION, &grp->notifs, 0,
-                                        LY_STMT_REFERENCE, &grp->ref, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_STATUS, &grp->flags, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_TYPEDEF, &grp->typedefs, 0,
-                                        LY_STMT_USES, &grp->data, 0,
-                                        LY_STMT_EXTENSION_INSTANCE, NULL, 0
-                                   ));
+            LY_STMT_ACTION, &grp->actions, 0,
+            LY_STMT_ANYDATA, &grp->data, 0,
+            LY_STMT_ANYXML, &grp->data, 0,
+            LY_STMT_CHOICE, &grp->data, 0,
+            LY_STMT_CONTAINER, &grp->data, 0,
+            LY_STMT_DESCRIPTION, &grp->dsc, YIN_SUBELEM_UNIQUE,
+            LY_STMT_GROUPING, &grp->groupings, 0,
+            LY_STMT_LEAF, &grp->data, 0,
+            LY_STMT_LEAF_LIST, &grp->data, 0,
+            LY_STMT_LIST, &grp->data, 0,
+            LY_STMT_NOTIFICATION, &grp->notifs, 0,
+            LY_STMT_REFERENCE, &grp->ref, YIN_SUBELEM_UNIQUE,
+            LY_STMT_STATUS, &grp->flags, YIN_SUBELEM_UNIQUE,
+            LY_STMT_TYPEDEF, &grp->typedefs, 0,
+            LY_STMT_USES, &grp->data, 0,
+            LY_STMT_EXTENSION_INSTANCE, NULL, 0));
     ret = yin_parse_content(ctx, subelems, 16, LY_STMT_GROUPING, NULL, &grp->exts);
     subelems_deallocator(16, subelems);
     LY_CHECK_RET(ret);
@@ -2212,28 +2231,27 @@
 
     /* parse container content */
     LY_CHECK_RET(subelems_allocator(ctx, 21, (struct lysp_node *)cont, &subelems,
-                                        LY_STMT_ACTION, &cont->actions, YIN_SUBELEM_VER2,
-                                        LY_STMT_ANYDATA, &cont->child, YIN_SUBELEM_VER2,
-                                        LY_STMT_ANYXML, &cont->child, 0,
-                                        LY_STMT_CHOICE, &cont->child, 0,
-                                        LY_STMT_CONFIG, &cont->flags, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_CONTAINER, &cont->child, 0,
-                                        LY_STMT_DESCRIPTION, &cont->dsc, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_GROUPING, &cont->groupings, 0,
-                                        LY_STMT_IF_FEATURE, &cont->iffeatures, 0,
-                                        LY_STMT_LEAF, &cont->child, 0,
-                                        LY_STMT_LEAF_LIST, &cont->child, 0,
-                                        LY_STMT_LIST, &cont->child, 0,
-                                        LY_STMT_MUST, &cont->musts, 0,
-                                        LY_STMT_NOTIFICATION, &cont->notifs, YIN_SUBELEM_VER2,
-                                        LY_STMT_PRESENCE, &cont->presence, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_REFERENCE, &cont->ref, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_STATUS, &cont->flags, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_TYPEDEF, &cont->typedefs, 0,
-                                        LY_STMT_USES, &cont->child, 0,
-                                        LY_STMT_WHEN, &cont->when, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_EXTENSION_INSTANCE, NULL, 0
-                                   ));
+            LY_STMT_ACTION, &cont->actions, YIN_SUBELEM_VER2,
+            LY_STMT_ANYDATA, &cont->child, YIN_SUBELEM_VER2,
+            LY_STMT_ANYXML, &cont->child, 0,
+            LY_STMT_CHOICE, &cont->child, 0,
+            LY_STMT_CONFIG, &cont->flags, YIN_SUBELEM_UNIQUE,
+            LY_STMT_CONTAINER, &cont->child, 0,
+            LY_STMT_DESCRIPTION, &cont->dsc, YIN_SUBELEM_UNIQUE,
+            LY_STMT_GROUPING, &cont->groupings, 0,
+            LY_STMT_IF_FEATURE, &cont->iffeatures, 0,
+            LY_STMT_LEAF, &cont->child, 0,
+            LY_STMT_LEAF_LIST, &cont->child, 0,
+            LY_STMT_LIST, &cont->child, 0,
+            LY_STMT_MUST, &cont->musts, 0,
+            LY_STMT_NOTIFICATION, &cont->notifs, YIN_SUBELEM_VER2,
+            LY_STMT_PRESENCE, &cont->presence, YIN_SUBELEM_UNIQUE,
+            LY_STMT_REFERENCE, &cont->ref, YIN_SUBELEM_UNIQUE,
+            LY_STMT_STATUS, &cont->flags, YIN_SUBELEM_UNIQUE,
+            LY_STMT_TYPEDEF, &cont->typedefs, 0,
+            LY_STMT_USES, &cont->child, 0,
+            LY_STMT_WHEN, &cont->when, YIN_SUBELEM_UNIQUE,
+            LY_STMT_EXTENSION_INSTANCE, NULL, 0));
     ret = yin_parse_content(ctx, subelems, 21, LY_STMT_CONTAINER, NULL, &cont->exts);
     subelems_deallocator(21, subelems);
     LY_CHECK_RET(ret);
@@ -2256,7 +2274,7 @@
 {
     struct lysp_node_case *cas;
     LY_ERR ret = LY_SUCCESS;
-    struct yin_subelement *subelems = NULL;;
+    struct yin_subelement *subelems = NULL;
 
     /* create new case */
     LY_LIST_NEW_RET(ctx->xmlctx->ctx, node_meta->nodes, cas, next, LY_EMEM);
@@ -2269,21 +2287,20 @@
 
     /* parse case content */
     LY_CHECK_RET(subelems_allocator(ctx, 14, (struct lysp_node *)cas, &subelems,
-                                        LY_STMT_ANYDATA, &cas->child, YIN_SUBELEM_VER2,
-                                        LY_STMT_ANYXML, &cas->child, 0,
-                                        LY_STMT_CHOICE, &cas->child, 0,
-                                        LY_STMT_CONTAINER, &cas->child, 0,
-                                        LY_STMT_DESCRIPTION, &cas->dsc, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_IF_FEATURE, &cas->iffeatures, 0,
-                                        LY_STMT_LEAF, &cas->child, 0,
-                                        LY_STMT_LEAF_LIST, &cas->child, 0,
-                                        LY_STMT_LIST, &cas->child, 0,
-                                        LY_STMT_REFERENCE, &cas->ref, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_STATUS, &cas->flags, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_USES, &cas->child, 0,
-                                        LY_STMT_WHEN, &cas->when, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_EXTENSION_INSTANCE, NULL, 0
-                                   ));
+            LY_STMT_ANYDATA, &cas->child, YIN_SUBELEM_VER2,
+            LY_STMT_ANYXML, &cas->child, 0,
+            LY_STMT_CHOICE, &cas->child, 0,
+            LY_STMT_CONTAINER, &cas->child, 0,
+            LY_STMT_DESCRIPTION, &cas->dsc, YIN_SUBELEM_UNIQUE,
+            LY_STMT_IF_FEATURE, &cas->iffeatures, 0,
+            LY_STMT_LEAF, &cas->child, 0,
+            LY_STMT_LEAF_LIST, &cas->child, 0,
+            LY_STMT_LIST, &cas->child, 0,
+            LY_STMT_REFERENCE, &cas->ref, YIN_SUBELEM_UNIQUE,
+            LY_STMT_STATUS, &cas->flags, YIN_SUBELEM_UNIQUE,
+            LY_STMT_USES, &cas->child, 0,
+            LY_STMT_WHEN, &cas->when, YIN_SUBELEM_UNIQUE,
+            LY_STMT_EXTENSION_INSTANCE, NULL, 0));
     ret = yin_parse_content(ctx, subelems, 14, LY_STMT_CASE, NULL, &cas->exts);
     subelems_deallocator(14, subelems);
 
@@ -2317,24 +2334,23 @@
 
     /* parse choice content */
     LY_CHECK_RET(subelems_allocator(ctx, 17, (struct lysp_node *)choice, &subelems,
-                                        LY_STMT_ANYDATA, &choice->child, YIN_SUBELEM_VER2,
-                                        LY_STMT_ANYXML, &choice->child, 0,
-                                        LY_STMT_CASE, &choice->child, 0,
-                                        LY_STMT_CHOICE, &choice->child, YIN_SUBELEM_VER2,
-                                        LY_STMT_CONFIG, &choice->flags, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_CONTAINER, &choice->child, 0,
-                                        LY_STMT_DEFAULT, &choice->dflt, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_DESCRIPTION, &choice->dsc, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_IF_FEATURE, &choice->iffeatures, 0,
-                                        LY_STMT_LEAF, &choice->child, 0,
-                                        LY_STMT_LEAF_LIST, &choice->child, 0,
-                                        LY_STMT_LIST, &choice->child, 0,
-                                        LY_STMT_MANDATORY, &choice->flags, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_REFERENCE, &choice->ref, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_STATUS, &choice->flags, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_WHEN, &choice->when, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_EXTENSION_INSTANCE, NULL, 0
-                                   ));
+            LY_STMT_ANYDATA, &choice->child, YIN_SUBELEM_VER2,
+            LY_STMT_ANYXML, &choice->child, 0,
+            LY_STMT_CASE, &choice->child, 0,
+            LY_STMT_CHOICE, &choice->child, YIN_SUBELEM_VER2,
+            LY_STMT_CONFIG, &choice->flags, YIN_SUBELEM_UNIQUE,
+            LY_STMT_CONTAINER, &choice->child, 0,
+            LY_STMT_DEFAULT, &choice->dflt, YIN_SUBELEM_UNIQUE,
+            LY_STMT_DESCRIPTION, &choice->dsc, YIN_SUBELEM_UNIQUE,
+            LY_STMT_IF_FEATURE, &choice->iffeatures, 0,
+            LY_STMT_LEAF, &choice->child, 0,
+            LY_STMT_LEAF_LIST, &choice->child, 0,
+            LY_STMT_LIST, &choice->child, 0,
+            LY_STMT_MANDATORY, &choice->flags, YIN_SUBELEM_UNIQUE,
+            LY_STMT_REFERENCE, &choice->ref, YIN_SUBELEM_UNIQUE,
+            LY_STMT_STATUS, &choice->flags, YIN_SUBELEM_UNIQUE,
+            LY_STMT_WHEN, &choice->when, YIN_SUBELEM_UNIQUE,
+            LY_STMT_EXTENSION_INSTANCE, NULL, 0));
     ret = yin_parse_content(ctx, subelems, 17, LY_STMT_CHOICE, NULL, &choice->exts);
     subelems_deallocator(17, subelems);
     return ret;
@@ -2365,19 +2381,18 @@
 
     /* parser input/output content */
     LY_CHECK_RET(subelems_allocator(ctx, 12, (struct lysp_node *)inout_meta->inout_p, &subelems,
-                                        LY_STMT_ANYDATA, &inout_meta->inout_p->data, YIN_SUBELEM_VER2,
-                                        LY_STMT_ANYXML, &inout_meta->inout_p->data, 0,
-                                        LY_STMT_CHOICE, &inout_meta->inout_p->data, 0,
-                                        LY_STMT_CONTAINER, &inout_meta->inout_p->data, 0,
-                                        LY_STMT_GROUPING, &inout_meta->inout_p->groupings, 0,
-                                        LY_STMT_LEAF, &inout_meta->inout_p->data, 0,
-                                        LY_STMT_LEAF_LIST, &inout_meta->inout_p->data, 0,
-                                        LY_STMT_LIST, &inout_meta->inout_p->data, 0,
-                                        LY_STMT_MUST, &inout_meta->inout_p->musts, YIN_SUBELEM_VER2,
-                                        LY_STMT_TYPEDEF, &inout_meta->inout_p->typedefs, 0,
-                                        LY_STMT_USES, &inout_meta->inout_p->data, 0,
-                                        LY_STMT_EXTENSION_INSTANCE, NULL, 0
-                                   ));
+            LY_STMT_ANYDATA, &inout_meta->inout_p->data, YIN_SUBELEM_VER2,
+            LY_STMT_ANYXML, &inout_meta->inout_p->data, 0,
+            LY_STMT_CHOICE, &inout_meta->inout_p->data, 0,
+            LY_STMT_CONTAINER, &inout_meta->inout_p->data, 0,
+            LY_STMT_GROUPING, &inout_meta->inout_p->groupings, 0,
+            LY_STMT_LEAF, &inout_meta->inout_p->data, 0,
+            LY_STMT_LEAF_LIST, &inout_meta->inout_p->data, 0,
+            LY_STMT_LIST, &inout_meta->inout_p->data, 0,
+            LY_STMT_MUST, &inout_meta->inout_p->musts, YIN_SUBELEM_VER2,
+            LY_STMT_TYPEDEF, &inout_meta->inout_p->typedefs, 0,
+            LY_STMT_USES, &inout_meta->inout_p->data, 0,
+            LY_STMT_EXTENSION_INSTANCE, NULL, 0));
     ret = yin_parse_content(ctx, subelems, 12, inout_kw, NULL, &inout_meta->inout_p->exts);
     subelems_deallocator(12, subelems);
     LY_CHECK_RET(ret);
@@ -2419,16 +2434,15 @@
 
     /* parse content */
     LY_CHECK_RET(subelems_allocator(ctx, 9, (struct lysp_node *)act, &subelems,
-                                        LY_STMT_DESCRIPTION, &act->dsc, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_GROUPING, &act->groupings, 0,
-                                        LY_STMT_IF_FEATURE, &act->iffeatures, 0,
-                                        LY_STMT_INPUT, &act->input, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_OUTPUT, &act->output, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_REFERENCE, &act->ref, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_STATUS, &act->flags, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_TYPEDEF, &act->typedefs, 0,
-                                        LY_STMT_EXTENSION_INSTANCE, NULL, 0
-                                   ));
+            LY_STMT_DESCRIPTION, &act->dsc, YIN_SUBELEM_UNIQUE,
+            LY_STMT_GROUPING, &act->groupings, 0,
+            LY_STMT_IF_FEATURE, &act->iffeatures, 0,
+            LY_STMT_INPUT, &act->input, YIN_SUBELEM_UNIQUE,
+            LY_STMT_OUTPUT, &act->output, YIN_SUBELEM_UNIQUE,
+            LY_STMT_REFERENCE, &act->ref, YIN_SUBELEM_UNIQUE,
+            LY_STMT_STATUS, &act->flags, YIN_SUBELEM_UNIQUE,
+            LY_STMT_TYPEDEF, &act->typedefs, 0,
+            LY_STMT_EXTENSION_INSTANCE, NULL, 0));
     ret = (yin_parse_content(ctx, subelems, 9, LY_STMT_ACTION, NULL, &act->exts));
     subelems_deallocator(9, subelems);
     LY_CHECK_RET(ret);
@@ -2476,24 +2490,23 @@
 
     /* parser augment content */
     LY_CHECK_RET(subelems_allocator(ctx, 17, (struct lysp_node *)aug, &subelems,
-                                        LY_STMT_ACTION, &aug->actions, YIN_SUBELEM_VER2,
-                                        LY_STMT_ANYDATA, &aug->child, YIN_SUBELEM_VER2,
-                                        LY_STMT_ANYXML, &aug->child, 0,
-                                        LY_STMT_CASE, &aug->child, 0,
-                                        LY_STMT_CHOICE, &aug->child, 0,
-                                        LY_STMT_CONTAINER, &aug->child, 0,
-                                        LY_STMT_DESCRIPTION, &aug->dsc, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_IF_FEATURE, &aug->iffeatures, YIN_SUBELEM_TEXT,
-                                        LY_STMT_LEAF, &aug->child, 0,
-                                        LY_STMT_LEAF_LIST, &aug->child, 0,
-                                        LY_STMT_LIST, &aug->child, 0,
-                                        LY_STMT_NOTIFICATION, &aug->notifs, YIN_SUBELEM_VER2,
-                                        LY_STMT_REFERENCE, &aug->ref, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_STATUS, &aug->flags, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_USES, &aug->child, 0,
-                                        LY_STMT_WHEN, &aug->when, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_EXTENSION_INSTANCE, NULL, 0
-                                   ));
+            LY_STMT_ACTION, &aug->actions, YIN_SUBELEM_VER2,
+            LY_STMT_ANYDATA, &aug->child, YIN_SUBELEM_VER2,
+            LY_STMT_ANYXML, &aug->child, 0,
+            LY_STMT_CASE, &aug->child, 0,
+            LY_STMT_CHOICE, &aug->child, 0,
+            LY_STMT_CONTAINER, &aug->child, 0,
+            LY_STMT_DESCRIPTION, &aug->dsc, YIN_SUBELEM_UNIQUE,
+            LY_STMT_IF_FEATURE, &aug->iffeatures, YIN_SUBELEM_TEXT,
+            LY_STMT_LEAF, &aug->child, 0,
+            LY_STMT_LEAF_LIST, &aug->child, 0,
+            LY_STMT_LIST, &aug->child, 0,
+            LY_STMT_NOTIFICATION, &aug->notifs, YIN_SUBELEM_VER2,
+            LY_STMT_REFERENCE, &aug->ref, YIN_SUBELEM_UNIQUE,
+            LY_STMT_STATUS, &aug->flags, YIN_SUBELEM_UNIQUE,
+            LY_STMT_USES, &aug->child, 0,
+            LY_STMT_WHEN, &aug->when, YIN_SUBELEM_UNIQUE,
+            LY_STMT_EXTENSION_INSTANCE, NULL, 0));
     ret = yin_parse_content(ctx, subelems, 17, LY_STMT_AUGMENT, NULL, &aug->exts);
     subelems_deallocator(17, subelems);
     LY_CHECK_RET(ret);
@@ -2536,7 +2549,7 @@
         dev_mod = LYS_DEV_DELETE;
     } else {
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INVAL_YIN VALID_VALS4, temp_val, "value", "deviate",
-                       "not-supported", "add", "replace", "delete");
+                "not-supported", "add", "replace", "delete");
         FREE_STRING(ctx->xmlctx->ctx, temp_val);
         return LY_EVALID;
     }
@@ -2639,6 +2652,7 @@
         {LY_STMT_REFERENCE, &dev->ref, YIN_SUBELEM_UNIQUE},
         {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
     };
+
     return yin_parse_content(ctx, subelems, 4, LY_STMT_DEVIATION, NULL, &dev->exts);
 }
 
@@ -2846,6 +2860,7 @@
 
     char *result;
     char *temp;
+
     temp = result = malloc(sizeof(*temp) * (len + 1)); /* +1 for '\0' terminator */
     LY_CHECK_ERR_RET(!temp, LOGMEM(ctx->xmlctx->ctx), NULL);
 
@@ -2886,23 +2901,23 @@
             /* match keyword */
             last_kw = kw;
             kw = yin_match_keyword(ctx, ctx->xmlctx->name, ctx->xmlctx->name_len, ctx->xmlctx->prefix,
-                                   ctx->xmlctx->prefix_len, current_element);
+                    ctx->xmlctx->prefix_len, current_element);
 
             /* check if this element can be child of current element */
             subelem = get_record(kw, subelem_info_size, subelem_info);
             if (!subelem) {
-                if (current_element == LY_STMT_DEVIATE && isdevsub(kw)) {
+                if ((current_element == LY_STMT_DEVIATE) && isdevsub(kw)) {
                     LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_INDEV_YIN, ly_stmt2str(kw));
                 } else {
                     LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_UNEXP_SUBELEM, ctx->xmlctx->name_len,
-                                  ctx->xmlctx->name, ly_stmt2str(current_element));
+                            ctx->xmlctx->name, ly_stmt2str(current_element));
                 }
                 ret = LY_EVALID;
                 goto cleanup;
             }
 
             /* relative order is required only in module and submodule sub-elements */
-            if (current_element == LY_STMT_MODULE || current_element == LY_STMT_SUBMODULE) {
+            if ((current_element == LY_STMT_MODULE) || (current_element == LY_STMT_SUBMODULE)) {
                 ret = yin_check_relative_order(ctx, last_kw, kw, current_element);
                 LY_CHECK_GOTO(ret, cleanup);
             }
@@ -2933,7 +2948,7 @@
             /* call responsible function */
             case LY_STMT_EXTENSION_INSTANCE:
                 ret = yin_parse_extension_instance(ctx, kw2lyext_substmt(current_element),
-                                (subelem->dest) ? *((LY_ARRAY_COUNT_TYPE *)subelem->dest) : 0, exts);
+                        (subelem->dest) ? *((LY_ARRAY_COUNT_TYPE *)subelem->dest) : 0, exts);
                 break;
             case LY_STMT_ACTION:
             case LY_STMT_RPC:
@@ -3340,16 +3355,16 @@
         }
         if (((ctx->xmlctx->status == LYXML_ELEM_CONTENT) && !ctx->xmlctx->ws_only) || (ctx->xmlctx->status != LYXML_ELEMENT)) {
             LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_FIRT_SUBELEM,
-                          elem_type == LY_STMT_ERROR_MESSAGE ? "value" : "text", ly_stmt2str(elem_type));
+                    elem_type == LY_STMT_ERROR_MESSAGE ? "value" : "text", ly_stmt2str(elem_type));
             return LY_EVALID;
         }
 
         /* parse child element */
         child = yin_match_keyword(ctx, ctx->xmlctx->name, ctx->xmlctx->name_len, ctx->xmlctx->prefix, ctx->xmlctx->prefix_len, elem_type);
-        if ((elem_type == LY_STMT_ERROR_MESSAGE && child != LY_STMT_ARG_VALUE) ||
-                (elem_type != LY_STMT_ERROR_MESSAGE && child != LY_STMT_ARG_TEXT)) {
+        if (((elem_type == LY_STMT_ERROR_MESSAGE) && (child != LY_STMT_ARG_VALUE)) ||
+                ((elem_type != LY_STMT_ERROR_MESSAGE) && (child != LY_STMT_ARG_TEXT))) {
             LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_UNEXP_SUBELEM, ctx->xmlctx->name_len, ctx->xmlctx->name,
-                          ly_stmt2str(elem_type));
+                    ly_stmt2str(elem_type));
             return LY_EVALID;
         }
         LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
@@ -3395,13 +3410,13 @@
     LY_CHECK_ERR_GOTO(!(*element)->stmt, ret = LY_EMEM, cleanup);
 
     (*element)->kw = yin_match_keyword(ctx, ctx->xmlctx->name, ctx->xmlctx->name_len, ctx->xmlctx->prefix,
-                                       ctx->xmlctx->prefix_len, parent);
+            ctx->xmlctx->prefix_len, parent);
 
     last = (*element)->child;
     if ((*element)->kw == LY_STMT_NONE) {
         /* unrecognized element */
         LOGVAL_PARSER((struct lys_parser_ctx *)ctx, LY_VCODE_UNEXP_SUBELEM, ctx->xmlctx->name_len, ctx->xmlctx->name,
-                      ly_stmt2str(parent));
+                ly_stmt2str(parent));
         ret = LY_EVALID;
         goto cleanup;
     } else if ((*element)->kw != LY_STMT_EXTENSION_INSTANCE) {
@@ -3483,35 +3498,34 @@
     LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
     LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_NAME, &mod->mod->name, Y_IDENTIF_ARG, LY_STMT_MODULE));
     LY_CHECK_RET(subelems_allocator(ctx, 28, NULL, &subelems,
-                                            LY_STMT_ANYDATA, &mod->data, YIN_SUBELEM_VER2,
-                                            LY_STMT_ANYXML, &mod->data, 0,
-                                            LY_STMT_AUGMENT, &mod->augments, 0,
-                                            LY_STMT_CHOICE, &mod->data, 0,
-                                            LY_STMT_CONTACT, &mod->mod->contact, YIN_SUBELEM_UNIQUE,
-                                            LY_STMT_CONTAINER, &mod->data, 0,
-                                            LY_STMT_DESCRIPTION, &mod->mod->dsc, YIN_SUBELEM_UNIQUE,
-                                            LY_STMT_DEVIATION, &mod->deviations, 0,
-                                            LY_STMT_EXTENSION, &mod->extensions, 0,
-                                            LY_STMT_FEATURE, &mod->features, 0,
-                                            LY_STMT_GROUPING, &mod->groupings, 0,
-                                            LY_STMT_IDENTITY, &mod->identities, 0,
-                                            LY_STMT_IMPORT, mod->mod->prefix, &mod->imports, 0,
-                                            LY_STMT_INCLUDE, mod->mod->name, &mod->includes, 0,
-                                            LY_STMT_LEAF, &mod->data, 0,
-                                            LY_STMT_LEAF_LIST, &mod->data, 0,
-                                            LY_STMT_LIST, &mod->data, 0,
-                                            LY_STMT_NAMESPACE, &mod->mod->ns, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
-                                            LY_STMT_NOTIFICATION, &mod->notifs, 0,
-                                            LY_STMT_ORGANIZATION, &mod->mod->org, YIN_SUBELEM_UNIQUE,
-                                            LY_STMT_PREFIX, &mod->mod->prefix, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
-                                            LY_STMT_REFERENCE, &mod->mod->ref, YIN_SUBELEM_UNIQUE,
-                                            LY_STMT_REVISION, &mod->revs, 0,
-                                            LY_STMT_RPC, &mod->rpcs, 0,
-                                            LY_STMT_TYPEDEF, &mod->typedefs, 0,
-                                            LY_STMT_USES, &mod->data, 0,
-                                            LY_STMT_YANG_VERSION, &mod->mod->version, YIN_SUBELEM_UNIQUE,
-                                            LY_STMT_EXTENSION_INSTANCE, NULL, 0
-                                   ));
+            LY_STMT_ANYDATA, &mod->data, YIN_SUBELEM_VER2,
+            LY_STMT_ANYXML, &mod->data, 0,
+            LY_STMT_AUGMENT, &mod->augments, 0,
+            LY_STMT_CHOICE, &mod->data, 0,
+            LY_STMT_CONTACT, &mod->mod->contact, YIN_SUBELEM_UNIQUE,
+            LY_STMT_CONTAINER, &mod->data, 0,
+            LY_STMT_DESCRIPTION, &mod->mod->dsc, YIN_SUBELEM_UNIQUE,
+            LY_STMT_DEVIATION, &mod->deviations, 0,
+            LY_STMT_EXTENSION, &mod->extensions, 0,
+            LY_STMT_FEATURE, &mod->features, 0,
+            LY_STMT_GROUPING, &mod->groupings, 0,
+            LY_STMT_IDENTITY, &mod->identities, 0,
+            LY_STMT_IMPORT, mod->mod->prefix, &mod->imports, 0,
+            LY_STMT_INCLUDE, mod->mod->name, &mod->includes, 0,
+            LY_STMT_LEAF, &mod->data, 0,
+            LY_STMT_LEAF_LIST, &mod->data, 0,
+            LY_STMT_LIST, &mod->data, 0,
+            LY_STMT_NAMESPACE, &mod->mod->ns, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
+            LY_STMT_NOTIFICATION, &mod->notifs, 0,
+            LY_STMT_ORGANIZATION, &mod->mod->org, YIN_SUBELEM_UNIQUE,
+            LY_STMT_PREFIX, &mod->mod->prefix, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
+            LY_STMT_REFERENCE, &mod->mod->ref, YIN_SUBELEM_UNIQUE,
+            LY_STMT_REVISION, &mod->revs, 0,
+            LY_STMT_RPC, &mod->rpcs, 0,
+            LY_STMT_TYPEDEF, &mod->typedefs, 0,
+            LY_STMT_USES, &mod->data, 0,
+            LY_STMT_YANG_VERSION, &mod->mod->version, YIN_SUBELEM_UNIQUE,
+            LY_STMT_EXTENSION_INSTANCE, NULL, 0));
 
     ret = yin_parse_content(ctx, subelems, 28, LY_STMT_MODULE, NULL, &mod->exts);
     subelems_deallocator(28, subelems);
@@ -3543,34 +3557,33 @@
     LY_CHECK_RET(lyxml_ctx_next(ctx->xmlctx));
     LY_CHECK_RET(yin_parse_attribute(ctx, YIN_ARG_NAME, &submod->name, Y_IDENTIF_ARG, LY_STMT_SUBMODULE));
     LY_CHECK_RET(subelems_allocator(ctx, 27, NULL, &subelems,
-                                        LY_STMT_ANYDATA, &submod->data, YIN_SUBELEM_VER2,
-                                        LY_STMT_ANYXML, &submod->data, 0,
-                                        LY_STMT_AUGMENT, &submod->augments, 0,
-                                        LY_STMT_BELONGS_TO, submod, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_CHOICE, &submod->data, 0,
-                                        LY_STMT_CONTACT, &submod->contact, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_CONTAINER, &submod->data, 0,
-                                        LY_STMT_DESCRIPTION, &submod->dsc, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_DEVIATION, &submod->deviations, 0,
-                                        LY_STMT_EXTENSION, &submod->extensions, 0,
-                                        LY_STMT_FEATURE, &submod->features, 0,
-                                        LY_STMT_GROUPING, &submod->groupings, 0,
-                                        LY_STMT_IDENTITY, &submod->identities, 0,
-                                        LY_STMT_IMPORT, submod->prefix, &submod->imports, 0,
-                                        LY_STMT_INCLUDE, submod->name, &submod->includes, 0,
-                                        LY_STMT_LEAF, &submod->data, 0,
-                                        LY_STMT_LEAF_LIST, &submod->data, 0,
-                                        LY_STMT_LIST, &submod->data, 0,
-                                        LY_STMT_NOTIFICATION, &submod->notifs, 0,
-                                        LY_STMT_ORGANIZATION, &submod->org, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_REFERENCE, &submod->ref, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_REVISION, &submod->revs, 0,
-                                        LY_STMT_RPC, &submod->rpcs, 0,
-                                        LY_STMT_TYPEDEF, &submod->typedefs, 0,
-                                        LY_STMT_USES, &submod->data, 0,
-                                        LY_STMT_YANG_VERSION, &submod->version, YIN_SUBELEM_UNIQUE,
-                                        LY_STMT_EXTENSION_INSTANCE, NULL, 0
-                                   ));
+            LY_STMT_ANYDATA, &submod->data, YIN_SUBELEM_VER2,
+            LY_STMT_ANYXML, &submod->data, 0,
+            LY_STMT_AUGMENT, &submod->augments, 0,
+            LY_STMT_BELONGS_TO, submod, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE,
+            LY_STMT_CHOICE, &submod->data, 0,
+            LY_STMT_CONTACT, &submod->contact, YIN_SUBELEM_UNIQUE,
+            LY_STMT_CONTAINER, &submod->data, 0,
+            LY_STMT_DESCRIPTION, &submod->dsc, YIN_SUBELEM_UNIQUE,
+            LY_STMT_DEVIATION, &submod->deviations, 0,
+            LY_STMT_EXTENSION, &submod->extensions, 0,
+            LY_STMT_FEATURE, &submod->features, 0,
+            LY_STMT_GROUPING, &submod->groupings, 0,
+            LY_STMT_IDENTITY, &submod->identities, 0,
+            LY_STMT_IMPORT, submod->prefix, &submod->imports, 0,
+            LY_STMT_INCLUDE, submod->name, &submod->includes, 0,
+            LY_STMT_LEAF, &submod->data, 0,
+            LY_STMT_LEAF_LIST, &submod->data, 0,
+            LY_STMT_LIST, &submod->data, 0,
+            LY_STMT_NOTIFICATION, &submod->notifs, 0,
+            LY_STMT_ORGANIZATION, &submod->org, YIN_SUBELEM_UNIQUE,
+            LY_STMT_REFERENCE, &submod->ref, YIN_SUBELEM_UNIQUE,
+            LY_STMT_REVISION, &submod->revs, 0,
+            LY_STMT_RPC, &submod->rpcs, 0,
+            LY_STMT_TYPEDEF, &submod->typedefs, 0,
+            LY_STMT_USES, &submod->data, 0,
+            LY_STMT_YANG_VERSION, &submod->version, YIN_SUBELEM_UNIQUE,
+            LY_STMT_EXTENSION_INSTANCE, NULL, 0));
 
     ret = yin_parse_content(ctx, subelems, 27, LY_STMT_SUBMODULE, NULL, &submod->exts);
     subelems_deallocator(27, subelems);
@@ -3611,7 +3624,7 @@
 
     /* check submodule */
     kw = yin_match_keyword(*yin_ctx, (*yin_ctx)->xmlctx->name, (*yin_ctx)->xmlctx->name_len, (*yin_ctx)->xmlctx->prefix,
-                    (*yin_ctx)->xmlctx->prefix_len, LY_STMT_NONE);
+            (*yin_ctx)->xmlctx->prefix_len, LY_STMT_NONE);
     if (kw == LY_STMT_MODULE) {
         LOGERR(ctx, LY_EDENIED, "Input data contains module in situation when a submodule is expected.");
         ret = LY_EINVAL;
@@ -3636,7 +3649,7 @@
     }
     if (in->current[0]) {
         LOGVAL_PARSER((struct lys_parser_ctx *)*yin_ctx, LY_VCODE_TRAILING_SUBMOD, 15, in->current,
-                      strlen(in->current) > 15 ? "..." : "");
+                strlen(in->current) > 15 ? "..." : "");
         ret = LY_EVALID;
         goto cleanup;
     }
@@ -3669,7 +3682,7 @@
 
     /* check module */
     kw = yin_match_keyword(*yin_ctx, (*yin_ctx)->xmlctx->name, (*yin_ctx)->xmlctx->name_len, (*yin_ctx)->xmlctx->prefix,
-                    (*yin_ctx)->xmlctx->prefix_len, LY_STMT_NONE);
+            (*yin_ctx)->xmlctx->prefix_len, LY_STMT_NONE);
     if (kw == LY_STMT_SUBMODULE) {
         LOGERR(mod->ctx, LY_EDENIED, "Input data contains submodule which cannot be parsed directly without its main module.");
         ret = LY_EINVAL;
@@ -3696,7 +3709,7 @@
     }
     if (in->current[0]) {
         LOGVAL_PARSER((struct lys_parser_ctx *)*yin_ctx, LY_VCODE_TRAILING_MOD, 15, in->current,
-                      strlen(in->current) > 15 ? "..." : "");
+                strlen(in->current) > 15 ? "..." : "");
         ret = LY_EVALID;
         goto cleanup;
     }
diff --git a/src/parser_yin.h b/src/parser_yin.h
index f5a8d85..94c5dc0 100644
--- a/src/parser_yin.h
+++ b/src/parser_yin.h
@@ -49,7 +49,7 @@
     YIN_ARG_URI,           /**< argument uri */
     YIN_ARG_DATE,          /**< argument data */
     YIN_ARG_TAG,           /**< argument tag */
-    YIN_ARG_NONE,          /**< empty (special value) */
+    YIN_ARG_NONE           /**< empty (special value) */
 };
 
 /* flags to set constraints of subelements */
diff --git a/src/path.c b/src/path.c
index 4b0ec07..2ec3b73 100644
--- a/src/path.c
+++ b/src/path.c
@@ -57,8 +57,8 @@
     if (!lyxp_next_token(NULL, exp, tok_idx, LYXP_TOKEN_BRACK1)) {
         /* '[' */
 
-        if (((pred == LY_PATH_PRED_SIMPLE) || (pred == LY_PATH_PRED_KEYS))
-                && !lyxp_check_token(NULL, exp, *tok_idx, LYXP_TOKEN_NAMETEST)) {
+        if (((pred == LY_PATH_PRED_SIMPLE) || (pred == LY_PATH_PRED_KEYS)) &&
+                !lyxp_check_token(NULL, exp, *tok_idx, LYXP_TOKEN_NAMETEST)) {
             ret = ly_set_new(&set);
             LY_CHECK_GOTO(ret, cleanup);
 
@@ -70,11 +70,11 @@
                 name = strnstr(exp->expr + exp->tok_pos[*tok_idx], ":", exp->tok_len[*tok_idx]);
                 if ((prefix == LY_PATH_PREFIX_MANDATORY) && !name) {
                     LOGVAL_P(ctx, cur_node, LYVE_XPATH, "Prefix missing for \"%.*s\" in path.", exp->tok_len[*tok_idx],
-                             exp->expr + exp->tok_pos[*tok_idx]);
+                            exp->expr + exp->tok_pos[*tok_idx]);
                     goto token_error;
                 } else if ((prefix == LY_PATH_PREFIX_STRICT_INHERIT) && name) {
                     LOGVAL_P(ctx, cur_node, LYVE_XPATH, "Redundant prefix for \"%.*s\" in path.", exp->tok_len[*tok_idx],
-                             exp->expr + exp->tok_pos[*tok_idx]);
+                            exp->expr + exp->tok_pos[*tok_idx]);
                     goto token_error;
                 }
                 if (!name) {
@@ -172,7 +172,7 @@
                 LY_CHECK_GOTO(lyxp_check_token(ctx, exp, *tok_idx, LYXP_TOKEN_FUNCNAME), token_error);
                 if ((exp->tok_len[*tok_idx] != 7) || strncmp(exp->expr + exp->tok_pos[*tok_idx], "current", 7)) {
                     LOGVAL_P(ctx, cur_node, LYVE_XPATH, "Invalid function \"%.*s\" invocation in path.",
-                             exp->tok_len[*tok_idx], exp->expr + exp->tok_pos[*tok_idx]);
+                            exp->tok_len[*tok_idx], exp->expr + exp->tok_pos[*tok_idx]);
                     goto token_error;
                 }
                 ++(*tok_idx);
@@ -210,7 +210,7 @@
 
         } else {
             LOGVAL_P(ctx, cur_node, LY_VCODE_XP_INTOK, lyxp_print_token(exp->tokens[*tok_idx]),
-                     exp->expr + exp->tok_pos[*tok_idx]);
+                    exp->expr + exp->tok_pos[*tok_idx]);
             goto token_error;
         }
     }
@@ -235,8 +235,8 @@
 
     assert((begin == LY_PATH_BEGIN_ABSOLUTE) || (begin == LY_PATH_BEGIN_EITHER));
     assert((lref == LY_PATH_LREF_TRUE) || (lref == LY_PATH_LREF_FALSE));
-    assert((prefix == LY_PATH_PREFIX_OPTIONAL) || (prefix == LY_PATH_PREFIX_MANDATORY)
-            || (prefix == LY_PATH_PREFIX_STRICT_INHERIT));
+    assert((prefix == LY_PATH_PREFIX_OPTIONAL) || (prefix == LY_PATH_PREFIX_MANDATORY) ||
+            (prefix == LY_PATH_PREFIX_STRICT_INHERIT));
     assert((pred == LY_PATH_PRED_KEYS) || (pred == LY_PATH_PRED_SIMPLE) || (pred == LY_PATH_PRED_LEAFREF));
 
     /* parse as a generic XPath expression */
@@ -308,7 +308,7 @@
     /* trailing token check */
     if (exp->used > tok_idx) {
         LOGVAL_P(ctx, ctx_node, LYVE_XPATH, "Unparsed characters \"%s\" left at the end of path.",
-                 exp->expr + exp->tok_pos[tok_idx]);
+                exp->expr + exp->tok_pos[tok_idx]);
         ret = LY_EVALID;
         goto error;
     }
@@ -341,7 +341,7 @@
     /* trailing token check */
     if (exp->used > tok_idx) {
         LOGVAL_P(ctx, cur_node, LYVE_XPATH, "Unparsed characters \"%s\" left at the end of predicate.",
-                 exp->expr + exp->tok_pos[tok_idx]);
+                exp->expr + exp->tok_pos[tok_idx]);
         ret = LY_EVALID;
         goto error;
     }
@@ -391,7 +391,7 @@
         *mod = ly_resolve_prefix(ctx, expr->expr + expr->tok_pos[tok_idx], len, format, prefix_data);
         if (!*mod) {
             LOGVAL_P(ctx, cur_node, LYVE_XPATH, "Prefix \"%.*s\" not found of a module in path.",
-                     len, expr->expr + expr->tok_pos[tok_idx]);
+                    len, expr->expr + expr->tok_pos[tok_idx]);
             return LY_EVALID;
         } else if (!(*mod)->implemented) {
             if (lref == LY_PATH_LREF_FALSE) {
@@ -453,25 +453,25 @@
     if (expr->tokens[*tok_idx] == LYXP_TOKEN_NAMETEST) {
         if (ctx_node->nodetype != LYS_LIST) {
             LOGVAL_P(ctx, cur_node, LYVE_XPATH, "List predicate defined for %s \"%s\" in path.",
-                     lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
+                    lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
             return LY_EVALID;
         } else if (ctx_node->flags & LYS_KEYLESS) {
             LOGVAL_P(ctx, cur_node, LYVE_XPATH, "List predicate defined for keyless %s \"%s\" in path.",
-                     lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
+                    lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
             return LY_EVALID;
         }
 
         do {
             /* NameTest, find the key */
             LY_CHECK_RET(ly_path_compile_prefix(ctx, cur_node, cur_mod, ctx_node, expr, *tok_idx, LY_PATH_LREF_FALSE,
-                                                format, prefix_data, &mod, &name, &name_len));
+                    format, prefix_data, &mod, &name, &name_len));
             key = lys_find_child(ctx_node, mod, name, name_len, 0, LYS_GETNEXT_NOSTATECHECK);
             if (!key) {
                 LOGVAL_P(ctx, cur_node, LYVE_XPATH, "Not found node \"%.*s\" in path.", name_len, name);
                 return LY_ENOTFOUND;
             } else if ((key->nodetype != LYS_LEAF) || !(key->flags & LYS_KEY)) {
                 LOGVAL_P(ctx, cur_node ? cur_node : key, LYVE_XPATH, "Key expected instead of %s \"%s\" in path.",
-                         lys_nodetype2str(key->nodetype), key->name);
+                        lys_nodetype2str(key->nodetype), key->name);
                 return LY_EVALID;
             }
             ++(*tok_idx);
@@ -510,7 +510,7 @@
         if (LY_ARRAY_COUNT(*predicates) != key_count) {
             /* names (keys) are unique - it was checked when parsing */
             LOGVAL_P(ctx, cur_node, LYVE_XPATH, "Predicate missing for a key of %s \"%s\" in path.",
-                     lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
+                    lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
             ly_path_predicates_free(ctx, LY_PATH_PREDTYPE_LIST, NULL, *predicates);
             *predicates = NULL;
             return LY_EVALID;
@@ -519,7 +519,7 @@
     } else if (expr->tokens[*tok_idx] == LYXP_TOKEN_DOT) {
         if (ctx_node->nodetype != LYS_LEAFLIST) {
             LOGVAL_P(ctx, cur_node, LYVE_XPATH, "Leaf-list predicate defined for %s \"%s\" in path.",
-                     lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
+                    lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
             return LY_EVALID;
         }
         ++(*tok_idx);
@@ -546,11 +546,11 @@
         assert(expr->tokens[*tok_idx] == LYXP_TOKEN_NUMBER);
         if (!(ctx_node->nodetype & (LYS_LEAFLIST | LYS_LIST))) {
             LOGVAL_P(ctx, cur_node, LYVE_XPATH, "Positional predicate defined for %s \"%s\" in path.",
-                     lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
+                    lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
             return LY_EVALID;
         } else if (ctx_node->flags & LYS_CONFIG_W) {
             LOGVAL_P(ctx, cur_node, LYVE_XPATH, "Positional predicate defined for configuration %s \"%s\" in path.",
-                     lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
+                    lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
             return LY_EVALID;
         }
 
@@ -597,25 +597,25 @@
 
     if (ctx_node->nodetype != LYS_LIST) {
         LOGVAL_P(cur_node->module->ctx, cur_node, LYVE_XPATH, "List predicate defined for %s \"%s\" in path.",
-                 lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
+                lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
         return LY_EVALID;
     } else if (ctx_node->flags & LYS_KEYLESS) {
         LOGVAL_P(cur_node->module->ctx, cur_node, LYVE_XPATH, "List predicate defined for keyless %s \"%s\" in path.",
-                 lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
+                lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
         return LY_EVALID;
     }
 
     do {
         /* NameTest, find the key */
         LY_CHECK_RET(ly_path_compile_prefix(cur_node->module->ctx, cur_node, cur_node->module, ctx_node, expr, *tok_idx,
-                                            LY_PATH_LREF_TRUE, format, prefix_data, &mod, &name, &name_len));
+                LY_PATH_LREF_TRUE, format, prefix_data, &mod, &name, &name_len));
         key = lys_find_child(ctx_node, mod, name, name_len, 0, LYS_GETNEXT_NOSTATECHECK);
         if (!key) {
             LOGVAL_P(cur_node->module->ctx, cur_node, LYVE_XPATH, "Not found node \"%.*s\" in path.", name_len, name);
             return LY_EVALID;
         } else if ((key->nodetype != LYS_LEAF) || !(key->flags & LYS_KEY)) {
             LOGVAL_P(cur_node->module->ctx, cur_node, LYVE_XPATH, "Key expected instead of %s \"%s\" in path.",
-                     lys_nodetype2str(key->nodetype), key->name);
+                    lys_nodetype2str(key->nodetype), key->name);
             return LY_EVALID;
         }
         ++(*tok_idx);
@@ -667,7 +667,7 @@
             /* NameTest */
             assert(expr->tokens[*tok_idx] == LYXP_TOKEN_NAMETEST);
             LY_CHECK_RET(ly_path_compile_prefix(cur_node->module->ctx, cur_node, cur_node->module, node, expr, *tok_idx,
-                                                LY_PATH_LREF_TRUE, format, prefix_data, &mod, &name, &name_len));
+                    LY_PATH_LREF_TRUE, format, prefix_data, &mod, &name, &name_len));
             node2 = lys_find_child(node, mod, name, name_len, 0, LYS_GETNEXT_NOSTATECHECK);
             if (!node2) {
                 LOGVAL_P(cur_node->module->ctx, cur_node, LYVE_XPATH, "Not found node \"%.*s\" in path.", name_len, name);
@@ -680,8 +680,8 @@
         /* check the last target node */
         if (node->nodetype != LYS_LEAF) {
             LOGVAL_P(cur_node->module->ctx, cur_node, LYVE_XPATH,
-                     "Leaf expected instead of %s \"%s\" in leafref predicate in path.",
-                     lys_nodetype2str(node->nodetype), node->name);
+                    "Leaf expected instead of %s \"%s\" in leafref predicate in path.",
+                    lys_nodetype2str(node->nodetype), node->name);
             return LY_EVALID;
         }
 
@@ -762,13 +762,13 @@
         /* check last compiled inner node, whether it is uniquely identified (even key-less list) */
         if (p && (lref == LY_PATH_LREF_FALSE) && (p->node->nodetype == LYS_LIST) && !p->predicates) {
             LOGVAL_P(ctx, cur_node, LYVE_XPATH, "Predicate missing for %s \"%s\" in path.",
-                     lys_nodetype2str(p->node->nodetype), p->node->name);
+                    lys_nodetype2str(p->node->nodetype), p->node->name);
             return LY_EVALID;
         }
 
         /* get module and node name */
         LY_CHECK_GOTO(ret = ly_path_compile_prefix(ctx, cur_node, cur_mod, ctx_node, expr, tok_idx, lref, format,
-                                                   prefix_data, &mod, &name, &name_len), cleanup);
+                prefix_data, &mod, &name, &name_len), cleanup);
         ++tok_idx;
 
         /* find the next node */
@@ -789,16 +789,16 @@
             ret = ly_path_compile_predicate_leafref(ctx_node, cur_node, expr, &tok_idx, format, prefix_data);
         } else {
             ret = ly_path_compile_predicate(ctx, cur_node, cur_mod, ctx_node, expr, &tok_idx, format, prefix_data,
-                                            &p->predicates, &p->pred_type);
+                    &p->predicates, &p->pred_type);
         }
         LY_CHECK_GOTO(ret, cleanup);
     } while (!lyxp_next_token(NULL, expr, &tok_idx, LYXP_TOKEN_OPER_PATH));
 
     /* check last compiled node */
-    if ((lref == LY_PATH_LREF_FALSE) && (target == LY_PATH_TARGET_SINGLE)
-            && (p->node->nodetype & (LYS_LIST | LYS_LEAFLIST)) && !p->predicates) {
+    if ((lref == LY_PATH_LREF_FALSE) && (target == LY_PATH_TARGET_SINGLE) &&
+            (p->node->nodetype & (LYS_LIST | LYS_LEAFLIST)) && !p->predicates) {
         LOGVAL_P(ctx, cur_node, LYVE_XPATH, "Predicate missing for %s \"%s\" in path.",
-                 lys_nodetype2str(p->node->nodetype), p->node->name);
+                lys_nodetype2str(p->node->nodetype), p->node->name);
         return LY_EVALID;
     }
 
diff --git a/src/plugins_exts_internal.h b/src/plugins_exts_internal.h
index 18fb33a..fac88f4 100644
--- a/src/plugins_exts_internal.h
+++ b/src/plugins_exts_internal.h
@@ -15,8 +15,8 @@
 #ifndef LY_PLUGINS_EXTS_INTERNAL_H_
 #define LY_PLUGINS_EXTS_INTERNAL_H_
 
-#include "tree_schema.h"
 #include "plugins_exts.h"
+#include "tree_schema.h"
 
 #include "plugins_exts_metadata.h"
 
diff --git a/src/plugins_exts_metadata.c b/src/plugins_exts_metadata.c
index 359ffb5..1e8364c 100644
--- a/src/plugins_exts_metadata.c
+++ b/src/plugins_exts_metadata.c
@@ -16,8 +16,8 @@
 #include <stdlib.h>
 
 #include "plugins_exts.h"
-#include "tree_schema.h"
 #include "plugins_exts_metadata.h"
+#include "tree_schema.h"
 
 /**
  * @brief Storage for ID used to check plugin API version compatibility.
@@ -50,13 +50,13 @@
     /* annotations can appear only at the top level of a YANG module or submodule */
     if (c_ext->parent_type != LYEXT_PAR_MODULE) {
         lyext_log(c_ext, LY_LLERR, LY_EVALID, cctx->path, "Extension %s is allowed only at the top level of a YANG module or submodule, but it is placed in \"%s\" statement.",
-                  p_ext->name, lyext_parent2str(c_ext->parent_type));
+                p_ext->name, lyext_parent2str(c_ext->parent_type));
         return LY_EVALID;
     }
     /* check mandatory argument */
     if (!c_ext->argument) {
         lyext_log(c_ext, LY_LLERR, LY_EVALID, cctx->path, "Extension %s is instantiated without mandatory argument representing metadata name.",
-                  p_ext->name);
+                p_ext->name);
         return LY_EVALID;
     }
 
@@ -64,7 +64,7 @@
 
     /* check for duplication */
     LY_ARRAY_FOR(mod_c->exts, u) {
-        if (&mod_c->exts[u] != c_ext && mod_c->exts[u].def == c_ext->def && !strcmp(mod_c->exts[u].argument, c_ext->argument)) {
+        if ((&mod_c->exts[u] != c_ext) && (mod_c->exts[u].def == c_ext->def) && !strcmp(mod_c->exts[u].argument, c_ext->argument)) {
             /* duplication of the same annotation extension in a single module */
             lyext_log(c_ext, LY_LLERR, LY_EVALID, cctx->path, "Extension %s is instantiated multiple times.", p_ext->name);
             return LY_EVALID;
@@ -98,6 +98,7 @@
     }
 
     struct lyext_metadata *annotation = (struct lyext_metadata *)ext->data;
+
     annotation_substmt[0].storage = &annotation->iffeatures;
     annotation_substmt[1].storage = &annotation->units;
     annotation_substmt[2].storage = &annotation->flags;
diff --git a/src/plugins_exts_nacm.c b/src/plugins_exts_nacm.c
index 5be0619..b98fc03 100644
--- a/src/plugins_exts_nacm.c
+++ b/src/plugins_exts_nacm.c
@@ -51,27 +51,27 @@
     /* check that the extension is instantiated at an allowed place - data node */
     if (c_ext->parent_type != LYEXT_PAR_NODE) {
         lyext_log(c_ext, LY_LLERR, LY_EVALID, cctx->path, "Extension %s is allowed only in a data nodes, but it is placed in \"%s\" statement.",
-                  p_ext->name, lyext_parent2str(c_ext->parent_type));
+                p_ext->name, lyext_parent2str(c_ext->parent_type));
         return LY_EVALID;
     } else {
         parent = (struct lysc_node *)c_ext->parent;
-        if (!(parent->nodetype & (LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | LYS_CHOICE | LYS_ANYDATA
-                | LYS_CASE | LYS_RPC | LYS_ACTION | LYS_NOTIF))) {
+        if (!(parent->nodetype & (LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | LYS_CHOICE | LYS_ANYDATA |
+                LYS_CASE | LYS_RPC | LYS_ACTION | LYS_NOTIF))) {
             /* note LYS_AUGMENT and LYS_USES is not in the list since they are not present in the compiled tree. Instead, libyang
              * passes all their extensions to their children nodes */
 invalid_parent:
             lyext_log(c_ext, LY_LLERR, LY_EVALID, cctx->path,
-                      "Extension %s is not allowed in %s statement.", p_ext->name, lys_nodetype2str(parent->nodetype));
+                    "Extension %s is not allowed in %s statement.", p_ext->name, lys_nodetype2str(parent->nodetype));
             return LY_EVALID;
         }
-        if (c_ext->data == (void *)&nacm_deny_write && (parent->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF))) {
+        if ((c_ext->data == (void *)&nacm_deny_write) && (parent->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF))) {
             goto invalid_parent;
         }
     }
 
     /* check for duplication */
     LY_ARRAY_FOR(parent->exts, u) {
-        if (&parent->exts[u] != c_ext && parent->exts[u].def->plugin == c_ext->def->plugin) {
+        if ((&parent->exts[u] != c_ext) && (parent->exts[u].def->plugin == c_ext->def->plugin)) {
             /* duplication of a NACM extension on a single node
              * We check plugin since we want to catch even the situation that there is default-deny-all
              * AND default-deny-write */
diff --git a/src/plugins_types.c b/src/plugins_types.c
index 50af84c..4b16ecb 100644
--- a/src/plugins_types.c
+++ b/src/plugins_types.c
@@ -301,7 +301,7 @@
         goto error;
     } else if (!isdigit(value[len]) && (value[len] != '-') && (value[len] != '+')) {
         if (asprintf(&errmsg, "Invalid %lu. character of decimal64 value \"%.*s\".",
-                     len + 1, (int)value_len, value) == -1) {
+                len + 1, (int)value_len, value) == -1) {
             errmsg = NULL;
             rc = LY_EMEM;
         }
@@ -317,7 +317,7 @@
     }
 
     trailing_zeros = 0;
-    if (len < value_len && ((value[len] != '.') || !isdigit(value[len + 1]))) {
+    if ((len < value_len) && ((value[len] != '.') || !isdigit(value[len + 1]))) {
         goto decimal;
     }
     fraction = len;
@@ -335,7 +335,7 @@
 decimal:
     if (fraction && (len - 1 - fraction > fraction_digits)) {
         if (asprintf(&errmsg, "Value \"%.*s\" of decimal64 type exceeds defined number (%u) of fraction digits.", (int)len, value,
-                     fraction_digits) == -1) {
+                fraction_digits) == -1) {
             errmsg = NULL;
             rc = LY_EMEM;
         }
@@ -353,7 +353,7 @@
         for (u = len + trailing_zeros; u < value_len && isspace(value[u]); ++u) {}
         if (u != value_len) {
             if (asprintf(&errmsg, "Invalid %lu. character of decimal64 value \"%.*s\".",
-                         u + 1, (int)value_len, value) == -1) {
+                    u + 1, (int)value_len, value) == -1) {
                 errmsg = NULL;
                 rc = LY_EMEM;
             }
@@ -431,7 +431,7 @@
             goto cleanup;
         }
 
-    cleanup:
+cleanup:
         pcre2_match_data_free(match_data);
         if (ret) {
             break;
@@ -457,8 +457,8 @@
                     errmsg = strdup(range->emsg);
                 } else {
                     rc = asprintf(&errmsg, "%s \"%s\" does not satisfy the %s constraint.",
-                                    (basetype == LY_TYPE_BINARY || basetype == LY_TYPE_STRING) ? "Length" : "Value", strval,
-                                    (basetype == LY_TYPE_BINARY || basetype == LY_TYPE_STRING) ? "length" : "range");
+                            (basetype == LY_TYPE_BINARY || basetype == LY_TYPE_STRING) ? "Length" : "Value", strval,
+                            (basetype == LY_TYPE_BINARY || basetype == LY_TYPE_STRING) ? "length" : "range");
                 }
                 goto error;
             } else if ((uint64_t)value <= range->parts[u].max_u64) {
@@ -470,8 +470,8 @@
                     errmsg = strdup(range->emsg);
                 } else {
                     rc = asprintf(&errmsg, "%s \"%s\" does not satisfy the %s constraint.",
-                                    (basetype == LY_TYPE_BINARY || basetype == LY_TYPE_STRING) ? "Length" : "Value", strval,
-                                    (basetype == LY_TYPE_BINARY || basetype == LY_TYPE_STRING) ? "length" : "range");
+                            (basetype == LY_TYPE_BINARY || basetype == LY_TYPE_STRING) ? "Length" : "Value", strval,
+                            (basetype == LY_TYPE_BINARY || basetype == LY_TYPE_STRING) ? "length" : "range");
                 }
                 goto error;
             }
@@ -502,7 +502,7 @@
     return LY_SUCCESS;
 
 error:
-    if (rc == -1 || !errmsg) {
+    if ((rc == -1) || !errmsg) {
         *err = ly_err_new(LY_LLERR, LY_EMEM, 0, "Memory allocation failed.", NULL, NULL);
         return LY_EMEM;
     } else {
@@ -732,8 +732,8 @@
     /* prepare canonized value */
     if (d) {
         int count = sprintf(buf, "%" PRId64 " ", d);
-        if ((d > 0 && (count - 1) <= type_dec->fraction_digits)
-                || (count - 2) <= type_dec->fraction_digits) {
+        if (((d > 0) && ((count - 1) <= type_dec->fraction_digits)) ||
+                ((count - 2) <= type_dec->fraction_digits)) {
             /* we have 0. value, print the value with the leading zeros
              * (one for 0. and also keep the correct with of num according
              * to fraction-digits value)
@@ -741,7 +741,7 @@
             count = sprintf(buf, "%0*" PRId64 " ", (d > 0) ? (type_dec->fraction_digits + 1) : (type_dec->fraction_digits + 2), d);
         }
         for (uint8_t i = type_dec->fraction_digits, j = 1; i > 0; i--) {
-            if (j && i > 1 && buf[count - 2] == '0') {
+            if (j && (i > 1) && (buf[count - 2] == '0')) {
                 /* we have trailing zero to skip */
                 buf[count - 1] = '\0';
             } else {
@@ -811,13 +811,13 @@
             }
             count++;
 
-            if ((value[u] < '/' && value[u] != '+') ||
-                    (value[u] > '9' && value[u] < 'A') ||
-                    (value[u] > 'Z' && value[u] < 'a') || value[u] > 'z') {
+            if (((value[u] < '/') && (value[u] != '+')) ||
+                    ((value[u] > '9') && (value[u] < 'A')) ||
+                    ((value[u] > 'Z') && (value[u] < 'a')) || (value[u] > 'z')) {
                 /* non-encoding characters */
                 if (value[u] == '=') {
                     /* padding */
-                    if (u == stop - 1 && value[stop] == '=') {
+                    if ((u == stop - 1) && (value[stop] == '=')) {
                         termination = 2;
                         count++;
                         u++;
@@ -849,7 +849,7 @@
         LY_CHECK_RET(ly_type_validate_range(LY_TYPE_BINARY, type_bin->length, len, buf, err));
     }
 
-    if (start != 0 || (value_len && stop != value_len - 1)) {
+    if ((start != 0) || (value_len && (stop != value_len - 1))) {
         LY_CHECK_RET(lydict_insert(ctx, &value[start], stop + 1 - start, &storage->canonical));
     } else {
         LY_CHECK_RET(lydict_insert(ctx, value_len ? value : "", value_len, &storage->canonical));
@@ -864,7 +864,7 @@
 
 error:
     if (!*err) {
-        if (rc == -1 || !errmsg) {
+        if ((rc == -1) || !errmsg) {
             *err = ly_err_new(LY_LLERR, LY_EMEM, 0, "Memory allocation failed.", NULL, NULL);
         } else {
             *err = ly_err_new(LY_LLERR, LY_EVALID, LYVE_DATA, errmsg, NULL, NULL);
@@ -967,12 +967,12 @@
                 LY_ARRAY_FOR(type_bits->bits[u].iffeatures, v) {
                     if (lysc_iffeature_value(&type_bits->bits[u].iffeatures[v]) == LY_ENOT) {
                         rc = asprintf(&errmsg, "Bit \"%s\" is disabled by its %" LY_PRI_ARRAY_COUNT_TYPE ". if-feature condition.",
-                                       type_bits->bits[u].name, v + 1);
+                                type_bits->bits[u].name, v + 1);
                         goto cleanup;
                     }
                 }
 
-                if (iscanonical && items->count && type_bits->bits[u].position < ((struct lysc_type_bitenum_item *)items->objs[items->count - 1])->position) {
+                if (iscanonical && items->count && (type_bits->bits[u].position < ((struct lysc_type_bitenum_item *)items->objs[items->count - 1])->position)) {
                     iscanonical = 0;
                 }
                 ret = ly_set_add(items, &type_bits->bits[u], 0, &inserted);
@@ -1127,7 +1127,7 @@
             LY_ARRAY_FOR(type_enum->enums[u].iffeatures, v) {
                 if (lysc_iffeature_value(&type_enum->enums[u].iffeatures[v]) == LY_ENOT) {
                     rc = asprintf(&errmsg, "Enumeration \"%s\" is disabled by its %" LY_PRI_ARRAY_COUNT_TYPE ". if-feature condition.",
-                                   type_enum->enums[u].name, v + 1);
+                            type_enum->enums[u].name, v + 1);
                     goto error;
                 }
             }
@@ -1176,9 +1176,9 @@
     /* check hints */
     LY_CHECK_RET(type_check_hints(hints, value, value_len, type->basetype, NULL, err));
 
-    if (value_len == 4 && !strncmp(value, "true", 4)) {
+    if ((value_len == 4) && !strncmp(value, "true", 4)) {
         i = 1;
-    } else if (value_len == 5 && !strncmp(value, "false", 5)) {
+    } else if ((value_len == 5) && !strncmp(value, "false", 5)) {
         i = 0;
     } else {
         char *errmsg;
@@ -1324,7 +1324,7 @@
     } else if (!mod->compiled) {
         /* non-implemented module */
         rc = asprintf(&errmsg, "Invalid identityref \"%.*s\" value - identity found in non-implemented module \"%s\".",
-                        (int)value_len, value, mod->name);
+                (int)value_len, value, mod->name);
         goto error;
     }
 
@@ -1338,7 +1338,7 @@
     if (u == LY_ARRAY_COUNT(type_ident->bases)) {
         /* no match */
         rc = asprintf(&errmsg, "Invalid identityref \"%.*s\" value - identity not accepted by the type specification.",
-                        (int)value_len, value);
+                (int)value_len, value);
         goto error;
     }
 
@@ -1356,7 +1356,7 @@
     return LY_SUCCESS;
 
 error:
-    if (rc == -1 || !errmsg) {
+    if ((rc == -1) || !errmsg) {
         *err = ly_err_new(LY_LLERR, LY_EMEM, 0, "Memory allocation failed.", NULL, NULL);
         return LY_EMEM;
     } else {
@@ -1437,7 +1437,7 @@
 
     /* parse the value */
     ret = ly_path_parse(ctx, ctx_node, value, value_len, LY_PATH_BEGIN_ABSOLUTE, LY_PATH_LREF_FALSE,
-                        prefix_opt, LY_PATH_PRED_SIMPLE, &exp);
+            prefix_opt, LY_PATH_PRED_SIMPLE, &exp);
     if (ret) {
         rc = asprintf(&errmsg, "Invalid instance-identifier \"%.*s\" value - syntax error.", (int)value_len, value);
         goto error;
@@ -1536,7 +1536,7 @@
 
     if (val1 == val2) {
         return LY_SUCCESS;
-    } else if (!val1->target || !val2->target || LY_ARRAY_COUNT(val1->target) != LY_ARRAY_COUNT(val2->target)) {
+    } else if (!val1->target || !val2->target || (LY_ARRAY_COUNT(val1->target) != LY_ARRAY_COUNT(val2->target))) {
         return LY_ENOT;
     }
 
@@ -1544,8 +1544,8 @@
         struct ly_path *s1 = &val1->target[u];
         struct ly_path *s2 = &val2->target[u];
 
-        if (s1->node != s2->node || (s1->pred_type != s2->pred_type) ||
-                (s1->predicates && LY_ARRAY_COUNT(s1->predicates) != LY_ARRAY_COUNT(s2->predicates))) {
+        if ((s1->node != s2->node) || (s1->pred_type != s2->pred_type) ||
+                (s1->predicates && (LY_ARRAY_COUNT(s1->predicates) != LY_ARRAY_COUNT(s2->predicates)))) {
             return LY_ENOT;
         }
         if (s1->predicates) {
@@ -1564,7 +1564,7 @@
                     break;
                 case LY_PATH_PREDTYPE_LIST:
                     /* key-predicate */
-                    if (pred1->key != pred2->key || ((struct lysc_node_leaf *)pred1->key)->type->plugin->compare(&pred1->value, &pred2->value)) {
+                    if ((pred1->key != pred2->key) || ((struct lysc_node_leaf *)pred1->key)->type->plugin->compare(&pred1->value, &pred2->value)) {
                         return LY_ENOT;
                     }
                     break;
@@ -1601,9 +1601,10 @@
         /* everything is prefixed */
         LY_ARRAY_FOR(value->target, u) {
             ly_strcat(&result, "/%s:%s", ly_get_prefix(value->target[u].node->module, format, prefix_data),
-                      value->target[u].node->name);
+                    value->target[u].node->name);
             LY_ARRAY_FOR(value->target[u].predicates, v) {
                 struct ly_path_predicate *pred = &value->target[u].predicates[v];
+
                 switch (value->target[u].pred_type) {
                 case LY_PATH_PREDTYPE_NONE:
                     break;
@@ -1611,8 +1612,7 @@
                     /* position predicate */
                     ly_strcat(&result, "[%" PRIu64 "]", pred->position);
                     break;
-                case LY_PATH_PREDTYPE_LIST:
-                {
+                case LY_PATH_PREDTYPE_LIST: {
                     /* key-predicate */
                     ly_bool d = 0;
                     const char *value = pred->value.realtype->plugin->print(&pred->value, format, prefix_data, &d);
@@ -1621,14 +1621,13 @@
                         quot = '"';
                     }
                     ly_strcat(&result, "[%s:%s=%c%s%c]", ly_get_prefix(pred->key->module, format, prefix_data),
-                              pred->key->name, quot, value, quot);
+                            pred->key->name, quot, value, quot);
                     if (d) {
                         free((char *)value);
                     }
                     break;
                 }
-                case LY_PATH_PREDTYPE_LEAFLIST:
-                {
+                case LY_PATH_PREDTYPE_LEAFLIST: {
                     /* leaf-list-predicate */
                     ly_bool d = 0;
                     const char *value = pred->value.realtype->plugin->print(&pred->value, format, prefix_data, &d);
@@ -1657,6 +1656,7 @@
             }
             LY_ARRAY_FOR(value->target[u].predicates, v) {
                 struct ly_path_predicate *pred = &value->target[u].predicates[v];
+
                 switch (value->target[u].pred_type) {
                 case LY_PATH_PREDTYPE_NONE:
                     break;
@@ -1664,8 +1664,7 @@
                     /* position predicate */
                     ly_strcat(&result, "[%" PRIu64 "]", pred->position);
                     break;
-                case LY_PATH_PREDTYPE_LIST:
-                {
+                case LY_PATH_PREDTYPE_LIST: {
                     /* key-predicate */
                     ly_bool d = 0;
                     const char *value = pred->value.realtype->plugin->print(&pred->value, format, prefix_data, &d);
@@ -1679,8 +1678,7 @@
                     }
                     break;
                 }
-                case LY_PATH_PREDTYPE_LEAFLIST:
-                {
+                case LY_PATH_PREDTYPE_LEAFLIST: {
                     /* leaf-list-predicate */
                     ly_bool d = 0;
                     const char *value = pred->value.realtype->plugin->print(&pred->value, format, prefix_data, &d);
@@ -1772,7 +1770,7 @@
         ret = LY_ENOTFOUND;
         val_str = lref->plugin->print(value, LY_PREF_JSON, NULL, &dynamic);
         if (asprintf(errmsg, "Invalid leafref value \"%s\" - no target instance \"%s\" with the same value.", val_str,
-                     lref->path->expr) == -1) {
+                lref->path->expr) == -1) {
             *errmsg = NULL;
             ret = LY_EMEM;
         }
@@ -2090,8 +2088,8 @@
     /* use the first usable subtype to store the value */
     for (u = 0; u < LY_ARRAY_COUNT(types); ++u) {
         ret = types[u]->plugin->store(ctx, types[u], subvalue->original, strlen(subvalue->original),
-                                              0, subvalue->format, subvalue->prefix_data,
-                                              subvalue->hints, subvalue->ctx_node, &subvalue->value, err);
+                0, subvalue->format, subvalue->prefix_data,
+                subvalue->hints, subvalue->ctx_node, &subvalue->value, err);
         if ((ret == LY_SUCCESS) || (ret == LY_EINCOMPLETE)) {
             if (resolve && (ret == LY_EINCOMPLETE)) {
                 /* we need the value resolved */
@@ -2272,7 +2270,7 @@
             &dup->subvalue->original));
     dup->subvalue->format = original->subvalue->format;
     dup->subvalue->prefix_data = ly_type_union_dup_prefix_data(ctx, original->subvalue->format,
-                                                               original->subvalue->prefix_data);
+            original->subvalue->prefix_data);
 
     dup->realtype = original->realtype;
     return LY_SUCCESS;
diff --git a/src/printer.c b/src/printer.c
index dd48e51..174f48e 100644
--- a/src/printer.c
+++ b/src/printer.c
@@ -136,7 +136,8 @@
     return LY_SUCCESS;
 }
 
-API ly_write_clb ly_out_clb(struct ly_out *out, ly_write_clb writeclb)
+API ly_write_clb
+ly_out_clb(struct ly_out *out, ly_write_clb writeclb)
 {
     void *prev_clb;
 
@@ -308,11 +309,11 @@
         LOGINT(NULL);
         return LY_EINT;
     case LY_OUT_FD:
-        if ((lseek(out->method.fd, 0, SEEK_SET) == -1) && errno != ESPIPE) {
+        if ((lseek(out->method.fd, 0, SEEK_SET) == -1) && (errno != ESPIPE)) {
             LOGERR(NULL, LY_ESYS, "Seeking output file descriptor failed (%s).", strerror(errno));
             return LY_ESYS;
         }
-        if (errno != ESPIPE && ftruncate(out->method.fd, 0) == -1) {
+        if ((errno != ESPIPE) && (ftruncate(out->method.fd, 0) == -1)) {
             LOGERR(NULL, LY_ESYS, "Truncating output file failed (%s).", strerror(errno));
             return LY_ESYS;
         }
@@ -320,11 +321,11 @@
     case LY_OUT_FDSTREAM:
     case LY_OUT_FILE:
     case LY_OUT_FILEPATH:
-        if ((fseek(out->method.f, 0, SEEK_SET) == -1) && errno != ESPIPE) {
+        if ((fseek(out->method.f, 0, SEEK_SET) == -1) && (errno != ESPIPE)) {
             LOGERR(NULL, LY_ESYS, "Seeking output file stream failed (%s).", strerror(errno));
             return LY_ESYS;
         }
-        if (errno != ESPIPE && ftruncate(fileno(out->method.f), 0) == -1) {
+        if ((errno != ESPIPE) && (ftruncate(fileno(out->method.f), 0) == -1)) {
             LOGERR(NULL, LY_ESYS, "Truncating output file failed (%s).", strerror(errno));
             return LY_ESYS;
         }
@@ -381,7 +382,7 @@
     if (!out->method.fpath.f) {
         LOGERR(NULL, LY_ESYS, "Failed to open file \"%s\" (%s).", filepath, strerror(errno));
         out->method.fpath.f = f;
-        return ((void *)-1);
+        return (void *)-1;
     }
     fclose(f);
     free(out->method.fpath.filepath);
@@ -636,7 +637,7 @@
     }
 
     if (ret) {
-        if (errno == EAGAIN || errno == EWOULDBLOCK) {
+        if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) {
             ret = LY_SUCCESS;
             goto repeat;
         }
@@ -644,7 +645,7 @@
         written = 0;
     } else if ((size_t)written != len) {
         LOGERR(NULL, LY_ESYS, "%s: writing data failed (unable to write %u from %u data).", __func__,
-               len - (size_t)written, len);
+                len - (size_t)written, len);
         ret = LY_ESYS;
     } else {
         if (out->type == LY_OUT_FDSTREAM) {
diff --git a/src/printer_internal.h b/src/printer_internal.h
index ff02972..cdc9d07 100644
--- a/src/printer_internal.h
+++ b/src/printer_internal.h
@@ -16,8 +16,8 @@
 #define LY_PRINTER_INTERNAL_H_
 
 #include "printer.h"
-#include "printer_schema.h"
 #include "printer_data.h"
+#include "printer_schema.h"
 
 struct lysp_module;
 struct lysp_submodule;
diff --git a/src/printer_json.c b/src/printer_json.c
index 3e488de..b4f401a 100644
--- a/src/printer_json.c
+++ b/src/printer_json.c
@@ -77,7 +77,7 @@
         /* compare node names */
         struct lyd_node_opaq *onode1 = (struct lyd_node_opaq *)node1;
         struct lyd_node_opaq *onode2 = (struct lyd_node_opaq *)node2;
-        if (onode1->name != onode2->name || onode1->prefix.id != onode2->prefix.id) {
+        if ((onode1->name != onode2->name) || (onode1->prefix.id != onode2->prefix.id)) {
             return 0;
         }
     }
@@ -133,7 +133,7 @@
 
     LEVEL_DEC;
     ly_set_rm_index(&ctx->open, ctx->open.count - 1, NULL);
-    if (schema && schema->nodetype == LYS_LEAFLIST) {
+    if (schema && (schema->nodetype == LYS_LEAFLIST)) {
         /* leaf-list's content is always printed on a single line */
         ly_print_(ctx->out, "]");
     } else {
@@ -203,7 +203,7 @@
     } else {
         const char *pref1 = node_prefix(node1);
         const char *pref2 = node_prefix(node2);
-        if ((pref1 && pref2) && pref1 == pref2) {
+        if ((pref1 && pref2) && (pref1 == pref2)) {
             return 0;
         } else {
             return 1;
@@ -264,13 +264,13 @@
 json_print_member(struct jsonpr_ctx *ctx, const struct lyd_node *node, ly_bool is_attr)
 {
     PRINT_COMMA;
-    if (LEVEL == 1 || json_nscmp(node, (const struct lyd_node *)node->parent)) {
+    if ((LEVEL == 1) || json_nscmp(node, (const struct lyd_node *)node->parent)) {
         /* print "namespace" */
         ly_print_(ctx->out, "%*s\"%s%s:%s\":%s", INDENT, is_attr ? "@" : "",
-                 node_prefix(node), node->schema->name, DO_FORMAT ? " " : "");
+                node_prefix(node), node->schema->name, DO_FORMAT ? " " : "");
     } else {
         ly_print_(ctx->out, "%*s\"%s%s\":%s", INDENT, is_attr ? "@" : "",
-                 node->schema->name, DO_FORMAT ? " " : "");
+                node->schema->name, DO_FORMAT ? " " : "");
     }
 
     return LY_SUCCESS;
@@ -317,7 +317,7 @@
     }
 
     /* print the member */
-    if (module_name && (!parent || node_prefix(parent) != module_name)) {
+    if (module_name && (!parent || (node_prefix(parent) != module_name))) {
         ly_print_(ctx->out, "%*s\"%s%s:%s\":%s", INDENT, is_attr ? "@" : "", module_name, name, DO_FORMAT ? " " : "");
     } else {
         ly_print_(ctx->out, "%*s\"%s%s\":%s", INDENT, is_attr ? "@" : "", name, DO_FORMAT ? " " : "");
@@ -478,7 +478,7 @@
             LY_CHECK_RET(json_print_member2(ctx, NULL, LYD_JSON, NULL, "", 1));
         } else {
             LY_CHECK_RET(json_print_member2(ctx, node, ((struct lyd_node_opaq *)node)->format,
-                                            &((struct lyd_node_opaq *)node)->prefix, ((struct lyd_node_opaq *)node)->name, 1));
+                    &((struct lyd_node_opaq *)node)->prefix, ((struct lyd_node_opaq *)node)->name, 1));
         }
         ly_print_(ctx->out, "{%s", (DO_FORMAT ? "\n" : ""));
         LEVEL_INC;
@@ -600,12 +600,12 @@
         has_content = 1;
     }
 
-    if (!node->schema || node->schema->nodetype != LYS_LIST) {
+    if (!node->schema || (node->schema->nodetype != LYS_LIST)) {
         ly_print_(ctx->out, "%s{%s", (is_open_array(ctx, node) && ctx->level_printed >= ctx->level) ? "," : "",
                 (DO_FORMAT && has_content) ? "\n" : "");
     } else {
         ly_print_(ctx->out, "%s%*s{%s", (is_open_array(ctx, node) && ctx->level_printed >= ctx->level) ? "," : "",
-                 INDENT, (DO_FORMAT && has_content) ? "\n" : "");
+                INDENT, (DO_FORMAT && has_content) ? "\n" : "");
     }
     LEVEL_INC;
 
@@ -687,7 +687,7 @@
         }
     }
 
-    if (is_open_array(ctx, node) && (!node->next || node->next->schema != node->schema)) {
+    if (is_open_array(ctx, node) && (!node->next || (node->next->schema != node->schema))) {
         json_print_array_close(ctx);
     }
 
@@ -811,7 +811,7 @@
 json_print_node(struct jsonpr_ctx *ctx, const struct lyd_node *node)
 {
     if (!ly_should_print(node, ctx->options)) {
-        if (is_open_array(ctx, node) && (!node->next || node->next->schema != node->schema)) {
+        if (is_open_array(ctx, node) && (!node->next || (node->next->schema != node->schema))) {
             json_print_array_close(ctx);
         }
         return LY_SUCCESS;
diff --git a/src/printer_lyb.c b/src/printer_lyb.c
index d90fc9d..934156e 100644
--- a/src/printer_lyb.c
+++ b/src/printer_lyb.c
@@ -15,8 +15,8 @@
 #include "lyb.h"
 
 #include <assert.h>
-#include <stdio.h>
 #include <stdint.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
diff --git a/src/printer_schema.c b/src/printer_schema.c
index 99a947a..73c3745 100644
--- a/src/printer_schema.c
+++ b/src/printer_schema.c
@@ -17,8 +17,8 @@
 #include <stdio.h>
 #include <unistd.h>
 
-#include "compat.h"
 #include "common.h"
+#include "compat.h"
 #include "log.h"
 #include "printer.h"
 #include "printer_internal.h"
diff --git a/src/printer_schema.h b/src/printer_schema.h
index e566ef1..1f69ff0 100644
--- a/src/printer_schema.h
+++ b/src/printer_schema.h
@@ -58,7 +58,7 @@
     LYS_OUT_YANG_COMPILED = 2, /**< YANG schema output format of the compiled schema tree */
     LYS_OUT_YIN = 3,     /**< YIN schema output format */
 
-    LYS_OUT_TREE,        /**< Tree schema output format, for more information see the [printers](@ref howtoschemasprinters) page */
+    LYS_OUT_TREE         /**< Tree schema output format, for more information see the [printers](@ref howtoschemasprinters) page */
 } LYS_OUTFORMAT;
 
 /**
diff --git a/src/printer_xml.c b/src/printer_xml.c
index eea1e76..2e0aad5 100644
--- a/src/printer_xml.c
+++ b/src/printer_xml.c
@@ -135,6 +135,7 @@
     struct lyd_meta *meta;
     const struct lys_module *mod;
     struct ly_set ns_list = {0};
+
 #if 0
     const char **prefs, **nss;
     const char *xml_expr = NULL, *mod_name;
@@ -158,8 +159,8 @@
     }
 #if 0
     /* technically, check for the extension get-filter-element-attributes from ietf-netconf */
-    if (!strcmp(node->schema->name, "filter")
-            && (!strcmp(node->schema->module->name, "ietf-netconf") || !strcmp(node->schema->module->name, "notifications"))) {
+    if (!strcmp(node->schema->name, "filter") &&
+            (!strcmp(node->schema->module->name, "ietf-netconf") || !strcmp(node->schema->module->name, "notifications"))) {
         rpc_filter = 1;
     }
 #endif
@@ -537,7 +538,7 @@
     struct xmlpr_ctx ctx = {0};
 
     if (!root) {
-        if (out->type == LY_OUT_MEMORY || out->type == LY_OUT_CALLBACK) {
+        if ((out->type == LY_OUT_MEMORY) || (out->type == LY_OUT_CALLBACK)) {
             ly_print_(out, "");
         }
         goto finish;
diff --git a/src/printer_yang.c b/src/printer_yang.c
index 832ee10..586b65c 100644
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -235,7 +235,7 @@
         }
 
         count--;
-        if (ext->insubstmt != substmt || ext->insubstmt_index != substmt_index) {
+        if ((ext->insubstmt != substmt) || (ext->insubstmt_index != substmt_index)) {
             continue;
         }
 
@@ -326,7 +326,7 @@
 
     LEVEL++;
     LY_ARRAY_FOR(ext, u) {
-        if (((struct lysp_ext_instance *)ext)[u].insubstmt != substmt || ((struct lysp_ext_instance *)ext)[u].insubstmt_index != substmt_index) {
+        if ((((struct lysp_ext_instance *)ext)[u].insubstmt != substmt) || (((struct lysp_ext_instance *)ext)[u].insubstmt_index != substmt_index)) {
             continue;
         }
         if (ctx->schema == YPR_PARSED) {
@@ -485,7 +485,7 @@
     case LYS_IFF_AND:
         if (brackets_flag) {
             /* AND need brackets only if previous op was not */
-            if (*index_e < 2 || lysc_iff_getop(feat->expr, *index_e - 2) != LYS_IFF_NOT) {
+            if ((*index_e < 2) || (lysc_iff_getop(feat->expr, *index_e - 2) != LYS_IFF_NOT)) {
                 brackets_flag = 0;
             }
         }
@@ -522,7 +522,7 @@
         /* extensions */
         LEVEL++;
         LY_ARRAY_FOR(exts, v) {
-            if (exts[v].insubstmt != LYEXT_SUBSTMT_IFFEATURE || exts[v].insubstmt_index != u) {
+            if ((exts[v].insubstmt != LYEXT_SUBSTMT_IFFEATURE) || (exts[v].insubstmt_index != u)) {
                 continue;
             }
             yprc_extension_instances(ctx, LYEXT_SUBSTMT_IFFEATURE, u, &exts[v], &extflag, 1);
@@ -556,7 +556,7 @@
             }
         }
         if ((ext->flags & LYS_YINELEM_MASK) ||
-                (ext->exts && lysp_ext_instance_iter(ext->exts, 0, LYEXT_SUBSTMT_YINELEM) != LY_ARRAY_COUNT(ext->exts))) {
+                (ext->exts && (lysp_ext_instance_iter(ext->exts, 0, LYEXT_SUBSTMT_YINELEM) != LY_ARRAY_COUNT(ext->exts)))) {
             ypr_open(ctx->out, &flag2);
             ypr_substmt(ctx, LYEXT_SUBSTMT_YINELEM, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts);
         }
diff --git a/src/printer_yin.c b/src/printer_yin.c
index 52a2f7e..da195d1 100644
--- a/src/printer_yin.c
+++ b/src/printer_yin.c
@@ -108,7 +108,7 @@
 
     LEVEL++;
     LY_ARRAY_FOR(ext, u) {
-        if (((struct lysp_ext_instance *)ext)[u].insubstmt != substmt || ((struct lysp_ext_instance *)ext)[u].insubstmt_index != substmt_index) {
+        if ((((struct lysp_ext_instance *)ext)[u].insubstmt != substmt) || (((struct lysp_ext_instance *)ext)[u].insubstmt_index != substmt_index)) {
             continue;
         }
         yprp_extension_instances(ctx, substmt, substmt_index, &((struct lysp_ext_instance *)ext)[u], &extflag, 1);
@@ -127,6 +127,7 @@
 ypr_unsigned(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, void *exts, unsigned long int attr_value)
 {
     char *str;
+
     if (asprintf(&str, "%lu", attr_value) == -1) {
         LOGMEM(ctx->module->ctx);
         return;
@@ -268,7 +269,7 @@
             }
         }
         if ((ext->flags & LYS_YINELEM_MASK) ||
-                (ext->exts && lysp_ext_instance_iter(ext->exts, 0, LYEXT_SUBSTMT_YINELEM) != LY_ARRAY_COUNT(ext->exts))) {
+                (ext->exts && (lysp_ext_instance_iter(ext->exts, 0, LYEXT_SUBSTMT_YINELEM) != LY_ARRAY_COUNT(ext->exts)))) {
             ypr_close_parent(ctx, &flag2);
             ypr_substmt(ctx, LYEXT_SUBSTMT_YINELEM, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts);
         }
@@ -365,6 +366,7 @@
 yprp_when(struct ypr_ctx *ctx, struct lysp_when *when, int8_t *flag)
 {
     int8_t inner_flag = 0;
+
     (void)flag;
 
     if (!when) {
@@ -388,6 +390,7 @@
 {
     LY_ARRAY_COUNT_TYPE u;
     int8_t inner_flag;
+
     (void)flag;
 
     LY_ARRAY_FOR(items, u) {
@@ -769,6 +772,7 @@
     struct lysp_node_leaf *leaf = (struct lysp_node_leaf *)node;
 
     int8_t flag = 1;
+
     yprp_node_common1(ctx, node, &flag);
 
     yprp_type(ctx, &leaf->type);
@@ -1313,7 +1317,7 @@
         }
 
         count--;
-        if (ext->insubstmt != substmt || ext->insubstmt_index != substmt_index) {
+        if ((ext->insubstmt != substmt) || (ext->insubstmt_index != substmt_index)) {
             continue;
         }
 
diff --git a/src/set.c b/src/set.c
index 2249494..f4c718a 100644
--- a/src/set.c
+++ b/src/set.c
@@ -14,9 +14,9 @@
 
 #include "common.h"
 
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdint.h>
 
 #include "log.h"
 #include "set.h"
diff --git a/src/tree.h b/src/tree.h
index 4b00073..75dd761 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -182,7 +182,7 @@
     LY_TYPE_INT8, /**< 8-bit signed integer ([RFC 6020 sec 9.2](http://tools.ietf.org/html/rfc6020#section-9.2)) */
     LY_TYPE_INT16, /**< 16-bit signed integer ([RFC 6020 sec 9.2](http://tools.ietf.org/html/rfc6020#section-9.2)) */
     LY_TYPE_INT32, /**< 32-bit signed integer ([RFC 6020 sec 9.2](http://tools.ietf.org/html/rfc6020#section-9.2)) */
-    LY_TYPE_INT64, /**< 64-bit signed integer ([RFC 6020 sec 9.2](http://tools.ietf.org/html/rfc6020#section-9.2)) */
+    LY_TYPE_INT64  /**< 64-bit signed integer ([RFC 6020 sec 9.2](http://tools.ietf.org/html/rfc6020#section-9.2)) */
 } LY_DATA_TYPE;
 #define LY_DATA_TYPE_COUNT 20 /**< Number of different types */
 
diff --git a/src/tree_data.c b/src/tree_data.c
index a7db1bf..1423421 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -38,8 +38,8 @@
 #include "parser_internal.h"
 #include "path.h"
 #include "plugins_exts.h"
-#include "plugins_exts_metadata.h"
 #include "plugins_exts_internal.h"
+#include "plugins_exts_metadata.h"
 #include "plugins_types.h"
 #include "set.h"
 #include "tree.h"
@@ -265,7 +265,7 @@
 lyd_parse_get_format(const struct ly_in *in, LYD_FORMAT format)
 {
 
-    if (!format && in->type == LY_IN_FILEPATH) {
+    if (!format && (in->type == LY_IN_FILEPATH)) {
         /* unknown format - try to detect it from filename's suffix */
         const char *path = in->method.fpath.filepath;
         size_t len = strlen(path);
@@ -273,11 +273,11 @@
         /* ignore trailing whitespaces */
         for ( ; len > 0 && isspace(path[len - 1]); len--) {}
 
-        if (len >= 5 && !strncmp(&path[len - 4], ".xml", 4)) {
+        if ((len >= 5) && !strncmp(&path[len - 4], ".xml", 4)) {
             format = LYD_XML;
-        } else if (len >= 6 && !strncmp(&path[len - 5], ".json", 5)) {
+        } else if ((len >= 6) && !strncmp(&path[len - 5], ".json", 5)) {
             format = LYD_JSON;
-        } else if (len >= 5 && !strncmp(&path[len - 4], ".lyb", 4)) {
+        } else if ((len >= 5) && !strncmp(&path[len - 4], ".lyb", 4)) {
             format = LYD_LYB;
         } /* else still unknown */
     }
@@ -346,7 +346,7 @@
 
             /* add all top-level defaults for this module */
             ret = lyd_new_implicit_r(NULL, first2, NULL, mod, &lydctx->unres_node_type, &lydctx->when_check,
-                            (validate_options & LYD_VALIDATE_NO_STATE) ? LYD_IMPLICIT_NO_STATE : 0, NULL);
+                    (validate_options & LYD_VALIDATE_NO_STATE) ? LYD_IMPLICIT_NO_STATE : 0, NULL);
             LY_CHECK_GOTO(ret, cleanup);
 
             /* finish incompletely validated terminal values/attributes and when conditions */
@@ -627,11 +627,11 @@
 
     /* parse keys */
     LY_CHECK_GOTO(ret = ly_path_parse_predicate(schema->module->ctx, NULL, keys, keys_len, LY_PATH_PREFIX_OPTIONAL,
-                                                LY_PATH_PRED_KEYS, &expr), cleanup);
+            LY_PATH_PRED_KEYS, &expr), cleanup);
 
     /* compile them */
     LY_CHECK_GOTO(ret = ly_path_compile_predicate(schema->module->ctx, NULL, NULL, schema, expr, &exp_idx,
-                                                  LY_PREF_JSON, NULL, &predicates, &pred_type), cleanup);
+            LY_PREF_JSON, NULL, &predicates, &pred_type), cleanup);
 
     /* create the list node */
     LY_CHECK_GOTO(ret = lyd_create_list(schema, predicates, node), cleanup);
@@ -726,7 +726,7 @@
     }
 
     schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0,
-                            LYS_CONTAINER | LYS_NOTIF | LYS_RPC | LYS_ACTION, 0);
+            LYS_CONTAINER | LYS_NOTIF | LYS_RPC | LYS_ACTION, 0);
     LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Inner node (and not a list) \"%s\" not found.", name), LY_ENOTFOUND);
 
     LY_CHECK_RET(lyd_create_inner(schema, &ret));
@@ -1052,7 +1052,7 @@
     }
 
     LY_CHECK_RET(lyd_create_attr(parent, &ret, ctx, name, name_len, val_str, strlen(val_str), NULL, LYD_JSON, 0, NULL,
-                                 prefix, pref_len, module_name, module_name ? strlen(module_name) : 0));
+            prefix, pref_len, module_name, module_name ? strlen(module_name) : 0));
 
     if (attr) {
         *attr = ret;
@@ -1206,18 +1206,18 @@
 
     /* parse path */
     LY_CHECK_GOTO(ret = ly_path_parse(ctx, NULL, path, strlen(path), LY_PATH_BEGIN_EITHER, LY_PATH_LREF_FALSE,
-                                      LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_SIMPLE, &exp), cleanup);
+            LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_SIMPLE, &exp), cleanup);
 
     /* compile path */
     LY_CHECK_GOTO(ret = ly_path_compile(ctx, NULL, parent ? parent->schema : NULL, exp, LY_PATH_LREF_FALSE,
-                                        options & LYD_NEWOPT_OUTPUT ? LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT,
-                                        LY_PATH_TARGET_MANY, LY_PREF_JSON, NULL, &p), cleanup);
+            options & LYD_NEWOPT_OUTPUT ? LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT,
+            LY_PATH_TARGET_MANY, LY_PREF_JSON, NULL, &p), cleanup);
 
     schema = p[LY_ARRAY_COUNT(p) - 1].node;
-    if ((schema->nodetype == LYS_LIST) && (p[LY_ARRAY_COUNT(p) - 1].pred_type == LY_PATH_PREDTYPE_NONE)
-            && !(options & LYD_NEWOPT_OPAQ)) {
+    if ((schema->nodetype == LYS_LIST) && (p[LY_ARRAY_COUNT(p) - 1].pred_type == LY_PATH_PREDTYPE_NONE) &&
+            !(options & LYD_NEWOPT_OPAQ)) {
         LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Predicate missing for %s \"%s\" in path.",
-               lys_nodetype2str(schema->nodetype), schema->name);
+                lys_nodetype2str(schema->nodetype), schema->name);
         ret = LY_EINVAL;
         goto cleanup;
     } else if ((schema->nodetype == LYS_LEAFLIST) && (p[LY_ARRAY_COUNT(p) - 1].pred_type == LY_PATH_PREDTYPE_NONE)) {
@@ -1280,7 +1280,7 @@
                     /* creating opaque list without keys */
                     LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0, NULL, LYD_JSON,
                             LYD_NODEHINT_LIST, NULL, NULL, 0, schema->module->name, strlen(schema->module->name), &node),
-                                  cleanup);
+                            cleanup);
                 } else {
                     assert(p[path_idx].pred_type == LY_PATH_PREDTYPE_LIST);
                     LY_CHECK_GOTO(ret = lyd_create_list(schema, p[path_idx].predicates, &node), cleanup);
@@ -1321,8 +1321,8 @@
             } else {
                 /* creating opaque leaf without value */
                 LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0, NULL, LYD_JSON,
-                                                    0, NULL, NULL, 0, schema->module->name,
-                                                    strlen(schema->module->name), &node), cleanup);
+                        0, NULL, NULL, 0, schema->module->name,
+                        strlen(schema->module->name), &node), cleanup);
             }
             break;
         case LYS_ANYDATA:
@@ -1394,7 +1394,7 @@
             if (((struct lysc_node_choice *)iter)->dflt && !lys_getnext_data(NULL, *first, NULL, iter, NULL)) {
                 /* create default case data */
                 LY_CHECK_RET(lyd_new_implicit_r(parent, first, (struct lysc_node *)((struct lysc_node_choice *)iter)->dflt,
-                                                NULL, node_types, node_when, impl_opts, diff));
+                        NULL, node_types, node_when, impl_opts, diff));
             }
             break;
         case LYS_CONTAINER:
@@ -1409,12 +1409,12 @@
 
                 /* create any default children */
                 LY_CHECK_RET(lyd_new_implicit_r(node, lyd_node_children_p(node), NULL, NULL, node_types, node_when,
-                                                impl_opts, diff));
+                        impl_opts, diff));
             }
             break;
         case LYS_LEAF:
-            if (!(impl_opts & LYD_IMPLICIT_NO_DEFAULTS) && ((struct lysc_node_leaf *)iter)->dflt
-                    && lyd_find_sibling_val(*first, iter, NULL, 0, NULL)) {
+            if (!(impl_opts & LYD_IMPLICIT_NO_DEFAULTS) && ((struct lysc_node_leaf *)iter)->dflt &&
+                    lyd_find_sibling_val(*first, iter, NULL, 0, NULL)) {
                 /* create default leaf */
                 ret = lyd_create_term2(iter, ((struct lysc_node_leaf *)iter)->dflt, &node);
                 if (ret == LY_EINCOMPLETE) {
@@ -1439,8 +1439,8 @@
             }
             break;
         case LYS_LEAFLIST:
-            if (!(impl_opts & LYD_IMPLICIT_NO_DEFAULTS) && ((struct lysc_node_leaflist *)iter)->dflts
-                    && lyd_find_sibling_val(*first, iter, NULL, 0, NULL)) {
+            if (!(impl_opts & LYD_IMPLICIT_NO_DEFAULTS) && ((struct lysc_node_leaflist *)iter)->dflts &&
+                    lyd_find_sibling_val(*first, iter, NULL, 0, NULL)) {
                 /* create all default leaf-lists */
                 dflts = ((struct lysc_node_leaflist *)iter)->dflts;
                 LY_ARRAY_FOR(dflts, u) {
@@ -1489,10 +1489,10 @@
 
     LYD_TREE_DFS_BEGIN(tree, node) {
         /* skip added default nodes */
-        if (((node->flags & (LYD_DEFAULT | LYD_NEW)) != (LYD_DEFAULT | LYD_NEW))
-                && (node->schema->nodetype & LYD_NODE_INNER)) {
+        if (((node->flags & (LYD_DEFAULT | LYD_NEW)) != (LYD_DEFAULT | LYD_NEW)) &&
+                (node->schema->nodetype & LYD_NODE_INNER)) {
             LY_CHECK_GOTO(ret = lyd_new_implicit_r(node, lyd_node_children_p((struct lyd_node *)node), NULL, NULL, NULL,
-                                                   NULL, implicit_options, diff), cleanup);
+                    NULL, implicit_options, diff), cleanup);
         }
 
         LYD_TREE_DFS_END(tree, node);
@@ -1859,7 +1859,7 @@
         /* inner node */
         if (par2 != parent) {
             LOGERR(schema->module->ctx, LY_EINVAL, "Cannot insert, parent of \"%s\" is not \"%s\".", schema->name,
-                   parent->name);
+                    parent->name);
             return LY_EINVAL;
         }
     } else {
@@ -2046,8 +2046,8 @@
         }
 
         /* check for NP container whether its last non-default node is not being unlinked */
-        if (node->parent->schema && (node->parent->schema->nodetype == LYS_CONTAINER)
-                && !(node->parent->flags & LYD_DEFAULT) && !(node->parent->schema->flags & LYS_PRESENCE)) {
+        if (node->parent->schema && (node->parent->schema->nodetype == LYS_CONTAINER) &&
+                !(node->parent->flags & LYD_DEFAULT) && !(node->parent->schema->flags & LYS_PRESENCE)) {
             LY_LIST_FOR(node->parent->child, iter) {
                 if ((iter != node) && !(iter->flags & LYD_DEFAULT)) {
                     break;
@@ -2115,7 +2115,7 @@
     assert((parent || meta) && mod);
 
     LY_ARRAY_FOR(mod->compiled->exts, u) {
-        if (mod->compiled->exts[u].def->plugin == lyext_plugins_internal[LYEXT_PLUGIN_INTERNAL_ANNOTATION].plugin &&
+        if ((mod->compiled->exts[u].def->plugin == lyext_plugins_internal[LYEXT_PLUGIN_INTERNAL_ANNOTATION].plugin) &&
                 !ly_strncmp(mod->compiled->exts[u].argument, name, name_len)) {
             /* we have the annotation definition */
             ant = &mod->compiled->exts[u];
@@ -2397,14 +2397,14 @@
             case LYD_ANYDATA_JSON:
                 len1 = strlen(any1->value.str);
                 len2 = strlen(any2->value.str);
-                if (len1 != len2 || strcmp(any1->value.str, any2->value.str)) {
+                if ((len1 != len2) || strcmp(any1->value.str, any2->value.str)) {
                     return LY_ENOT;
                 }
                 return LY_SUCCESS;
             case LYD_ANYDATA_LYB:
                 len1 = lyd_lyb_data_length(any1->value.mem);
                 len2 = lyd_lyb_data_length(any2->value.mem);
-                if (len1 != len2 || memcmp(any1->value.mem, any2->value.mem, len1)) {
+                if ((len1 != len2) || memcmp(any1->value.mem, any2->value.mem, len1)) {
                     return LY_ENOT;
                 }
                 return LY_SUCCESS;
@@ -2551,7 +2551,7 @@
 
         term->hash = orig->hash;
         LY_CHECK_ERR_GOTO(orig->value.realtype->plugin->duplicate(LYD_CTX(node), &orig->value, &term->value),
-                          LOGERR(LYD_CTX(node), LY_EINT, "Value duplication failed."); ret = LY_EINT, error);
+                LOGERR(LYD_CTX(node), LY_EINT, "Value duplication failed."); ret = LY_EINT, error);
     } else if (dup->schema->nodetype & LYD_NODE_INNER) {
         struct lyd_node_inner *orig = (struct lyd_node_inner *)node;
         struct lyd_node *child;
@@ -2561,7 +2561,7 @@
             LY_LIST_FOR(orig->child, child) {
                 LY_CHECK_GOTO(ret = lyd_dup_r(child, dup, NULL, options, NULL), error);
             }
-        } else if (dup->schema->nodetype == LYS_LIST && !(dup->schema->flags & LYS_KEYLESS)) {
+        } else if ((dup->schema->nodetype == LYS_LIST) && !(dup->schema->flags & LYS_KEYLESS)) {
             /* always duplicate keys of a list */
             child = orig->child;
             for (struct lysc_node *key = ((struct lysc_node_list *)dup->schema)->child;
@@ -2642,7 +2642,7 @@
     if (repeat && parent) {
         /* given parent and created parents chain actually do not interconnect */
         LOGERR(LYD_CTX(node), LY_EINVAL,
-               "Invalid argument parent (%s()) - does not interconnect with the created node's parents chain.", __func__);
+                "Invalid argument parent (%s()) - does not interconnect with the created node's parents chain.", __func__);
         return LY_EINVAL;
     }
 
@@ -2676,7 +2676,7 @@
 
     /* rehash if needed */
     for ( ; local_parent; local_parent = local_parent->parent) {
-        if (local_parent->schema->nodetype == LYS_LIST && (local_parent->schema->flags & LYS_KEYLESS)) {
+        if ((local_parent->schema->nodetype == LYS_LIST) && (local_parent->schema->flags & LYS_KEYLESS)) {
             lyd_hash((struct lyd_node *)local_parent);
         }
     }
@@ -2779,7 +2779,7 @@
                 type = ((struct lysc_node_leaf *)match_trg->schema)->type;
                 type->plugin->free(LYD_CTX(match_trg), &((struct lyd_node_term *)match_trg)->value);
                 LY_CHECK_RET(type->plugin->duplicate(LYD_CTX(match_trg), &((struct lyd_node_term *)sibling_src)->value,
-                                                     &((struct lyd_node_term *)match_trg)->value));
+                        &((struct lyd_node_term *)match_trg)->value));
 
                 /* copy flags and add LYD_NEW */
                 match_trg->flags = sibling_src->flags | LYD_NEW;
@@ -3026,7 +3026,7 @@
 iter_print:
             /* print prefix and name */
             mod = NULL;
-            if (iter->schema && (!iter->parent || iter->schema->module != iter->parent->schema->module)) {
+            if (iter->schema && (!iter->parent || (iter->schema->module != iter->parent->schema->module))) {
                 mod = iter->schema->module;
             }
 
@@ -3039,7 +3039,7 @@
 
             /* print next node */
             bufused += sprintf(buffer + bufused, "/%s%s%s", mod ? mod->name : "", mod ? ":" : "",
-                               iter->schema ? iter->schema->name : ((struct lyd_node_opaq *)iter)->name);
+                    iter->schema ? iter->schema->name : ((struct lyd_node_opaq *)iter)->name);
 
             /* do not always print the last (first) predicate */
             if (iter->schema && (bufused || (pathtype == LYD_PATH_LOG))) {
diff --git a/src/tree_data.h b/src/tree_data.h
index 6817d64..1380bf0 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -129,7 +129,7 @@
     LYD_UNKNOWN = 0,     /**< unknown data format, invalid value */
     LYD_XML,             /**< XML instance data format */
     LYD_JSON,            /**< JSON instance data format */
-    LYD_LYB,             /**< LYB instance data format */
+    LYD_LYB              /**< LYB instance data format */
 } LYD_FORMAT;
 
 /**
@@ -138,7 +138,7 @@
 typedef enum {
     LY_PREF_SCHEMA,          /**< value prefixes map to YANG import prefixes */
     LY_PREF_XML,             /**< value prefixes map to XML namespace prefixes */
-    LY_PREF_JSON,            /**< value prefixes map to module names */
+    LY_PREF_JSON             /**< value prefixes map to module names */
 } LY_PREFIX_FORMAT;
 
 /**
@@ -153,7 +153,7 @@
                                           is printed in XML format. */
     LYD_ANYDATA_XML,                 /**< Value is a string containing the serialized XML data. */
     LYD_ANYDATA_JSON,                /**< Value is a string containing the data modeled by YANG and encoded as I-JSON. */
-    LYD_ANYDATA_LYB,                 /**< Value is a memory chunk with the serialized data tree in LYB format. */
+    LYD_ANYDATA_LYB                  /**< Value is a memory chunk with the serialized data tree in LYB format. */
 } LYD_ANYDATA_VALUETYPE;
 
 /** @} */
@@ -1288,7 +1288,7 @@
  */
 typedef enum {
     LYD_PATH_LOG, /**< Descriptive path format used in log messages */
-    LYD_PATH_LOG_NO_LAST_PRED, /**< Similar to ::LYD_PATH_LOG except there is never a predicate on the last node */
+    LYD_PATH_LOG_NO_LAST_PRED  /**< Similar to ::LYD_PATH_LOG except there is never a predicate on the last node */
 } LYD_PATH_TYPE;
 
 /**
diff --git a/src/tree_data_free.c b/src/tree_data_free.c
index dc888cd..53d80ca 100644
--- a/src/tree_data_free.c
+++ b/src/tree_data_free.c
@@ -17,10 +17,10 @@
 
 #include "common.h"
 #include "hash_table.h"
-#include "tree.h"
-#include "tree_schema.h"
-#include "tree_data_internal.h"
 #include "plugins_types.h"
+#include "tree.h"
+#include "tree_data_internal.h"
+#include "tree_schema.h"
 
 void
 ly_free_val_prefs(const struct ly_ctx *ctx, struct ly_prefix *val_prefs)
diff --git a/src/tree_data_hash.c b/src/tree_data_hash.c
index 482ce15..f69a552 100644
--- a/src/tree_data_hash.c
+++ b/src/tree_data_hash.c
@@ -17,8 +17,8 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "compat.h"
 #include "common.h"
+#include "compat.h"
 #include "hash_table.h"
 #include "log.h"
 #include "plugins_types.h"
@@ -138,8 +138,8 @@
     }
 
     /* add first instance of a (leaf-)list */
-    if ((node->schema->nodetype & (LYS_LIST | LYS_LEAFLIST))
-            && (!node->prev->next || (node->prev->schema != node->schema))) {
+    if ((node->schema->nodetype & (LYS_LIST | LYS_LEAFLIST)) &&
+            (!node->prev->next || (node->prev->schema != node->schema))) {
         /* get the simple hash */
         hash = dict_hash_multi(0, node->schema->module->name, strlen(node->schema->module->name));
         hash = dict_hash_multi(hash, node->schema->name, strlen(node->schema->name));
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index 712f300..8c4b310 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -254,8 +254,8 @@
     }
 
     LY_LIST_FOR(*meta, meta2) {
-        if (!strcmp(meta2->name, "default") && !strcmp(meta2->annotation->module->name, "ietf-netconf-with-defaults")
-                && meta2->value.boolean) {
+        if (!strcmp(meta2->name, "default") && !strcmp(meta2->annotation->module->name, "ietf-netconf-with-defaults") &&
+                meta2->value.boolean) {
             /* node is default according to the metadata */
             node->flags |= LYD_DEFAULT;
 
diff --git a/src/tree_schema.c b/src/tree_schema.c
index d5d672c..1b9433c 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -58,7 +58,7 @@
         /* get know where to start */
         if (parent) {
             /* schema subtree */
-            if (parent->nodetype == LYS_CHOICE && (options & LYS_GETNEXT_WITHCASE)) {
+            if ((parent->nodetype == LYS_CHOICE) && (options & LYS_GETNEXT_WITHCASE)) {
                 if (((struct lysc_node_choice *)parent)->cases) {
                     next = last = (const struct lysc_node *)&((struct lysc_node_choice *)parent)->cases[0];
                 }
@@ -119,7 +119,7 @@
 repeat:
     if (!next) {
         /* possibly go back to parent */
-        if (last && last->parent != parent) {
+        if (last && (last->parent != parent)) {
             last = last->parent;
             goto next;
         } else if (!action_flag) {
@@ -245,7 +245,7 @@
         }
         if (!mod) {
             LOGERR(ctx, LY_EINVAL, "Invalid qpath - unable to find module connected with the prefix of the node \"%.*s\".",
-                   id - qpath, qpath);
+                    id - qpath, qpath);
             return NULL;
         }
 
@@ -413,7 +413,7 @@
             } else {
                 slash = "/";
             }
-            if (!iter->parent || iter->parent->module != iter->module) {
+            if (!iter->parent || (iter->parent->module != iter->module)) {
                 /* print prefix */
                 if (buffer) {
                     len = snprintf(buffer, buflen, "%s%s:%s%s", slash, iter->module->name, id, s ? s : "");
@@ -431,7 +431,7 @@
             free(s);
             free(id);
 
-            if (buffer && buflen <= (size_t)len) {
+            if (buffer && (buflen <= (size_t)len)) {
                 /* not enough space in buffer */
                 break;
             }
@@ -566,7 +566,7 @@
 
     if (!mod->compiled) {
         LOGERR(ctx, LY_EINVAL, "Module \"%s\" is not implemented so all its features are permanently disabled without a chance to change it.",
-               mod->name);
+                mod->name);
         return LY_EINVAL;
     }
     if (!mod->features) {
@@ -605,8 +605,8 @@
                                 goto next;
                             } else {
                                 LOGERR(ctx, LY_EDENIED,
-                                    "Feature \"%s\" cannot be enabled since it is disabled by its if-feature condition(s).",
-                                    f->name);
+                                        "Feature \"%s\" cannot be enabled since it is disabled by its if-feature condition(s).",
+                                        f->name);
                                 ret = LY_EDENIED;
                                 goto cleanup;
                             }
@@ -646,8 +646,8 @@
             for (u = 0; disabled_count && u < LY_ARRAY_COUNT(mod->features); ++u) {
                 if (!(mod->features[u].flags & LYS_FENABLED)) {
                     LOGERR(ctx, LY_EDENIED,
-                           "Feature \"%s\" cannot be enabled since it is disabled by its if-feature condition(s).",
-                           mod->features[u].name);
+                            "Feature \"%s\" cannot be enabled since it is disabled by its if-feature condition(s).",
+                            mod->features[u].name);
                     --disabled_count;
                 }
             }
@@ -1119,10 +1119,10 @@
             /* error */
             if (mod->parsed->revs) {
                 LOGERR(ctx, LY_EEXIST, "Module \"%s\" of revision \"%s\" is already present in the context.",
-                       mod->name, mod->parsed->revs[0].date);
+                        mod->name, mod->parsed->revs[0].date);
             } else {
                 LOGERR(ctx, LY_EEXIST, "Module \"%s\" with no revision is already present in the context.",
-                       mod->name);
+                        mod->name);
             }
             ret = LY_EEXIST;
             goto error;
@@ -1152,14 +1152,14 @@
         /* name */
         len = strlen(mod->name);
         if (strncmp(filename, mod->name, len) ||
-                ((rev && rev != &filename[len]) || (!rev && dot != &filename[len]))) {
+                ((rev && (rev != &filename[len])) || (!rev && (dot != &filename[len])))) {
             LOGWRN(ctx, "File name \"%s\" does not match module name \"%s\".", filename, mod->name);
         }
         if (rev) {
             len = dot - ++rev;
-            if (!mod->parsed->revs || len != 10 || strncmp(mod->parsed->revs[0].date, rev, len)) {
+            if (!mod->parsed->revs || (len != 10) || strncmp(mod->parsed->revs[0].date, rev, len)) {
                 LOGWRN(ctx, "File name \"%s\" does not match module revision \"%s\".", filename,
-                       mod->parsed->revs ? mod->parsed->revs[0].date : "none");
+                        mod->parsed->revs ? mod->parsed->revs[0].date : "none");
             }
         }
 
@@ -1200,9 +1200,9 @@
         /* pre-compile features and identities of any submodules */
         LY_ARRAY_FOR(mod->parsed->includes, u) {
             LY_CHECK_GOTO(ret = lys_feature_precompile(NULL, ctx, mod, mod->parsed->includes[u].submodule->features,
-                                                       &mod->features), error);
+                    &mod->features), error);
             LY_CHECK_GOTO(ret = lys_identity_precompile(NULL, ctx, mod, mod->parsed->includes[u].submodule->identities,
-                                                        &mod->identities), error);
+                    &mod->identities), error);
         }
     }
 
@@ -1295,7 +1295,7 @@
     LY_CHECK_ARG_RET(ctx, path, format != LYS_IN_UNKNOWN, LY_EINVAL);
 
     LY_CHECK_ERR_RET(ret = ly_in_new_filepath(path, 0, &in),
-                     LOGERR(ctx, ret, "Unable to create input handler for filepath %s.", path), ret);
+            LOGERR(ctx, ret, "Unable to create input handler for filepath %s.", path), ret);
 
     ret = lys_parse(ctx, in, format, module);
     ly_in_free(in, 0);
@@ -1387,7 +1387,7 @@
                 }
                 if (stat(wn, &st) == -1) {
                     LOGWRN(NULL, "Unable to get information about \"%s\" file in \"%s\" when searching for (sub)modules (%s)",
-                           file->d_name, wd, strerror(errno));
+                            file->d_name, wd, strerror(errno));
                     continue;
                 }
                 if (S_ISDIR(st.st_mode) && (dirs->count || !implicit_cwd)) {
@@ -1406,7 +1406,7 @@
 
                 /* here we know that the item is a file which can contain a module */
                 if (strncmp(name, file->d_name, len) ||
-                        (file->d_name[len] != '.' && file->d_name[len] != '@')) {
+                        ((file->d_name[len] != '.') && (file->d_name[len] != '@'))) {
                     /* different filename than the module we search for */
                     continue;
                 }
@@ -1452,10 +1452,10 @@
                 } else {
                     /* remember the revision and try to find the newest one */
                     if (match_name) {
-                        if (file->d_name[len] != '@' ||
-                                lysp_check_date(NULL, &file->d_name[len + 1], flen - (format_aux == LYS_IN_YANG ? 5 : 4) - len - 1, NULL)) {
+                        if ((file->d_name[len] != '@') ||
+                                lysp_check_date(NULL, &file->d_name[len + 1], flen - ((format_aux == LYS_IN_YANG) ? 5 : 4) - len - 1, NULL)) {
                             continue;
-                        } else if (match_name[match_len] == '@' &&
+                        } else if ((match_name[match_len] == '@') &&
                                 (strncmp(&match_name[match_len + 1], &file->d_name[len + 1], LY_REV_SIZE - 1) >= 0)) {
                             continue;
                         }
diff --git a/src/tree_schema.h b/src/tree_schema.h
index 8f16508..26df0bb 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -257,7 +257,7 @@
     LYEXT_PAR_WHEN,      /**< ::lysc_when */
     LYEXT_PAR_IDENT,     /**< ::lysc_ident */
     LYEXT_PAR_EXT,       /**< ::lysc_ext */
-    LYEXT_PAR_IMPORT,    /**< ::lysp_import */
+    LYEXT_PAR_IMPORT     /**< ::lysp_import */
 // LYEXT_PAR_TPDF,      /**< ::lysp_tpdf */
 // LYEXT_PAR_EXTINST,   /**< ::lysp_ext_instance */
 // LYEXT_PAR_REFINE,    /**< ::lysp_refine */
@@ -321,7 +321,7 @@
                                       lys_node_leaflist and lys_deviate */
     LYEXT_SUBSTMT_POSITION,      /**< extension of the position statement, can appear in lys_type_bit */
     LYEXT_SUBSTMT_UNIQUE,        /**< extension of the unique statement, can appear in lys_node_list and lys_deviate */
-    LYEXT_SUBSTMT_IFFEATURE,     /**< extension of the if-feature statement */
+    LYEXT_SUBSTMT_IFFEATURE      /**< extension of the if-feature statement */
 } LYEXT_SUBSTMT;
 
 /**
diff --git a/src/tree_schema_compile.c b/src/tree_schema_compile.c
index 05e2243..7547114 100644
--- a/src/tree_schema_compile.c
+++ b/src/tree_schema_compile.c
@@ -27,12 +27,12 @@
 #include "context.h"
 #include "dict.h"
 #include "log.h"
-#include "path.h"
 #include "parser.h"
 #include "parser_schema.h"
+#include "path.h"
 #include "plugins_exts.h"
-#include "plugins_types.h"
 #include "plugins_exts_internal.h"
+#include "plugins_types.h"
 #include "set.h"
 #include "tree.h"
 #include "tree_data.h"
@@ -291,7 +291,7 @@
         ctx->path[ctx->path_len] = '\0';
     } else {
         if (ctx->path_len > 1) {
-            if (!parent && ctx->path[ctx->path_len - 1] == '}' && ctx->path[ctx->path_len - 2] != '\'') {
+            if (!parent && (ctx->path[ctx->path_len - 1] == '}') && (ctx->path[ctx->path_len - 2] != '\'')) {
                 /* extension of the special tag */
                 nextlevel = 2;
                 --ctx->path_len;
@@ -302,7 +302,7 @@
         } /* else the path is just initiated with '/', so do not add additional slash in case of top-level nodes */
 
         if (nextlevel != 2) {
-            if ((parent && parent->module == ctx->mod) || (!parent && ctx->path_len > 1 && name[0] == '{')) {
+            if ((parent && (parent->module == ctx->mod)) || (!parent && (ctx->path_len > 1) && (name[0] == '{'))) {
                 /* module not changed, print the name unprefixed */
                 len = snprintf(&ctx->path[ctx->path_len], LYSC_CTX_BUFSIZE - ctx->path_len, "%s%s", nextlevel ? "/" : "", name);
             } else {
@@ -597,7 +597,7 @@
                 if (!ly_strncmp(ctx->mod_def->parsed->imports[v].module->ns, ext_p->name, u - 1)) {
                     char *s;
                     LY_CHECK_ERR_GOTO(asprintf(&s, "%s:%s", ctx->mod_def->parsed->imports[v].prefix, &ext_p->name[u]) == -1,
-                                      ret = LY_EMEM, cleanup);
+                            ret = LY_EMEM, cleanup);
                     LY_CHECK_GOTO(ret = lydict_insert_zc(ctx->ctx, s, &prefixed_name), cleanup);
                     u = strlen(ctx->mod_def->parsed->imports[v].prefix) + 1; /* add semicolon */
                     break;
@@ -606,7 +606,7 @@
         }
         if (!prefixed_name) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                   "Invalid XML prefix of \"%.*s\" namespace used for extension instance identifier.", u, ext_p->name);
+                    "Invalid XML prefix of \"%.*s\" namespace used for extension instance identifier.", u, ext_p->name);
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -619,7 +619,7 @@
         ext_mod = u ? lys_module_find_prefix(ctx->mod_def, prefixed_name, u - 1) : ctx->mod_def;
         if (!ext_mod) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                "Invalid prefix \"%.*s\" used for extension instance identifier.", u, prefixed_name);
+                    "Invalid prefix \"%.*s\" used for extension instance identifier.", u, prefixed_name);
             ret = LY_EVALID;
             goto cleanup;
         } else if (!ext_mod->parsed->extensions) {
@@ -642,7 +642,7 @@
     }
     if (!ext->def) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-               "Extension definition of extension instance \"%s\" not found.", prefixed_name);
+                "Extension definition of extension instance \"%s\" not found.", prefixed_name);
         ret = LY_EVALID;
         goto cleanup;
     }
@@ -675,7 +675,7 @@
         if (!stmt) {
             /* missing extension's argument */
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                   "Extension instance \"%s\" misses argument \"%s\".", prefixed_name, ext->def->argument);
+                    "Extension instance \"%s\" misses argument \"%s\".", prefixed_name, ext->def->argument);
             ret = LY_EVALID;
             goto cleanup;
 
@@ -703,7 +703,7 @@
     ext_p->compiled = ext;
 
 cleanup:
-    if (prefixed_name && prefixed_name != ext_p->name) {
+    if (prefixed_name && (prefixed_name != ext_p->name)) {
         lydict_remove(ctx->ctx, prefixed_name);
     }
 
@@ -753,7 +753,7 @@
             for (spaces = 0; c[i + op_len + spaces] && isspace(c[i + op_len + spaces]); spaces++) {}
             if (c[i + op_len + spaces] == '\0') {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid value \"%s\" of if-feature - unexpected end of expression.", qname->str);
+                        "Invalid value \"%s\" of if-feature - unexpected end of expression.", qname->str);
                 return LY_EVALID;
             } else if (!isspace(c[i + op_len])) {
                 /* feature name starting with the not/and/or */
@@ -770,8 +770,8 @@
             } else { /* and, or */
                 if (f_exp != f_size) {
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                           "Invalid value \"%s\" of if-feature - missing feature/expression before \"%.*s\" operation.",
-                           qname->str, op_len, &c[i]);
+                            "Invalid value \"%s\" of if-feature - missing feature/expression before \"%.*s\" operation.",
+                            qname->str, op_len, &c[i]);
                     return LY_EVALID;
                 }
                 f_exp++;
@@ -787,7 +787,7 @@
         expr_size++;
 
         while (!isspace(c[i])) {
-            if (!c[i] || c[i] == ')' || c[i] == '(') {
+            if (!c[i] || (c[i] == ')') || (c[i] == '(')) {
                 i--;
                 break;
             }
@@ -797,22 +797,22 @@
     if (j) {
         /* not matching count of ( and ) */
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-               "Invalid value \"%s\" of if-feature - non-matching opening and closing parentheses.", qname->str);
+                "Invalid value \"%s\" of if-feature - non-matching opening and closing parentheses.", qname->str);
         return LY_EVALID;
     }
     if (f_exp != f_size) {
         /* features do not match the needed arguments for the logical operations */
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-               "Invalid value \"%s\" of if-feature - number of features in expression does not match "
-               "the required number of operands for the operations.", qname->str);
+                "Invalid value \"%s\" of if-feature - number of features in expression does not match "
+                "the required number of operands for the operations.", qname->str);
         return LY_EVALID;
     }
 
-    if (checkversion || expr_size > 1) {
+    if (checkversion || (expr_size > 1)) {
         /* check that we have 1.1 module */
         if (qname->mod->version != LYS_VERSION_1_1) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                   "Invalid value \"%s\" of if-feature - YANG 1.1 expression in YANG 1.0 module.", qname->str);
+                    "Invalid value \"%s\" of if-feature - YANG 1.1 expression in YANG 1.0 module.", qname->str);
             return LY_EVALID;
         }
     }
@@ -849,7 +849,7 @@
         i++; /* go back by one step */
 
         if (!strncmp(&c[i], "not", 3) && isspace(c[i + 3])) {
-            if (stack.index && stack.stack[stack.index - 1] == LYS_IFF_NOT) {
+            if (stack.index && (stack.stack[stack.index - 1] == LYS_IFF_NOT)) {
                 /* double not */
                 iff_stack_pop(&stack);
             } else {
@@ -998,10 +998,10 @@
                 LOGINT(ctx->ctx);
             } else {
                 LY_CHECK_RET(lys_parse(ctx->ctx, in, !strcmp(&imp_p->module->filepath[strlen(imp_p->module->filepath - 4)],
-                                                             ".yin") ? LYS_IN_YIN : LYS_IN_YANG, &mod));
+                        ".yin") ? LYS_IN_YIN : LYS_IN_YANG, &mod));
                 if (mod != imp_p->module) {
                     LOGERR(ctx->ctx, LY_EINT, "Filepath \"%s\" of the module \"%s\" does not match.",
-                           imp_p->module->filepath, imp_p->module->name);
+                            imp_p->module->filepath, imp_p->module->name);
                     mod = NULL;
                 }
             }
@@ -1010,7 +1010,7 @@
         if (!mod) {
             if (lysp_load_module(ctx->ctx, imp_p->module->name, imp_p->module->revision, 0, 1, (struct lys_module **)&mod)) {
                 LOGERR(ctx->ctx, LY_ENOTFOUND, "Unable to reload \"%s\" module to import it into \"%s\", source data not found.",
-                       imp_p->module->name, ctx->mod->name);
+                        imp_p->module->name, ctx->mod->name);
                 return LY_ENOTFOUND;
             }
         }
@@ -1057,10 +1057,10 @@
         DUP_STRING_GOTO(ctx_sc->ctx, identities_p[u].ref, (*identities)[offset + u].ref, ret, done);
         (*identities)[offset + u].module = ctx_sc->mod;
         COMPILE_ARRAY_GOTO(ctx_sc, identities_p[u].iffeatures, (*identities)[offset + u].iffeatures, v,
-                           lys_compile_iffeature, ret, done);
+                lys_compile_iffeature, ret, done);
         /* backlinks (derived) can be added no sooner than when all the identities in the current module are present */
         COMPILE_EXTS_GOTO(ctx_sc, identities_p[u].exts, (*identities)[offset + u].exts, &(*identities)[offset + u],
-                          LYEXT_PAR_IDENT, ret, done);
+                LYEXT_PAR_IDENT, ret, done);
         (*identities)[offset + u].flags = identities_p[u].flags;
 
         lysc_update_path(ctx_sc, NULL, NULL);
@@ -1096,7 +1096,7 @@
     for (u = 0; u < LY_ARRAY_COUNT(derived); ++u) {
         if (ident == derived[u]) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                   "Identity \"%s\" is indirectly derived from itself.", ident->name);
+                    "Identity \"%s\" is indirectly derived from itself.", ident->name);
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -1112,7 +1112,7 @@
         for (u = 0; u < LY_ARRAY_COUNT(drv->derived); ++u) {
             if (ident == drv->derived[u]) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                       "Identity \"%s\" is indirectly derived from itself.", ident->name);
+                        "Identity \"%s\" is indirectly derived from itself.", ident->name);
                 ret = LY_EVALID;
                 goto cleanup;
             }
@@ -1150,9 +1150,9 @@
 
     assert(ident || bases);
 
-    if (LY_ARRAY_COUNT(bases_p) > 1 && ctx->mod_def->version < 2) {
+    if ((LY_ARRAY_COUNT(bases_p) > 1) && (ctx->mod_def->version < 2)) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-               "Multiple bases in %s are allowed only in YANG 1.1 modules.", ident ? "identity" : "identityref type");
+                "Multiple bases in %s are allowed only in YANG 1.1 modules.", ident ? "identity" : "identityref type");
         return LY_EVALID;
     }
 
@@ -1169,10 +1169,10 @@
         if (!mod) {
             if (ident) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid prefix used for base (%s) of identity \"%s\".", bases_p[u], ident->name);
+                        "Invalid prefix used for base (%s) of identity \"%s\".", bases_p[u], ident->name);
             } else {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid prefix used for base (%s) of identityref.", bases_p[u]);
+                        "Invalid prefix used for base (%s) of identityref.", bases_p[u]);
             }
             return LY_EVALID;
         }
@@ -1183,7 +1183,7 @@
                 if (ident) {
                     if (ident == &mod->identities[v]) {
                         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                               "Identity \"%s\" is derived from itself.", ident->name);
+                                "Identity \"%s\" is derived from itself.", ident->name);
                         return LY_EVALID;
                     }
                     LY_CHECK_RET(lys_compile_identity_circular_check(ctx, &mod->identities[v], ident->derived));
@@ -1201,10 +1201,10 @@
         if (!idref || !(*idref)) {
             if (ident) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Unable to find base (%s) of identity \"%s\".", bases_p[u], ident->name);
+                        "Unable to find base (%s) of identity \"%s\".", bases_p[u], ident->name);
             } else {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Unable to find base (%s) of identityref.", bases_p[u]);
+                        "Unable to find base (%s) of identityref.", bases_p[u]);
             }
             return LY_EVALID;
         }
@@ -1310,7 +1310,7 @@
     for (u = 0; u < LY_ARRAY_COUNT(depfeatures); ++u) {
         if (feature == depfeatures[u]) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                   "Feature \"%s\" is indirectly referenced from itself.", feature->name);
+                    "Feature \"%s\" is indirectly referenced from itself.", feature->name);
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -1326,7 +1326,7 @@
         for (u = 0; u < LY_ARRAY_COUNT(drv->depfeatures); ++u) {
             if (feature == drv->depfeatures[u]) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                       "Feature \"%s\" is indirectly referenced from itself.", feature->name);
+                        "Feature \"%s\" is indirectly referenced from itself.", feature->name);
                 ret = LY_EVALID;
                 goto cleanup;
             }
@@ -1376,7 +1376,7 @@
                         /* check for circular dependency - direct reference first,... */
                         if (feature == feature->iffeatures[u].features[v]) {
                             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                                   "Feature \"%s\" is referenced from itself.", feature->name);
+                                    "Feature \"%s\" is referenced from itself.", feature->name);
                             return LY_EVALID;
                         }
                         /* ... and indirect circular reference */
@@ -1391,7 +1391,7 @@
         }
         lysc_update_path(ctx, NULL, NULL);
         lysc_update_path(ctx, NULL, NULL);
-    done:
+done:
         return ret;
     }
 
@@ -1483,8 +1483,8 @@
         assert(frdigits);
         if (fraction && (*len - 1 - fraction > frdigits)) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                   "Range boundary \"%.*s\" of decimal64 type exceeds defined number (%u) of fraction digits.",
-                   *len, value, frdigits);
+                    "Range boundary \"%.*s\" of decimal64 type exceeds defined number (%u) of fraction digits.",
+                    *len, value, frdigits);
             return LY_EINVAL;
         }
         if (fraction) {
@@ -1521,11 +1521,11 @@
 range_part_check_ascendancy(ly_bool unsigned_value, ly_bool max, int64_t value, int64_t prev_value)
 {
     if (unsigned_value) {
-        if ((max && (uint64_t)prev_value > (uint64_t)value) || (!max && (uint64_t)prev_value >= (uint64_t)value)) {
+        if ((max && ((uint64_t)prev_value > (uint64_t)value)) || (!max && ((uint64_t)prev_value >= (uint64_t)value))) {
             return LY_EEXIST;
         }
     } else {
-        if ((max && prev_value > value) || (!max && prev_value >= value)) {
+        if ((max && (prev_value > value)) || (!max && (prev_value >= value))) {
             return LY_EEXIST;
         }
     }
@@ -1613,7 +1613,7 @@
     case LY_TYPE_DEC64: /* range */
         if (valcopy) {
             ret = ly_parse_int(valcopy, strlen(valcopy), INT64_C(-9223372036854775807) - INT64_C(1), INT64_C(9223372036854775807), 10,
-                               max ? &part->max_64 : &part->min_64);
+                    max ? &part->max_64 : &part->min_64);
         } else if (max) {
             part->max_64 = INT64_C(9223372036854775807);
         } else {
@@ -1681,16 +1681,16 @@
 finalize:
     if (ret == LY_EDENIED) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-               "Invalid %s restriction - value \"%s\" does not fit the type limitations.",
-               length_restr ? "length" : "range", valcopy ? valcopy : *value);
+                "Invalid %s restriction - value \"%s\" does not fit the type limitations.",
+                length_restr ? "length" : "range", valcopy ? valcopy : *value);
     } else if (ret == LY_EVALID) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-               "Invalid %s restriction - invalid value \"%s\".",
-               length_restr ? "length" : "range", valcopy ? valcopy : *value);
+                "Invalid %s restriction - invalid value \"%s\".",
+                length_restr ? "length" : "range", valcopy ? valcopy : *value);
     } else if (ret == LY_EEXIST) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid %s restriction - values are not in ascending order (%s).",
-                       length_restr ? "length" : "range",
+                "Invalid %s restriction - values are not in ascending order (%s).",
+                length_restr ? "length" : "range",
                 (valcopy && basetype != LY_TYPE_DEC64) ? valcopy : value ? *value : max ? "max" : "min");
     } else if (!ret && value) {
         *value = *value + len;
@@ -1731,13 +1731,13 @@
         } else if (*expr == '\0') {
             if (range_expected) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid %s restriction - unexpected end of the expression after \"..\" (%s).",
-                       length_restr ? "length" : "range", range_p->arg);
+                        "Invalid %s restriction - unexpected end of the expression after \"..\" (%s).",
+                        length_restr ? "length" : "range", range_p->arg);
                 goto cleanup;
-            } else if (!parts || parts_done == LY_ARRAY_COUNT(parts)) {
+            } else if (!parts || (parts_done == LY_ARRAY_COUNT(parts))) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid %s restriction - unexpected end of the expression (%s).",
-                       length_restr ? "length" : "range", range_p->arg);
+                        "Invalid %s restriction - unexpected end of the expression (%s).",
+                        length_restr ? "length" : "range", range_p->arg);
                 goto cleanup;
             }
             parts_done++;
@@ -1746,8 +1746,8 @@
             if (parts) {
                 /* min cannot be used elsewhere than in the first part */
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid %s restriction - unexpected data before min keyword (%.*s).", length_restr ? "length" : "range",
-                       expr - range_p->arg.str, range_p->arg.str);
+                        "Invalid %s restriction - unexpected data before min keyword (%.*s).", length_restr ? "length" : "range",
+                        expr - range_p->arg.str, range_p->arg.str);
                 goto cleanup;
             }
             expr += 3;
@@ -1758,7 +1758,7 @@
         } else if (*expr == '|') {
             if (!parts || range_expected) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid %s restriction - unexpected beginning of the expression (%s).", length_restr ? "length" : "range", expr);
+                        "Invalid %s restriction - unexpected beginning of the expression (%s).", length_restr ? "length" : "range", expr);
                 goto cleanup;
             }
             expr++;
@@ -1769,9 +1769,9 @@
             while (isspace(*expr)) {
                 expr++;
             }
-            if (!parts || LY_ARRAY_COUNT(parts) == parts_done) {
+            if (!parts || (LY_ARRAY_COUNT(parts) == parts_done)) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid %s restriction - unexpected \"..\" without a lower bound.", length_restr ? "length" : "range");
+                        "Invalid %s restriction - unexpected \"..\" without a lower bound.", length_restr ? "length" : "range");
                 goto cleanup;
             }
             /* continue expecting the upper boundary */
@@ -1785,7 +1785,7 @@
             } else {
                 LY_ARRAY_NEW_GOTO(ctx->ctx, parts, part, ret, cleanup);
                 LY_CHECK_GOTO(range_part_minmax(ctx, part, 0, parts_done ? parts[LY_ARRAY_COUNT(parts) - 2].max_64 : 0,
-                                                basetype, parts_done ? 0 : 1, length_restr, frdigits, NULL, &expr), cleanup);
+                        basetype, parts_done ? 0 : 1, length_restr, frdigits, NULL, &expr), cleanup);
                 part->max_64 = part->min_64;
             }
 
@@ -1797,7 +1797,7 @@
             }
             if (*expr != '\0') {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid %s restriction - unexpected data after max keyword (%s).",
-                       length_restr ? "length" : "range", expr);
+                        length_restr ? "length" : "range", expr);
                 goto cleanup;
             }
             if (range_expected) {
@@ -1807,12 +1807,12 @@
             } else {
                 LY_ARRAY_NEW_GOTO(ctx->ctx, parts, part, ret, cleanup);
                 LY_CHECK_GOTO(range_part_minmax(ctx, part, 1, parts_done ? parts[LY_ARRAY_COUNT(parts) - 2].max_64 : 0,
-                                                basetype, parts_done ? 0 : 1, length_restr, frdigits, base_range, NULL), cleanup);
+                        basetype, parts_done ? 0 : 1, length_restr, frdigits, base_range, NULL), cleanup);
                 part->min_64 = part->max_64;
             }
         } else {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid %s restriction - unexpected data (%s).",
-                   length_restr ? "length" : "range", expr);
+                    length_restr ? "length" : "range", expr);
             goto cleanup;
         }
     }
@@ -1841,7 +1841,7 @@
             goto cleanup;
         }
         for (u = v = 0; u < parts_done && v < LY_ARRAY_COUNT(base_range->parts); ++u) {
-            if ((uns && parts[u].min_u64 < base_range->parts[v].min_u64) || (!uns && parts[u].min_64 < base_range->parts[v].min_64)) {
+            if ((uns && (parts[u].min_u64 < base_range->parts[v].min_u64)) || (!uns && (parts[u].min_64 < base_range->parts[v].min_64))) {
                 goto baseerror;
             }
             /* current lower bound is not lower than the base */
@@ -1869,7 +1869,7 @@
                 /* base is the range */
                 if (parts[u].min_64 == parts[u].max_64) {
                     /* current is a single value */
-                    if ((uns && parts[u].max_u64 > base_range->parts[v].max_u64) || (!uns && parts[u].max_64 > base_range->parts[v].max_64)) {
+                    if ((uns && (parts[u].max_u64 > base_range->parts[v].max_u64)) || (!uns && (parts[u].max_64 > base_range->parts[v].max_64))) {
                         /* current is behind the base range, so base range is omitted,
                          * move the base and keep the current for further check */
                         ++v;
@@ -1878,9 +1878,9 @@
                     continue;
                 } else {
                     /* both are ranges - check the higher bound, the lower was already checked */
-                    if ((uns && parts[u].max_u64 > base_range->parts[v].max_u64) || (!uns && parts[u].max_64 > base_range->parts[v].max_64)) {
+                    if ((uns && (parts[u].max_u64 > base_range->parts[v].max_u64)) || (!uns && (parts[u].max_64 > base_range->parts[v].max_64))) {
                         /* higher bound is higher than the current higher bound */
-                        if ((uns && parts[u].min_u64 > base_range->parts[v].max_u64) || (!uns && parts[u].min_64 > base_range->parts[v].max_64)) {
+                        if ((uns && (parts[u].min_u64 > base_range->parts[v].max_u64)) || (!uns && (parts[u].min_64 > base_range->parts[v].max_64))) {
                             /* but the current lower bound is also higher, so the base range is omitted,
                              * continue with the same current, but move the base */
                             --u;
@@ -1900,8 +1900,8 @@
         if (u != parts_done) {
 baseerror:
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                   "Invalid %s restriction - the derived restriction (%s) is not equally or more limiting.",
-                   length_restr ? "length" : "range", range_p->arg);
+                    "Invalid %s restriction - the derived restriction (%s) is not equally or more limiting.",
+                    length_restr ? "length" : "range", range_p->arg);
             goto cleanup;
         }
     }
@@ -1957,6 +1957,7 @@
     const char *orig_ptr;
     PCRE2_SIZE err_offset;
     pcre2_code *code_local;
+
 #define URANGE_LEN 19
     char *ublock2urange[][2] = {
         {"BasicLatin", "[\\x{0000}-\\x{007F}]"},
@@ -2105,7 +2106,7 @@
         ptr = strchr(ptr, '}');
         if (!ptr) {
             LOGVAL(ctx, LY_VLOG_STR, log_path, LY_VCODE_INREGEXP,
-                   pattern, perl_regex + start + 2, "unterminated character property");
+                    pattern, perl_regex + start + 2, "unterminated character property");
             free(perl_regex);
             return LY_EVALID;
         }
@@ -2125,7 +2126,7 @@
         }
         if (!ublock2urange[idx][0]) {
             LOGVAL(ctx, LY_VLOG_STR, log_path, LY_VCODE_INREGEXP,
-                   pattern, perl_regex + start + 5, "unknown block name");
+                    pattern, perl_regex + start + 5, "unknown block name");
             free(perl_regex);
             return LY_EVALID;
         }
@@ -2151,8 +2152,8 @@
 
     /* must return 0, already checked during parsing */
     code_local = pcre2_compile((PCRE2_SPTR)perl_regex, PCRE2_ZERO_TERMINATED,
-                               PCRE2_UTF | PCRE2_ANCHORED | PCRE2_ENDANCHORED | PCRE2_DOLLAR_ENDONLY | PCRE2_NO_AUTO_CAPTURE,
-                           &err_code, &err_offset, NULL);
+            PCRE2_UTF | PCRE2_ANCHORED | PCRE2_ENDANCHORED | PCRE2_DOLLAR_ENDONLY | PCRE2_NO_AUTO_CAPTURE,
+            &err_code, &err_offset, NULL);
     if (!code_local) {
         PCRE2_UCHAR err_msg[256] = {0};
         pcre2_get_error_message(err_code, err_msg, 256);
@@ -2247,9 +2248,11 @@
 /**
  * @brief stringification of the YANG built-in data types
  */
-const char *ly_data_type2str[LY_DATA_TYPE_COUNT] = {"unknown", "binary", "8bit unsigned integer", "16bit unsigned integer",
+const char *ly_data_type2str[LY_DATA_TYPE_COUNT] = {
+    "unknown", "binary", "8bit unsigned integer", "16bit unsigned integer",
     "32bit unsigned integer", "64bit unsigned integer", "string", "bits", "boolean", "decimal64", "empty", "enumeration",
-    "identityref", "instance-identifier", "leafref", "union", "8bit integer", "16bit integer", "32bit integer", "64bit integer"};
+    "identityref", "instance-identifier", "leafref", "union", "8bit integer", "16bit integer", "32bit integer", "64bit integer"
+};
 
 /**
  * @brief Compile parsed type's enum structures (for enumeration and bits types).
@@ -2270,9 +2273,9 @@
     uint32_t position = 0;
     struct lysc_type_bitenum_item *e, storage;
 
-    if (base_enums && ctx->mod_def->version < 2) {
+    if (base_enums && (ctx->mod_def->version < 2)) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "%s type can be subtyped only in YANG 1.1 modules.",
-               basetype == LY_TYPE_ENUM ? "Enumeration" : "Bits");
+                basetype == LY_TYPE_ENUM ? "Enumeration" : "Bits");
         return LY_EVALID;
     }
 
@@ -2291,8 +2294,8 @@
             }
             if (v == LY_ARRAY_COUNT(base_enums)) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid %s - derived type adds new item \"%s\".",
-                       basetype == LY_TYPE_ENUM ? "enumeration" : "bits", e->name);
+                        "Invalid %s - derived type adds new item \"%s\".",
+                        basetype == LY_TYPE_ENUM ? "enumeration" : "bits", e->name);
                 return LY_EVALID;
             }
             match = v;
@@ -2302,31 +2305,31 @@
             e->flags |= LYS_ISENUM;
             if (enums_p[u].flags & LYS_SET_VALUE) {
                 e->value = (int32_t)enums_p[u].value;
-                if (!u || e->value >= value) {
+                if (!u || (e->value >= value)) {
                     value = e->value + 1;
                 }
                 /* check collision with other values */
                 for (v = 0; v < LY_ARRAY_COUNT(*enums) - 1; ++v) {
                     if (e->value == (*enums)[v].value) {
                         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                               "Invalid enumeration - value %d collide in items \"%s\" and \"%s\".",
-                               e->value, e->name, (*enums)[v].name);
+                                "Invalid enumeration - value %d collide in items \"%s\" and \"%s\".",
+                                e->value, e->name, (*enums)[v].name);
                         return LY_EVALID;
                     }
                 }
             } else if (base_enums) {
                 /* inherit the assigned value */
                 e->value = base_enums[match].value;
-                if (!u || e->value >= value) {
+                if (!u || (e->value >= value)) {
                     value = e->value + 1;
                 }
             } else {
                 /* assign value automatically */
-                if (u && value == INT32_MIN) {
+                if (u && (value == INT32_MIN)) {
                     /* counter overflow */
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                           "Invalid enumeration - it is not possible to auto-assign enum value for "
-                           "\"%s\" since the highest value is already 2147483647.", e->name);
+                            "Invalid enumeration - it is not possible to auto-assign enum value for "
+                            "\"%s\" since the highest value is already 2147483647.", e->name);
                     return LY_EVALID;
                 }
                 e->value = value++;
@@ -2334,14 +2337,14 @@
         } else { /* LY_TYPE_BITS */
             if (enums_p[u].flags & LYS_SET_VALUE) {
                 e->value = (int32_t)enums_p[u].value;
-                if (!u || (uint32_t)e->value >= position) {
+                if (!u || ((uint32_t)e->value >= position)) {
                     position = (uint32_t)e->value + 1;
                 }
                 /* check collision with other values */
                 for (v = 0; v < LY_ARRAY_COUNT(*enums) - 1; ++v) {
                     if (e->value == (*enums)[v].value) {
                         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                               "Invalid bits - position %u collide in items \"%s\" and \"%s\".",
+                                "Invalid bits - position %u collide in items \"%s\" and \"%s\".",
                                 (uint32_t)e->value, e->name, (*enums)[v].name);
                         return LY_EVALID;
                     }
@@ -2349,16 +2352,16 @@
             } else if (base_enums) {
                 /* inherit the assigned value */
                 e->value = base_enums[match].value;
-                if (!u || (uint32_t)e->value >= position) {
+                if (!u || ((uint32_t)e->value >= position)) {
                     position = (uint32_t)e->value + 1;
                 }
             } else {
                 /* assign value automatically */
-                if (u && position == 0) {
+                if (u && (position == 0)) {
                     /* counter overflow */
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                           "Invalid bits - it is not possible to auto-assign bit position for "
-                           "\"%s\" since the highest value is already 4294967295.", e->name);
+                            "Invalid bits - it is not possible to auto-assign bit position for "
+                            "\"%s\" since the highest value is already 4294967295.", e->name);
                     return LY_EVALID;
                 }
                 e->value = position++;
@@ -2370,12 +2373,12 @@
             if (e->value != base_enums[match].value) {
                 if (basetype == LY_TYPE_ENUM) {
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid enumeration - value of the item \"%s\" has changed from %d to %d in the derived type.",
-                       e->name, base_enums[match].value, e->value);
+                            "Invalid enumeration - value of the item \"%s\" has changed from %d to %d in the derived type.",
+                            e->name, base_enums[match].value, e->value);
                 } else {
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid bits - position of the item \"%s\" has changed from %u to %u in the derived type.",
-                       e->name, (uint32_t)base_enums[match].value, (uint32_t)e->value);
+                            "Invalid bits - position of the item \"%s\" has changed from %u to %u in the derived type.",
+                            e->name, (uint32_t)base_enums[match].value, (uint32_t)e->value);
                 }
                 return LY_EVALID;
             }
@@ -2462,7 +2465,7 @@
     /* node-identifier ([prefix:]name) */
     LY_CHECK_RET(ly_parse_nodeid(path, prefix, prefix_len, name, name_len));
 
-    if ((**path == '/' && (*path)[1]) || !**path) {
+    if (((**path == '/') && (*path)[1]) || !**path) {
         /* path continues by another token or this is the last token */
         return LY_SUCCESS;
     } else if ((*path)[0] != '[') {
@@ -2567,7 +2570,7 @@
         /* RFC 7950 9.8.1, 9.4.4 - length, number of octets it contains */
         if (type_p->length) {
             LY_CHECK_RET(lys_compile_type_range(ctx, type_p->length, basetype, 1, 0,
-                                                base ? ((struct lysc_type_bin *)base)->length : NULL, &bin->length));
+                    base ? ((struct lysc_type_bin *)base)->length : NULL, &bin->length));
             if (!tpdfname) {
                 COMPILE_EXTS_GOTO(ctx, type_p->length->exts, bin->length->exts, bin->length, LYEXT_PAR_LENGTH, ret, cleanup);
             }
@@ -2578,7 +2581,7 @@
         bits = (struct lysc_type_bits *)(*type);
         if (type_p->bits) {
             LY_CHECK_RET(lys_compile_type_enums(ctx, type_p->bits, basetype,
-                                                base ? (struct lysc_type_bitenum_item *)((struct lysc_type_bits *)base)->bits : NULL,
+                    base ? (struct lysc_type_bitenum_item *)((struct lysc_type_bits *)base)->bits : NULL,
                     (struct lysc_type_bitenum_item **)&bits->bits));
         }
 
@@ -2611,11 +2614,11 @@
                 /* fraction digits is prohibited in types not directly derived from built-in decimal64 */
                 if (tpdfname) {
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                           "Invalid fraction-digits substatement for type \"%s\" not directly derived from decimal64 built-in type.",
-                           tpdfname);
+                            "Invalid fraction-digits substatement for type \"%s\" not directly derived from decimal64 built-in type.",
+                            tpdfname);
                 } else {
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                           "Invalid fraction-digits substatement for type not directly derived from decimal64 built-in type.");
+                            "Invalid fraction-digits substatement for type not directly derived from decimal64 built-in type.");
                 }
                 return LY_EVALID;
             }
@@ -2625,7 +2628,7 @@
         /* RFC 7950 9.2.4 - range */
         if (type_p->range) {
             LY_CHECK_RET(lys_compile_type_range(ctx, type_p->range, basetype, 0, dec->fraction_digits,
-                                                base ? ((struct lysc_type_dec *)base)->range : NULL, &dec->range));
+                    base ? ((struct lysc_type_dec *)base)->range : NULL, &dec->range));
             if (!tpdfname) {
                 COMPILE_EXTS_GOTO(ctx, type_p->range->exts, dec->range->exts, dec->range, LYEXT_PAR_RANGE, ret, cleanup);
             }
@@ -2637,7 +2640,7 @@
         /* RFC 7950 9.4.4 - length */
         if (type_p->length) {
             LY_CHECK_RET(lys_compile_type_range(ctx, type_p->length, basetype, 1, 0,
-                                                base ? ((struct lysc_type_str *)base)->length : NULL, &str->length));
+                    base ? ((struct lysc_type_str *)base)->length : NULL, &str->length));
             if (!tpdfname) {
                 COMPILE_EXTS_GOTO(ctx, type_p->length->exts, str->length->exts, str->length, LYEXT_PAR_LENGTH, ret, cleanup);
             }
@@ -2648,7 +2651,7 @@
         /* RFC 7950 9.4.5 - pattern */
         if (type_p->patterns) {
             LY_CHECK_RET(lys_compile_type_patterns(ctx, type_p->patterns,
-                                                   base ? ((struct lysc_type_str *)base)->patterns : NULL, &str->patterns));
+                    base ? ((struct lysc_type_str *)base)->patterns : NULL, &str->patterns));
         } else if (base && ((struct lysc_type_str *)base)->patterns) {
             str->patterns = lysc_patterns_dup(ctx->ctx, ((struct lysc_type_str *)base)->patterns);
         }
@@ -2659,7 +2662,7 @@
         /* RFC 7950 9.6 - enum */
         if (type_p->enums) {
             LY_CHECK_RET(lys_compile_type_enums(ctx, type_p->enums, basetype,
-                                                base ? ((struct lysc_type_enum *)base)->enums : NULL, &enumeration->enums));
+                    base ? ((struct lysc_type_enum *)base)->enums : NULL, &enumeration->enums));
         }
 
         if (!base && !type_p->flags) {
@@ -2685,7 +2688,7 @@
         /* RFC 6020 9.2.4 - range */
         if (type_p->range) {
             LY_CHECK_RET(lys_compile_type_range(ctx, type_p->range, basetype, 0, 0,
-                                                base ? ((struct lysc_type_num *)base)->range : NULL, &num->range));
+                    base ? ((struct lysc_type_num *)base)->range : NULL, &num->range));
             if (!tpdfname) {
                 COMPILE_EXTS_GOTO(ctx, type_p->range->exts, num->range->exts, num->range, LYEXT_PAR_RANGE, ret, cleanup);
             }
@@ -2700,11 +2703,11 @@
                 /* only the directly derived identityrefs can contain base specification */
                 if (tpdfname) {
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                           "Invalid base substatement for the type \"%s\" not directly derived from identityref built-in type.",
-                           tpdfname);
+                            "Invalid base substatement for the type \"%s\" not directly derived from identityref built-in type.",
+                            tpdfname);
                 } else {
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                           "Invalid base substatement for the type not directly derived from identityref built-in type.");
+                            "Invalid base substatement for the type not directly derived from identityref built-in type.");
                 }
                 return LY_EVALID;
             }
@@ -2729,10 +2732,10 @@
             if (context_mod->mod->version < LYS_VERSION_1_1) {
                 if (tpdfname) {
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                           "Leafref type \"%s\" can be restricted by require-instance statement only in YANG 1.1 modules.", tpdfname);
+                            "Leafref type \"%s\" can be restricted by require-instance statement only in YANG 1.1 modules.", tpdfname);
                 } else {
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                           "Leafref type can be restricted by require-instance statement only in YANG 1.1 modules.");
+                            "Leafref type can be restricted by require-instance statement only in YANG 1.1 modules.");
                 }
                 return LY_EVALID;
             }
@@ -2776,11 +2779,11 @@
                 /* only the directly derived union can contain types specification */
                 if (tpdfname) {
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                           "Invalid type substatement for the type \"%s\" not directly derived from union built-in type.",
-                           tpdfname);
+                            "Invalid type substatement for the type \"%s\" not directly derived from union built-in type.",
+                            tpdfname);
                 } else {
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                           "Invalid type substatement for the type not directly derived from union built-in type.");
+                            "Invalid type substatement for the type not directly derived from union built-in type.");
                 }
                 return LY_EVALID;
             }
@@ -2788,12 +2791,12 @@
             LY_ARRAY_CREATE_RET(ctx->ctx, un->types, LY_ARRAY_COUNT(type_p->types), LY_EVALID);
             for (LY_ARRAY_COUNT_TYPE u = 0, additional = 0; u < LY_ARRAY_COUNT(type_p->types); ++u) {
                 LY_CHECK_RET(lys_compile_type(ctx, context_pnode, context_flags, context_mod, context_name,
-                                              &type_p->types[u], &un->types[u + additional], NULL, NULL));
+                        &type_p->types[u], &un->types[u + additional], NULL, NULL));
                 if (un->types[u + additional]->basetype == LY_TYPE_UNION) {
                     /* add space for additional types from the union subtype */
                     un_aux = (struct lysc_type_union *)un->types[u + additional];
                     LY_ARRAY_RESIZE_ERR_RET(ctx->ctx, un->types, (*((uint64_t *)(type_p->types) - 1)) + additional + LY_ARRAY_COUNT(un_aux->types) - 1,
-                                            lysc_type_free(ctx->ctx, (struct lysc_type *)un_aux), LY_EMEM);
+                            lysc_type_free(ctx->ctx, (struct lysc_type *)un_aux), LY_EMEM);
 
                     /* copy subtypes of the subtype union */
                     for (LY_ARRAY_COUNT_TYPE v = 0; v < LY_ARRAY_COUNT(un_aux->types); ++v) {
@@ -2942,17 +2945,17 @@
     tctx = calloc(1, sizeof *tctx);
     LY_CHECK_ERR_RET(!tctx, LOGMEM(ctx->ctx), LY_EMEM);
     for (ret = lysp_type_find(type_p->name, context_pnode, ctx->mod_def->parsed,
-                             &basetype, &tctx->tpdf, &tctx->node, &tctx->mod);
+            &basetype, &tctx->tpdf, &tctx->node, &tctx->mod);
             ret == LY_SUCCESS;
             ret = lysp_type_find(tctx_prev->tpdf->type.name, tctx_prev->node, tctx_prev->mod,
-                                         &basetype, &tctx->tpdf, &tctx->node, &tctx->mod)) {
+                    &basetype, &tctx->tpdf, &tctx->node, &tctx->mod)) {
         if (basetype) {
             break;
         }
 
         /* check status */
         ret = lysc_check_status(ctx, context_flags, context_mod, context_name,
-                                tctx->tpdf->flags, tctx->mod, tctx->node ? tctx->node->name : tctx->tpdf->name);
+                tctx->tpdf->flags, tctx->mod, tctx->node ? tctx->node->name : tctx->tpdf->name);
         LY_CHECK_ERR_GOTO(ret, free(tctx), cleanup);
 
         if (units && !*units) {
@@ -2990,9 +2993,9 @@
         for (uint32_t u = 0; u < tpdf_chain.count; u++) {
             /* local part */
             tctx_iter = (struct type_context *)tpdf_chain.objs[u];
-            if (tctx_iter->mod == tctx->mod && tctx_iter->node == tctx->node && tctx_iter->tpdf == tctx->tpdf) {
+            if ((tctx_iter->mod == tctx->mod) && (tctx_iter->node == tctx->node) && (tctx_iter->tpdf == tctx->tpdf)) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                       "Invalid \"%s\" type reference - circular chain of types detected.", tctx->tpdf->name);
+                        "Invalid \"%s\" type reference - circular chain of types detected.", tctx->tpdf->name);
                 free(tctx);
                 ret = LY_EVALID;
                 goto cleanup;
@@ -3001,9 +3004,9 @@
         for (uint32_t u = 0; u < ctx->tpdf_chain.count; u++) {
             /* global part for unions corner case */
             tctx_iter = (struct type_context *)ctx->tpdf_chain.objs[u];
-            if (tctx_iter->mod == tctx->mod && tctx_iter->node == tctx->node && tctx_iter->tpdf == tctx->tpdf) {
+            if ((tctx_iter->mod == tctx->mod) && (tctx_iter->node == tctx->node) && (tctx_iter->tpdf == tctx->tpdf)) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                       "Invalid \"%s\" type reference - circular chain of types detected.", tctx->tpdf->name);
+                        "Invalid \"%s\" type reference - circular chain of types detected.", tctx->tpdf->name);
                 free(tctx);
                 ret = LY_EVALID;
                 goto cleanup;
@@ -3067,14 +3070,14 @@
         break;
     case LY_TYPE_UNKNOWN:
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-               "Referenced type \"%s\" not found.", tctx_prev ? tctx_prev->tpdf->type.name : type_p->name);
+                "Referenced type \"%s\" not found.", tctx_prev ? tctx_prev->tpdf->type.name : type_p->name);
         ret = LY_EVALID;
         goto cleanup;
     }
     LY_CHECK_ERR_GOTO(!(*type), LOGMEM(ctx->ctx), cleanup);
     if (~type_substmt_map[basetype] & type_p->flags) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid type restrictions for %s type.",
-               ly_data_type2str[basetype]);
+                ly_data_type2str[basetype]);
         free(*type);
         (*type) = NULL;
         ret = LY_EVALID;
@@ -3092,7 +3095,7 @@
         if (tctx->tpdf->type.compiled) {
             base = tctx->tpdf->type.compiled;
             continue;
-        } else if (basetype != LY_TYPE_LEAFREF && (u != tpdf_chain.count - 1) && !(tctx->tpdf->type.flags)) {
+        } else if ((basetype != LY_TYPE_LEAFREF) && (u != tpdf_chain.count - 1) && !(tctx->tpdf->type.flags)) {
             /* no change, just use the type information from the base */
             base = ((struct lysp_tpdf *)tctx->tpdf)->type.compiled = ((struct type_context *)tpdf_chain.objs[u + 1])->tpdf->type.compiled;
             ++base->refcount;
@@ -3102,13 +3105,13 @@
         ++(*type)->refcount;
         if (~type_substmt_map[basetype] & tctx->tpdf->type.flags) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid type \"%s\" restriction(s) for %s type.",
-                   tctx->tpdf->name, ly_data_type2str[basetype]);
+                    tctx->tpdf->name, ly_data_type2str[basetype]);
             ret = LY_EVALID;
             goto cleanup;
-        } else if (basetype == LY_TYPE_EMPTY && tctx->tpdf->dflt.str) {
+        } else if ((basetype == LY_TYPE_EMPTY) && tctx->tpdf->dflt.str) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                   "Invalid type \"%s\" - \"empty\" type must not have a default value (%s).",
-                   tctx->tpdf->name, tctx->tpdf->dflt.str);
+                    "Invalid type \"%s\" - \"empty\" type must not have a default value (%s).",
+                    tctx->tpdf->name, tctx->tpdf->dflt.str);
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -3126,7 +3129,7 @@
     ctx->tpdf_chain.count = ctx->tpdf_chain.count - tpdf_chain.count;
 
     /* process the type definition in leaf */
-    if (type_p->flags || !base || basetype == LY_TYPE_LEAFREF) {
+    if (type_p->flags || !base || (basetype == LY_TYPE_LEAFREF)) {
         /* get restrictions from the node itself */
         (*type)->basetype = basetype;
         /* TODO user type plugins */
@@ -3135,7 +3138,7 @@
         ret = lys_compile_type_(ctx, context_pnode, context_flags, context_mod, context_name, type_p, basetype, NULL,
                 base, type);
         LY_CHECK_GOTO(ret, cleanup);
-    } else if (basetype != LY_TYPE_BOOL && basetype != LY_TYPE_EMPTY) {
+    } else if ((basetype != LY_TYPE_BOOL) && (basetype != LY_TYPE_EMPTY)) {
         /* no specific restriction in leaf's type definition, copy from the base */
         free(*type);
         (*type) = base;
@@ -3184,11 +3187,11 @@
         if ((parent_flags & LYS_STATUS_MASK) > ((*node_flags) & LYS_STATUS_MASK)) {
             if ((*node_flags) & LYS_STATUS_CURR) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                       "A \"current\" status is in conflict with the parent's \"%s\" status.",
+                        "A \"current\" status is in conflict with the parent's \"%s\" status.",
                         (parent_flags & LYS_STATUS_DEPRC) ? "deprecated" : "obsolete");
             } else { /* LYS_STATUS_DEPRC */
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                       "A \"deprecated\" status is in conflict with the parent's \"obsolete\" status.");
+                        "A \"deprecated\" status is in conflict with the parent's \"obsolete\" status.");
             }
             return LY_EVALID;
         }
@@ -3339,8 +3342,8 @@
 
     if (ctx->options & (LYSC_OPT_RPC_MASK | LYSC_OPT_NOTIFICATION)) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-               "Action \"%s\" is placed inside %s.", action_p->name,
-               ctx->options & LYSC_OPT_RPC_MASK ? "another RPC/action" : "notification");
+                "Action \"%s\" is placed inside %s.", action_p->name,
+                ctx->options & LYSC_OPT_RPC_MASK ? "another RPC/action" : "notification");
         return LY_EVALID;
     }
 
@@ -3482,8 +3485,8 @@
 
     if (ctx->options & (LYSC_OPT_RPC_MASK | LYSC_OPT_NOTIFICATION)) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-               "Notification \"%s\" is placed inside %s.", notif_p->name,
-               ctx->options & LYSC_OPT_RPC_MASK ? "RPC/action" : "another notification");
+                "Notification \"%s\" is placed inside %s.", notif_p->name,
+                ctx->options & LYSC_OPT_RPC_MASK ? "RPC/action" : "another notification");
         return LY_EVALID;
     }
 
@@ -3559,13 +3562,13 @@
         if (cont_p->parent->nodetype == LYS_CHOICE) {
             /* container is an implicit case, so its existence decides the existence of the whole case */
             LOGWRN(ctx->ctx, "Container \"%s\" changed to presence because it has a meaning as a case of choice \"%s\".",
-                   cont_p->name, cont_p->parent->name);
+                    cont_p->name, cont_p->parent->name);
             cont->flags |= LYS_PRESENCE;
-        } else if ((cont_p->parent->nodetype == LYS_CASE)
-                && (((struct lysp_node_case *)cont_p->parent)->child == pnode) && !cont_p->next) {
+        } else if ((cont_p->parent->nodetype == LYS_CASE) &&
+                (((struct lysp_node_case *)cont_p->parent)->child == pnode) && !cont_p->next) {
             /* container is the only node in a case, so its existence decides the existence of the whole case */
             LOGWRN(ctx->ctx, "Container \"%s\" changed to presence because it has a meaning as a case of choice \"%s\".",
-                   cont_p->name, cont_p->parent->name);
+                    cont_p->name, cont_p->parent->name);
             cont->flags |= LYS_PRESENCE;
         }
     }
@@ -3608,7 +3611,7 @@
     struct lysp_qname *dflt;
 
     LY_CHECK_RET(lys_compile_type(ctx, context_node, leaf->flags, ctx->mod_def->parsed, leaf->name, type_p, &leaf->type,
-                                  leaf->units ? NULL : &leaf->units, &dflt));
+            leaf->units ? NULL : &leaf->units, &dflt));
 
     /* store default value, if any */
     if (dflt && !(leaf->flags & LYS_SET_DFLT)) {
@@ -3627,9 +3630,9 @@
             }
         }
     } else if (leaf->type->basetype == LY_TYPE_EMPTY) {
-        if (leaf->nodetype == LYS_LEAFLIST && ctx->mod_def->version < LYS_VERSION_1_1) {
+        if ((leaf->nodetype == LYS_LEAFLIST) && (ctx->mod_def->version < LYS_VERSION_1_1)) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                   "Leaf-list of type \"empty\" is allowed only in YANG 1.1 modules.");
+                    "Leaf-list of type \"empty\" is allowed only in YANG 1.1 modules.");
             return LY_EVALID;
         }
     }
@@ -3720,7 +3723,7 @@
     if (llist_p->dflts) {
         if (ctx->mod_def->version < LYS_VERSION_1_1) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                   "Leaf-list default values are allowed only in YANG 1.1 modules.");
+                    "Leaf-list default values are allowed only in YANG 1.1 modules.");
             return LY_EVALID;
         }
 
@@ -3743,7 +3746,7 @@
 
     if (llist->min > llist->max) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS, "Leaf-list min-elements %u is bigger than max-elements %u.",
-               llist->min, llist->max);
+                llist->min, llist->max);
         return LY_EVALID;
     }
 
@@ -3788,25 +3791,25 @@
             /* unique node must be present */
             LY_ARRAY_NEW_RET(ctx->ctx, *unique, key, LY_EMEM);
             ret = lysc_resolve_schema_nodeid(ctx, keystr, len, (struct lysc_node *)list, uniques[v].mod, LYS_LEAF,
-                            (const struct lysc_node **)key, &flags);
+                    (const struct lysc_node **)key, &flags);
             if (ret != LY_SUCCESS) {
                 if (ret == LY_EDENIED) {
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                           "Unique's descendant-schema-nodeid \"%.*s\" refers to %s node instead of a leaf.",
-                           len, keystr, lys_nodetype2str((*key)->nodetype));
+                            "Unique's descendant-schema-nodeid \"%.*s\" refers to %s node instead of a leaf.",
+                            len, keystr, lys_nodetype2str((*key)->nodetype));
                 }
                 return LY_EVALID;
             } else if (flags) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                       "Unique's descendant-schema-nodeid \"%.*s\" refers into %s node.",
-                       len, keystr, flags & LYSC_OPT_NOTIFICATION ? "notification" : "RPC/action");
+                        "Unique's descendant-schema-nodeid \"%.*s\" refers into %s node.",
+                        len, keystr, flags & LYSC_OPT_NOTIFICATION ? "notification" : "RPC/action");
                 return LY_EVALID;
             }
 
             /* all referenced leafs must be of the same config type */
-            if (config != -1 && ((((*key)->flags & LYS_CONFIG_W) && config == 0) || (((*key)->flags & LYS_CONFIG_R) && config == 1))) {
+            if ((config != -1) && ((((*key)->flags & LYS_CONFIG_W) && (config == 0)) || (((*key)->flags & LYS_CONFIG_R) && (config == 1)))) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                       "Unique statement \"%s\" refers to leaves with different config type.", uniques[v].str);
+                        "Unique statement \"%s\" refers to leaves with different config type.", uniques[v].str);
                 return LY_EVALID;
             } else if ((*key)->flags & LYS_CONFIG_W) {
                 config = 1;
@@ -3818,7 +3821,7 @@
             for (parent = (*key)->parent; parent != (struct lysc_node *)list; parent = parent->parent) {
                 if (parent->nodetype == LYS_LIST) {
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                       "Unique statement \"%s\" refers to a leaf in nested list \"%s\".", uniques[v].str, parent->name);
+                            "Unique statement \"%s\" refers to a leaf in nested list \"%s\".", uniques[v].str, parent->name);
                     return LY_EVALID;
                 }
             }
@@ -3902,14 +3905,14 @@
         key = (struct lysc_node_leaf *)lys_find_child(node, node->module, keystr, len, LYS_LEAF, LYS_GETNEXT_NOCHOICE | LYS_GETNEXT_NOSTATECHECK);
         if (!(key)) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                   "The list's key \"%.*s\" not found.", len, keystr);
+                    "The list's key \"%.*s\" not found.", len, keystr);
             return LY_EVALID;
         }
         /* keys must be unique */
         if (key->flags & LYS_KEY) {
             /* the node was already marked as a key */
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                   "Duplicated key identifier \"%.*s\".", len, keystr);
+                    "Duplicated key identifier \"%.*s\".", len, keystr);
             return LY_EVALID;
         }
 
@@ -3923,26 +3926,26 @@
             /* YANG 1.0 denies key to be of empty type */
             if (key->type->basetype == LY_TYPE_EMPTY) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                       "List's key cannot be of \"empty\" type until it is in YANG 1.1 module.");
+                        "List's key cannot be of \"empty\" type until it is in YANG 1.1 module.");
                 return LY_EVALID;
             }
         } else {
             /* when and if-feature are illegal on list keys */
             if (key->when) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                       "List's key must not have any \"when\" statement.");
+                        "List's key must not have any \"when\" statement.");
                 return LY_EVALID;
             }
             if (key->iffeatures) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                       "List's key must not have any \"if-feature\" statement.");
+                        "List's key must not have any \"if-feature\" statement.");
                 return LY_EVALID;
             }
         }
 
         /* check status */
         LY_CHECK_RET(lysc_check_status(ctx, list->flags, list->module, list->name,
-                                       key->flags, key->module, key->name));
+                key->flags, key->module, key->name));
 
         /* ignore default values of the key */
         if (key->dflt) {
@@ -3955,7 +3958,7 @@
         key->flags |= LYS_KEY;
 
         /* move it to the correct position */
-        if ((prev_key && (struct lysc_node *)prev_key != key->prev) || (!prev_key && key->prev->next)) {
+        if ((prev_key && ((struct lysc_node *)prev_key != key->prev)) || (!prev_key && key->prev->next)) {
             /* fix links in closest previous siblings of the key */
             if (key->next) {
                 key->next->prev = key->prev;
@@ -4008,7 +4011,7 @@
     /* checks */
     if (list->min > list->max) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS, "List min-elements %u is bigger than max-elements %u.",
-               list->min, list->max);
+                list->min, list->max);
         return LY_EVALID;
     }
 
@@ -4057,7 +4060,7 @@
     ch->dflt = (struct lysc_node_case *)lys_find_child(node, mod, name, 0, LYS_CASE, LYS_GETNEXT_NOSTATECHECK | LYS_GETNEXT_WITHCASE);
     if (!ch->dflt) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-               "Default case \"%s\" not found.", dflt->str);
+                "Default case \"%s\" not found.", dflt->str);
         return LY_EVALID;
     }
 
@@ -4068,7 +4071,7 @@
         }
         if (iter->flags & LYS_MAND_TRUE) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                   "Mandatory node \"%s\" under the default case \"%s\".", iter->name, dflt->str);
+                    "Mandatory node \"%s\" under the default case \"%s\".", iter->name, dflt->str);
             return LY_EVALID;
         }
     }
@@ -4180,7 +4183,7 @@
 
     if (any->flags & LYS_CONFIG_W) {
         LOGWRN(ctx->ctx, "Use of %s to define configuration data is not recommended. %s",
-               ly_stmt2str(any->nodetype == LYS_ANYDATA ? LY_STMT_ANYDATA : LY_STMT_ANYXML), ctx->path);
+                ly_stmt2str(any->nodetype == LYS_ANYDATA ? LY_STMT_ANYDATA : LY_STMT_ANYXML), ctx->path);
     }
 done:
     return ret;
@@ -4245,8 +4248,8 @@
                 /* check that we have not found the last augment node from our module or
                  * the first augment node from a "smaller" module or
                  * the first node from a local module */
-                if ((anchor->module == node->module) || (strcmp(anchor->module->name, node->module->name) < 0)
-                        || (anchor->module == parent->module)) {
+                if ((anchor->module == node->module) || (strcmp(anchor->module->name, node->module->name) < 0) ||
+                        (anchor->module == parent->module)) {
                     /* insert after */
                     insert_after = 1;
                     break;
@@ -4412,19 +4415,19 @@
      * - new cases augmenting some choice can have mandatory nodes
      * - mandatory nodes are allowed only in case the augmentation is made conditional with a when statement
      */
-    if (aug_p->when || target->nodetype == LYS_CHOICE || ctx->mod == target->module) {
+    if (aug_p->when || (target->nodetype == LYS_CHOICE) || (ctx->mod == target->module)) {
         allow_mandatory = 1;
     }
 
     when_shared = NULL;
     LY_LIST_FOR(aug_p->child, pnode) {
         /* check if the subnode can be connected to the found target (e.g. case cannot be inserted into container) */
-        if ((pnode->nodetype == LYS_CASE && target->nodetype != LYS_CHOICE)
-                || ((pnode->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)) && !(target->nodetype & (LYS_CONTAINER | LYS_LIST)))
-                || (pnode->nodetype == LYS_USES && target->nodetype == LYS_CHOICE)) {
+        if (((pnode->nodetype == LYS_CASE) && (target->nodetype != LYS_CHOICE)) ||
+                ((pnode->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)) && !(target->nodetype & (LYS_CONTAINER | LYS_LIST))) ||
+                ((pnode->nodetype == LYS_USES) && (target->nodetype == LYS_CHOICE))) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                   "Invalid augment of %s node which is not allowed to contain %s node \"%s\".",
-                   lys_nodetype2str(target->nodetype), lys_nodetype2str(pnode->nodetype), pnode->name);
+                    "Invalid augment of %s node which is not allowed to contain %s node \"%s\".",
+                    lys_nodetype2str(target->nodetype), lys_nodetype2str(pnode->nodetype), pnode->name);
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -4444,7 +4447,7 @@
                 node->flags &= ~LYS_MAND_TRUE;
                 lys_compile_mandatory_parents(target, 0);
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                    "Invalid augment adding mandatory node \"%s\" without making it conditional via when statement.", node->name);
+                        "Invalid augment adding mandatory node \"%s\" without making it conditional via when statement.", node->name);
                 ret = LY_EVALID;
                 goto cleanup;
             }
@@ -4478,28 +4481,28 @@
     switch (target->nodetype) {
     case LYS_CONTAINER:
         COMPILE_OP_ARRAY_GOTO(ctx, aug_p->actions, ((struct lysc_node_container *)target)->actions, target,
-                            u, lys_compile_action, 0, ret, cleanup);
+                u, lys_compile_action, 0, ret, cleanup);
         COMPILE_OP_ARRAY_GOTO(ctx, aug_p->notifs, ((struct lysc_node_container *)target)->notifs, target,
-                            u, lys_compile_notif, 0, ret, cleanup);
+                u, lys_compile_notif, 0, ret, cleanup);
         break;
     case LYS_LIST:
         COMPILE_OP_ARRAY_GOTO(ctx, aug_p->actions, ((struct lysc_node_list *)target)->actions, target,
-                            u, lys_compile_action, 0, ret, cleanup);
+                u, lys_compile_action, 0, ret, cleanup);
         COMPILE_OP_ARRAY_GOTO(ctx, aug_p->notifs, ((struct lysc_node_list *)target)->notifs, target,
-                            u, lys_compile_notif, 0, ret, cleanup);
+                u, lys_compile_notif, 0, ret, cleanup);
         break;
     default:
         if (aug_p->actions) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                   "Invalid augment of %s node which is not allowed to contain RPC/action node \"%s\".",
-                   lys_nodetype2str(target->nodetype), aug_p->actions[0].name);
+                    "Invalid augment of %s node which is not allowed to contain RPC/action node \"%s\".",
+                    lys_nodetype2str(target->nodetype), aug_p->actions[0].name);
             ret = LY_EVALID;
             goto cleanup;
         }
         if (aug_p->notifs) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                   "Invalid augment of %s node which is not allowed to contain notification node \"%s\".",
-                   lys_nodetype2str(target->nodetype), aug_p->notifs[0].name);
+                    "Invalid augment of %s node which is not allowed to contain notification node \"%s\".",
+                    lys_nodetype2str(target->nodetype), aug_p->notifs[0].name);
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -4541,7 +4544,7 @@
         mod = lys_module_find_prefix(ctx->mod_def, prefix, prefix_len);
         if (!mod) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                   "Invalid prefix used for grouping reference.", uses_p->name);
+                    "Invalid prefix used for grouping reference.", uses_p->name);
             return LY_EVALID;
         }
     } else {
@@ -4588,7 +4591,7 @@
     }
     if (!found) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-               "Grouping \"%s\" referenced by a uses statement not found.", uses_p->name);
+                "Grouping \"%s\" referenced by a uses statement not found.", uses_p->name);
         return LY_EVALID;
     }
 
@@ -4857,7 +4860,7 @@
     if (grp_stack_count == ctx->groupings.count) {
         /* the target grouping is already in the stack, so we are already inside it -> circular dependency */
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-               "Grouping \"%s\" references itself through a uses statement.", grp->name);
+                "Grouping \"%s\" references itself through a uses statement.", grp->name);
         return LY_EVALID;
     }
 
@@ -4920,8 +4923,8 @@
         actions = parent ? lysc_node_actions_p(parent) : &ctx->mod->compiled->rpcs;
         if (!actions) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE, "Invalid child %s \"%s\" of uses parent %s \"%s\" node.",
-                   grp->actions[0].name, lys_nodetype2str(grp->actions[0].nodetype), parent->name,
-                   lys_nodetype2str(parent->nodetype));
+                    grp->actions[0].name, lys_nodetype2str(grp->actions[0].nodetype), parent->name,
+                    lys_nodetype2str(parent->nodetype));
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -4933,8 +4936,8 @@
         notifs = parent ? lysc_node_notifs_p(parent) : &ctx->mod->compiled->notifs;
         if (!notifs) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE, "Invalid child %s \"%s\" of uses parent %s \"%s\" node.",
-                   grp->notifs[0].name, lys_nodetype2str(grp->notifs[0].nodetype), parent->name,
-                   lys_nodetype2str(parent->nodetype));
+                    grp->notifs[0].name, lys_nodetype2str(grp->notifs[0].nodetype), parent->name,
+                    lys_nodetype2str(parent->nodetype));
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -4944,7 +4947,7 @@
     /* check that all augments were applied */
     for (i = 0; i < ctx->uses_augs.count; ++i) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-               "Augment target node \"%s\" in grouping \"%s\" was not found.",
+                "Augment target node \"%s\" in grouping \"%s\" was not found.",
                 ((struct lysc_augment *)ctx->uses_augs.objs[i])->nodeid->expr, grp->name);
         ret = LY_ENOTFOUND;
     }
@@ -4953,7 +4956,7 @@
     /* check that all refines were applied */
     for (i = 0; i < ctx->uses_rfns.count; ++i) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-               "Refine(s) target node \"%s\" in grouping \"%s\" was not found.",
+                "Refine(s) target node \"%s\" in grouping \"%s\" was not found.",
                 ((struct lysc_refine *)ctx->uses_rfns.objs[i])->nodeid->expr, grp->name);
         ret = LY_ENOTFOUND;
     }
@@ -5124,7 +5127,7 @@
 
     if (parent && (parent->flags & LYS_CONFIG_R) && (node->flags & LYS_CONFIG_W)) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-               "Configuration node cannot be child of any state data node.");
+                "Configuration node cannot be child of any state data node.");
         return LY_EVALID;
     }
 
@@ -6979,6 +6982,7 @@
     struct lysp_node *dev_pnode = NULL, *orig_pnode = pnode;
     LY_ARRAY_COUNT_TYPE u;
     ly_bool not_supported;
+
     LY_ERR (*node_compile_spec)(struct lysc_ctx *, struct lysp_node *, struct lysc_node *);
 
     if (pnode->nodetype != LYS_USES) {
@@ -7340,7 +7344,7 @@
         }
         if (!substmts[u].stmt) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid keyword \"%s\" as a child of \"%s%s%s\" extension instance.",
-                   stmt->stmt, ext->name, ext->argument ? " " : "", ext->argument ? ext->argument : "");
+                    stmt->stmt, ext->name, ext->argument ? " " : "", ext->argument ? ext->argument : "");
             goto cleanup;
         }
     }
@@ -7403,8 +7407,8 @@
 
                     LY_CHECK_ERR_GOTO(r = lysp_stmt_parse(ctx, stmt, stmt->kw, &parsed, NULL), ret = r, cleanup);
                     LY_CHECK_ERR_GOTO(r = lys_compile_type(ctx, ext->parent_type == LYEXT_PAR_NODE ? ((struct lysc_node *)ext->parent)->sp : NULL,
-                                      flags ? *flags : 0, ctx->mod_def->parsed, ext->name, parsed, (struct lysc_type **)compiled,
-                                      units && !*units ? units : NULL, NULL), lysp_type_free(ctx->ctx, parsed); free(parsed); ret = r, cleanup);
+                            flags ? *flags : 0, ctx->mod_def->parsed, ext->name, parsed, (struct lysc_type **)compiled,
+                            units && !*units ? units : NULL, NULL), lysp_type_free(ctx->ctx, parsed); free(parsed); ret = r, cleanup);
                     lysp_type_free(ctx->ctx, parsed);
                     free(parsed);
                     break;
@@ -7433,15 +7437,15 @@
                  * also note that in many statements their extensions are not taken into account  */
                 default:
                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Statement \"%s\" is not supported as an extension (found in \"%s%s%s\") substatement.",
-                           stmt->stmt, ext->name, ext->argument ? " " : "", ext->argument ? ext->argument : "");
+                            stmt->stmt, ext->name, ext->argument ? " " : "", ext->argument ? ext->argument : "");
                     goto cleanup;
                 }
             }
         }
 
-        if ((substmts[u].cardinality == LY_STMT_CARD_MAND || substmts[u].cardinality == LY_STMT_CARD_SOME) && !stmt_present) {
+        if (((substmts[u].cardinality == LY_STMT_CARD_MAND) || (substmts[u].cardinality == LY_STMT_CARD_SOME)) && !stmt_present) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Missing mandatory keyword \"%s\" as a child of \"%s%s%s\".",
-                   ly_stmt2str(substmts[u].stmt), ext->name, ext->argument ? " " : "", ext->argument ? ext->argument : "");
+                    ly_stmt2str(substmts[u].stmt), ext->name, ext->argument ? " " : "", ext->argument ? ext->argument : "");
             goto cleanup;
         }
     }
@@ -7488,8 +7492,8 @@
             continue;
         }
 
-        if ((xp_scnode->type != LYXP_NODE_ELEM) || (xp_scnode->scnode->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF))
-                || !xp_scnode->scnode->when) {
+        if ((xp_scnode->type != LYXP_NODE_ELEM) || (xp_scnode->scnode->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)) ||
+                !xp_scnode->scnode->when) {
             /* no when to check */
             xp_scnode->in_ctx = 0;
             continue;
@@ -7500,7 +7504,7 @@
             LY_ARRAY_FOR(node->when, u) {
                 when = node->when[u];
                 ret = lyxp_atomize(when->cond, LY_PREF_SCHEMA, when->module, when->context,
-                                when->context ? LYXP_NODE_ELEM : LYXP_NODE_ROOT_CONFIG, &tmp_set, LYXP_SCNODE_SCHEMA);
+                        when->context ? LYXP_NODE_ELEM : LYXP_NODE_ROOT_CONFIG, &tmp_set, LYXP_SCNODE_SCHEMA);
                 if (ret != LY_SUCCESS) {
                     LOGVAL(set->ctx, LY_VLOG_LYSC, node, LYVE_SEMANTICS, "Invalid when condition \"%s\".", when->cond->expr);
                     goto cleanup;
@@ -7616,7 +7620,7 @@
     /* check "when" */
     LY_ARRAY_FOR(when, u) {
         ret = lyxp_atomize(when[u]->cond, LY_PREF_SCHEMA, when[u]->module, when[u]->context ? when[u]->context : node,
-                           when[u]->context ? LYXP_NODE_ELEM : LYXP_NODE_ROOT_CONFIG, &tmp_set, opts);
+                when[u]->context ? LYXP_NODE_ELEM : LYXP_NODE_ROOT_CONFIG, &tmp_set, opts);
         if (ret != LY_SUCCESS) {
             LOGVAL(ctx->ctx, LY_VLOG_LYSC, node, LYVE_SEMANTICS, "Invalid when condition \"%s\".", when[u]->cond->expr);
             goto cleanup;
@@ -7631,7 +7635,7 @@
 
                 /* XPath expression cannot reference "lower" status than the node that has the definition */
                 ret = lysc_check_status(ctx, when[u]->flags, when[u]->module, node->name, schema->flags, schema->module,
-                                        schema->name);
+                        schema->name);
                 LY_CHECK_GOTO(ret, cleanup);
 
                 /* check dummy node accessing */
@@ -7666,7 +7670,7 @@
             if (tmp_set.val.scnodes[i].type == LYXP_NODE_ELEM) {
                 /* XPath expression cannot reference "lower" status than the node that has the definition */
                 ret = lysc_check_status(ctx, node->flags, musts[u].module, node->name, tmp_set.val.scnodes[i].scnode->flags,
-                                        tmp_set.val.scnodes[i].scnode->module, tmp_set.val.scnodes[i].scnode->name);
+                        tmp_set.val.scnodes[i].scnode->module, tmp_set.val.scnodes[i].scnode->name);
                 LY_CHECK_GOTO(ret, cleanup);
             }
         }
@@ -7706,8 +7710,8 @@
 
     /* try to find the target */
     LY_CHECK_RET(ly_path_compile(ctx->ctx, node->module, node, lref->path, LY_PATH_LREF_TRUE,
-                                 lysc_is_output(node) ? LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT, LY_PATH_TARGET_MANY,
-                                 LY_PREF_SCHEMA, (void *)lref->path_mod, &p));
+            lysc_is_output(node) ? LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT, LY_PATH_TARGET_MANY,
+            LY_PREF_SCHEMA, (void *)lref->path_mod, &p));
 
     /* get the target node */
     target = p[LY_ARRAY_COUNT(p) - 1].node;
@@ -7715,8 +7719,8 @@
 
     if (!(target->nodetype & (LYS_LEAF | LYS_LEAFLIST))) {
         LOGVAL(ctx->ctx, LY_VLOG_LYSC, node, LYVE_REFERENCE,
-               "Invalid leafref path \"%s\" - target node is %s instead of leaf or leaf-list.",
-               lref->path->expr, lys_nodetype2str(target->nodetype));
+                "Invalid leafref path \"%s\" - target node is %s instead of leaf or leaf-list.",
+                lref->path->expr, lys_nodetype2str(target->nodetype));
         return LY_EVALID;
     }
 
@@ -7735,7 +7739,7 @@
         for (siter = node->parent; siter && !(siter->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)); siter = siter->parent) {}
         if (!siter && (node->flags & LYS_CONFIG_W) && (target->flags & LYS_CONFIG_R)) {
             LOGVAL(ctx->ctx, LY_VLOG_LYSC, node, LYVE_REFERENCE, "Invalid leafref path \"%s\" - target is supposed"
-                   " to represent configuration data (as the leafref does), but it does not.", lref->path->expr);
+                    " to represent configuration data (as the leafref does), but it does not.", lref->path->expr);
             return LY_EVALID;
         }
     }
@@ -7746,7 +7750,7 @@
         if (type == (struct lysc_type *)lref) {
             /* circular chain detected */
             LOGVAL(ctx->ctx, LY_VLOG_LYSC, node, LYVE_REFERENCE,
-                   "Invalid leafref path \"%s\" - circular chain of leafrefs detected.", lref->path->expr);
+                    "Invalid leafref path \"%s\" - circular chain of leafrefs detected.", lref->path->expr);
             return LY_EVALID;
         }
     }
@@ -7754,8 +7758,8 @@
     /* check if leafref and its target are under common if-features */
     if (lys_compile_leafref_features_validate(node, target)) {
         LOGVAL(ctx->ctx, LY_VLOG_LYSC, node, LYVE_REFERENCE,
-               "Invalid leafref path \"%s\" - set of features applicable to the leafref target is not a subset of"
-               " features applicable to the leafref itself.", lref->path->expr);
+                "Invalid leafref path \"%s\" - set of features applicable to the leafref target is not a subset of"
+                " features applicable to the leafref itself.", lref->path->expr);
         return LY_EVALID;
     }
 
@@ -7819,7 +7823,7 @@
     struct ly_err_item *err = NULL;
 
     ret = type->plugin->store(ctx->ctx, type, dflt, strlen(dflt), 0, LY_PREF_SCHEMA, (void *)dflt_mod, LYD_HINT_SCHEMA,
-                              node, storage, &err);
+            node, storage, &err);
     if (ret == LY_EINCOMPLETE) {
         /* we have no data so we will not be resolving it */
         ret = LY_SUCCESS;
@@ -7830,11 +7834,11 @@
         lysc_path(node, LYSC_PATH_LOG, ctx->path, LYSC_CTX_BUFSIZE);
         if (err) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                "Invalid default - value does not fit the type (%s).", err->msg);
+                    "Invalid default - value does not fit the type (%s).", err->msg);
             ly_err_free(err);
         } else {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                "Invalid default - value does not fit the type.");
+                    "Invalid default - value does not fit the type.");
         }
         return ret;
     }
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
index 776d18a..81693ec 100644
--- a/src/tree_schema_free.c
+++ b/src/tree_schema_free.c
@@ -14,8 +14,8 @@
 
 #include <stdlib.h>
 
-#include "compat.h"
 #include "common.h"
+#include "compat.h"
 #include "plugins_exts.h"
 #include "plugins_types.h"
 #include "tree.h"
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index 7b15269..48fc505 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -21,14 +21,14 @@
 #include <string.h>
 #include <time.h>
 
-#include "compat.h"
 #include "common.h"
+#include "compat.h"
 #include "context.h"
 #include "hash_table.h"
 #include "log.h"
 #include "parser.h"
-#include "parser_schema.h"
 #include "parser_internal.h"
+#include "parser_schema.h"
 #include "set.h"
 #include "tree.h"
 #include "tree_schema.h"
@@ -60,8 +60,8 @@
 
         if (*id == '/') {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                   "Invalid descendant-schema-nodeid value \"%.*s\" - absolute-schema-nodeid used.",
-                   nodeid_len ? nodeid_len : strlen(nodeid), nodeid);
+                    "Invalid descendant-schema-nodeid value \"%.*s\" - absolute-schema-nodeid used.",
+                    nodeid_len ? nodeid_len : strlen(nodeid), nodeid);
             return LY_EVALID;
         }
     } else {
@@ -70,8 +70,8 @@
 
         if (*id != '/') {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                   "Invalid absolute-schema-nodeid value \"%.*s\" - missing starting \"/\".",
-                   nodeid_len ? nodeid_len : strlen(nodeid), nodeid);
+                    "Invalid absolute-schema-nodeid value \"%.*s\" - missing starting \"/\".",
+                    nodeid_len ? nodeid_len : strlen(nodeid), nodeid);
             return LY_EVALID;
         }
         ++id;
@@ -82,8 +82,8 @@
             mod = lys_module_find_prefix(context_module, prefix, prefix_len);
             if (!mod) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                       "Invalid %s-schema-nodeid value \"%.*s\" - prefix \"%.*s\" not defined in module \"%s\".",
-                       nodeid_type, id - nodeid, nodeid, prefix_len, prefix, context_module->name);
+                        "Invalid %s-schema-nodeid value \"%.*s\" - prefix \"%.*s\" not defined in module \"%s\".",
+                        nodeid_type, id - nodeid, nodeid, prefix_len, prefix, context_module->name);
                 return LY_ENOTFOUND;
             }
         } else {
@@ -93,7 +93,7 @@
             /* move through input/output manually */
             if (mod != context_node->module) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                       "Invalid %s-schema-nodeid value \"%.*s\" - target node not found.", nodeid_type, id - nodeid, nodeid);
+                        "Invalid %s-schema-nodeid value \"%.*s\" - target node not found.", nodeid_type, id - nodeid, nodeid);
                 return LY_ENOTFOUND;
             }
             if (!ly_strncmp("input", name, name_len)) {
@@ -130,8 +130,8 @@
         }
         if (*id != '/') {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                   "Invalid %s-schema-nodeid value \"%.*s\" - missing \"/\" as node-identifier separator.",
-                   nodeid_type, id - nodeid + 1, nodeid);
+                    "Invalid %s-schema-nodeid value \"%.*s\" - missing \"/\" as node-identifier separator.",
+                    nodeid_type, id - nodeid + 1, nodeid);
             return LY_EVALID;
         }
         ++id;
@@ -144,8 +144,8 @@
         }
     } else {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-               "Invalid %s-schema-nodeid value \"%.*s\" - unexpected end of expression.",
-               nodeid_type, nodeid_len ? nodeid_len : strlen(nodeid), nodeid);
+                "Invalid %s-schema-nodeid value \"%.*s\" - unexpected end of expression.",
+                nodeid_type, nodeid_len ? nodeid_len : strlen(nodeid), nodeid);
     }
 
     return ret;
@@ -156,12 +156,12 @@
 {
     struct lysp_import *i;
 
-    if (module_prefix && &module_prefix != value && !strcmp(module_prefix, *value)) {
+    if (module_prefix && (&module_prefix != value) && !strcmp(module_prefix, *value)) {
         LOGVAL_PARSER(ctx, LYVE_REFERENCE, "Prefix \"%s\" already used as module prefix.", *value);
         return LY_EEXIST;
     }
     LY_ARRAY_FOR(imports, struct lysp_import, i) {
-        if (i->prefix && &i->prefix != value && !strcmp(i->prefix, *value)) {
+        if (i->prefix && (&i->prefix != value) && !strcmp(i->prefix, *value)) {
             LOGVAL_PARSER(ctx, LYVE_REFERENCE, "Prefix \"%s\" already used to import \"%s\" module.", *value, i->name);
             return LY_EEXIST;
         }
@@ -182,9 +182,9 @@
     if ((flg1 < flg2) && (mod1 == mod2)) {
         if (ctx) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                   "A %s definition \"%s\" is not allowed to reference %s definition \"%s\".",
-                   flg1 == LYS_STATUS_CURR ? "current" : "deprecated", name1,
-                   flg2 == LYS_STATUS_OBSLT ? "obsolete" : "deprecated", name2);
+                    "A %s definition \"%s\" is not allowed to reference %s definition \"%s\".",
+                    flg1 == LYS_STATUS_CURR ? "current" : "deprecated", name1,
+                    flg2 == LYS_STATUS_OBSLT ? "obsolete" : "deprecated", name2);
         }
         return LY_EVALID;
     }
@@ -203,7 +203,7 @@
 
     /* check format */
     for (uint8_t i = 0; i < date_len; i++) {
-        if (i == 4 || i == 7) {
+        if ((i == 4) || (i == 7)) {
             if (date[i] != '-') {
                 goto error;
             }
@@ -215,7 +215,7 @@
     /* check content, e.g. 2018-02-31 */
     memset(&tm, 0, sizeof tm);
     r = strptime(date, "%Y-%m-%d", &tm);
-    if (!r || r != &date[LY_REV_SIZE - 1]) {
+    if (!r || (r != &date[LY_REV_SIZE - 1])) {
         goto error;
     }
     memcpy(&tm_, &tm, sizeof tm);
@@ -282,27 +282,27 @@
     if (len >= 4) { /* otherwise it does not match any built-in type */
         if (name[0] == 'b') {
             if (name[1] == 'i') {
-                if (len == 6 && !strncmp(&name[2], "nary", 4)) {
+                if ((len == 6) && !strncmp(&name[2], "nary", 4)) {
                     return LY_TYPE_BINARY;
-                } else if (len == 4 && !strncmp(&name[2], "ts", 2)) {
+                } else if ((len == 4) && !strncmp(&name[2], "ts", 2)) {
                     return LY_TYPE_BITS;
                 }
-            } else if (len == 7 && !strncmp(&name[1], "oolean", 6)) {
+            } else if ((len == 7) && !strncmp(&name[1], "oolean", 6)) {
                 return LY_TYPE_BOOL;
             }
         } else if (name[0] == 'd') {
-            if (len == 9 && !strncmp(&name[1], "ecimal64", 8)) {
+            if ((len == 9) && !strncmp(&name[1], "ecimal64", 8)) {
                 return LY_TYPE_DEC64;
             }
         } else if (name[0] == 'e') {
-            if (len == 5 && !strncmp(&name[1], "mpty", 4)) {
+            if ((len == 5) && !strncmp(&name[1], "mpty", 4)) {
                 return LY_TYPE_EMPTY;
-            } else if (len == 11 && !strncmp(&name[1], "numeration", 10)) {
+            } else if ((len == 11) && !strncmp(&name[1], "numeration", 10)) {
                 return LY_TYPE_ENUM;
             }
         } else if (name[0] == 'i') {
             if (name[1] == 'n') {
-                if (len == 4 && !strncmp(&name[2], "t8", 2)) {
+                if ((len == 4) && !strncmp(&name[2], "t8", 2)) {
                     return LY_TYPE_INT8;
                 } else if (len == 5) {
                     if (!strncmp(&name[2], "t16", 3)) {
@@ -312,27 +312,27 @@
                     } else if (!strncmp(&name[2], "t64", 3)) {
                         return LY_TYPE_INT64;
                     }
-                } else if (len == 19 && !strncmp(&name[2], "stance-identifier", 17)) {
+                } else if ((len == 19) && !strncmp(&name[2], "stance-identifier", 17)) {
                     return LY_TYPE_INST;
                 }
-            } else if (len == 11 && !strncmp(&name[1], "dentityref", 10)) {
+            } else if ((len == 11) && !strncmp(&name[1], "dentityref", 10)) {
                 return LY_TYPE_IDENT;
             }
         } else if (name[0] == 'l') {
-            if (len == 7 && !strncmp(&name[1], "eafref", 6)) {
+            if ((len == 7) && !strncmp(&name[1], "eafref", 6)) {
                 return LY_TYPE_LEAFREF;
             }
         } else if (name[0] == 's') {
-            if (len == 6 && !strncmp(&name[1], "tring", 5)) {
+            if ((len == 6) && !strncmp(&name[1], "tring", 5)) {
                 return LY_TYPE_STRING;
             }
         } else if (name[0] == 'u') {
             if (name[1] == 'n') {
-                if (len == 5 && !strncmp(&name[2], "ion", 3)) {
+                if ((len == 5) && !strncmp(&name[2], "ion", 3)) {
                     return LY_TYPE_UNION;
                 }
-            } else if (name[1] == 'i' && name[2] == 'n' && name[3] == 't') {
-                if (len == 5 && name[4] == '8') {
+            } else if ((name[1] == 'i') && (name[2] == 'n') && (name[3] == 't')) {
+                if ((len == 5) && (name[4] == '8')) {
                     return LY_TYPE_UINT8;
                 } else if (len == 6) {
                     if (!strncmp(&name[4], "16", 2)) {
@@ -385,7 +385,7 @@
     }
     LY_CHECK_RET(!(*module), LY_ENOTFOUND);
 
-    if (start_node && *module == start_module) {
+    if (start_node && (*module == start_module)) {
         /* search typedefs in parent's nodes */
         *node = start_node;
         while (*node) {
@@ -432,13 +432,13 @@
         return LY_EVALID;
     } else if (isspace(name[0]) || isspace(name[name_len - 1])) {
         LOGVAL_PARSER(ctx, LYVE_SYNTAX_YANG, "Enum name must not have any leading or trailing whitespaces (\"%.*s\").",
-                    name_len, name);
+                name_len, name);
         return LY_EVALID;
     } else {
         for (size_t u = 0; u < name_len; ++u) {
             if (iscntrl(name[u])) {
                 LOGWRN(PARSER_CTX(ctx), "Control characters in enum name should be avoided (\"%.*s\", character number %d).",
-                    name_len, name, u + 1);
+                        name_len, name, u + 1);
                 break;
             }
         }
@@ -697,7 +697,7 @@
         /* check revision of the parsed model */
         if (!revs || strcmp(info->revision, revs[0].date)) {
             LOGERR(ctx, LY_EINVAL, "Module \"%s\" parsed with the wrong revision (\"%s\" instead \"%s\").", name,
-                   revs ? revs[0].date : "none", info->revision);
+                    revs ? revs[0].date : "none", info->revision);
             return LY_EINVAL;
         }
     } else if (!latest_revision) {
@@ -710,7 +710,7 @@
         /* check that the submodule belongs-to our module */
         if (strcmp(info->submoduleof, submod->mod->name)) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_REFERENCE, "Included \"%s\" submodule from \"%s\" belongs-to a different module \"%s\".",
-                   submod->name, info->submoduleof, submod->mod->name);
+                    submod->name, info->submoduleof, submod->mod->name);
             return LY_EVALID;
         }
         /* check circular dependency */
@@ -732,15 +732,15 @@
         rev = strchr(filename, '@');
         dot = strrchr(info->path, '.');
         if (strncmp(filename, name, len) ||
-                ((rev && rev != &filename[len]) || (!rev && dot != &filename[len]))) {
+                ((rev && (rev != &filename[len])) || (!rev && (dot != &filename[len])))) {
             LOGWRN(ctx, "File name \"%s\" does not match module name \"%s\".", filename, name);
         }
         /* revision */
         if (rev) {
             len = dot - ++rev;
-            if (!revs || len != 10 || strncmp(revs[0].date, rev, len)) {
+            if (!revs || (len != 10) || strncmp(revs[0].date, rev, len)) {
                 LOGWRN(ctx, "File name \"%s\" does not match module revision \"%s\".", filename,
-                       revs ? revs[0].date : "none");
+                        revs ? revs[0].date : "none");
             }
         }
     }
@@ -759,11 +759,11 @@
     struct lysp_load_module_check_data check_data = {0};
 
     LY_CHECK_RET(lys_search_localfile(ly_ctx_get_searchdirs(ctx), !(ctx->flags & LY_CTX_DISABLE_SEARCHDIR_CWD), name, revision,
-                                      &filepath, &format));
+            &filepath, &format));
     if (!filepath) {
         if (required) {
             LOGERR(ctx, LY_ENOTFOUND, "Data model \"%s%s%s\" not found in local searchdirs.", name, revision ? "@" : "",
-                   revision ? revision : "");
+                    revision ? revision : "");
         }
         return LY_ENOTFOUND;
     }
@@ -772,17 +772,17 @@
 
     /* get the (sub)module */
     LY_CHECK_ERR_GOTO(ret = ly_in_new_filepath(filepath, 0, &in),
-                      LOGERR(ctx, ret, "Unable to create input handler for filepath %s.", filepath), cleanup);
+            LOGERR(ctx, ret, "Unable to create input handler for filepath %s.", filepath), cleanup);
     check_data.name = name;
     check_data.revision = revision;
     check_data.path = filepath;
     check_data.submoduleof = main_name;
     if (main_ctx) {
         ret = lys_parse_submodule(ctx, in, format, main_ctx, lysp_load_module_check, &check_data,
-                        (struct lysp_submodule **)&mod);
+                (struct lysp_submodule **)&mod);
     } else {
         ret = lys_create_module(ctx, in, format, implement, lysp_load_module_check, &check_data,
-                        (struct lys_module **)&mod);
+                (struct lys_module **)&mod);
 
     }
     ly_in_free(in, 1);
@@ -803,6 +803,7 @@
 {
     const char *module_data = NULL;
     LYS_INFORMAT format = LYS_IN_UNKNOWN;
+
     void (*module_data_free)(void *module_data, void *user_data) = NULL;
     struct lysp_load_module_check_data check_data = {0};
     struct lys_module *m = NULL;
@@ -830,7 +831,7 @@
             /* get the requested module of the latest revision in the context */
 latest_in_the_context:
             *mod = (struct lys_module *)ly_ctx_get_module_latest(ctx, name);
-            if (*mod && (*mod)->latest_revision == 1) {
+            if (*mod && ((*mod)->latest_revision == 1)) {
                 /* let us now search with callback and searchpaths to check if there is newer revision outside the context */
                 m = *mod;
                 *mod = NULL;
@@ -844,7 +845,7 @@
         /* check collision with other implemented revision */
         if (implement && ly_ctx_get_module_implemented(ctx, name)) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_REFERENCE,
-                   "Module \"%s\" is already present in other implemented revision.", name);
+                    "Module \"%s\" is already present in other implemented revision.", name);
             return LY_EDENIED;
         }
 
@@ -853,7 +854,7 @@
 search_clb:
             if (ctx->imp_clb) {
                 if (ctx->imp_clb(name, revision, NULL, NULL, ctx->imp_clb_data,
-                                      &format, &module_data, &module_data_free) == LY_SUCCESS) {
+                        &format, &module_data, &module_data_free) == LY_SUCCESS) {
                     LY_CHECK_RET(ly_in_new_memory(module_data, &in));
                     check_data.name = name;
                     check_data.revision = revision;
@@ -891,10 +892,10 @@
         /* we have module from the current context */
         if (implement) {
             m = ly_ctx_get_module_implemented(ctx, name);
-            if (m && m != *mod) {
+            if (m && (m != *mod)) {
                 /* check collision with other implemented revision */
                 LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_REFERENCE,
-                       "Module \"%s\" is already present in other implemented revision.", name);
+                        "Module \"%s\" is already present in other implemented revision.", name);
                 *mod = NULL;
                 return LY_EDENIED;
             }
@@ -933,7 +934,7 @@
 LY_ERR
 lysp_check_identifierchar(struct lys_parser_ctx *ctx, uint32_t c, ly_bool first, uint8_t *prefix)
 {
-    if (first || (prefix && (*prefix) == 1)) {
+    if (first || (prefix && ((*prefix) == 1))) {
         if (!is_yangidentstartchar(c)) {
             LOGVAL_PARSER(ctx, LYVE_SYNTAX_YANG, "Invalid identifier first character '%c' (0x%04x).", (char)c, c);
             return LY_EVALID;
@@ -945,7 +946,7 @@
                 (*prefix) = 2;
             }
         }
-    } else if (c == ':' && prefix && (*prefix) == 0) {
+    } else if ((c == ':') && prefix && ((*prefix) == 0)) {
         (*prefix) = 1;
     } else if (!is_yangidentchar(c)) {
         LOGVAL_PARSER(ctx, LYVE_SYNTAX_YANG, "Invalid identifier character '%c' (0x%04x).", (char)c, c);
@@ -962,6 +963,7 @@
     struct lysp_submodule *submod = NULL;
     const char *submodule_data = NULL;
     LYS_INFORMAT format = LYS_IN_UNKNOWN;
+
     void (*submodule_data_free)(void *module_data, void *user_data) = NULL;
     struct lysp_load_module_check_data check_data = {0};
     struct ly_in *in;
@@ -971,7 +973,7 @@
 search_clb:
         if (ctx->imp_clb) {
             if (ctx->imp_clb(pctx->main_mod->name, NULL, inc->name, inc->rev[0] ? inc->rev : NULL, ctx->imp_clb_data,
-                                  &format, &submodule_data, &submodule_data_free) == LY_SUCCESS) {
+                    &format, &submodule_data, &submodule_data_free) == LY_SUCCESS) {
                 LY_CHECK_RET(ly_in_new_memory(submodule_data, &in));
                 check_data.name = inc->name;
                 check_data.revision = inc->rev[0] ? inc->rev : NULL;
@@ -1008,7 +1010,7 @@
     }
     if (!inc->submodule) {
         LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_REFERENCE, "Including \"%s\" submodule into \"%s\" failed.",
-               inc->name, pctx->main_mod->name);
+                inc->name, pctx->main_mod->name);
         return LY_EVALID;
     }
 
@@ -1212,6 +1214,7 @@
 lysp_node_actions(const struct lysp_node *node)
 {
     struct lysp_action **actions;
+
     actions = lysp_node_actions_p((struct lysp_node *)node);
     if (actions) {
         return *actions;
@@ -1242,6 +1245,7 @@
 lysp_node_notifs(const struct lysp_node *node)
 {
     struct lysp_notif **notifs;
+
     notifs = lysp_node_notifs_p((struct lysp_node *)node);
     if (notifs) {
         return *notifs;
@@ -1312,6 +1316,7 @@
 lysc_node_actions(const struct lysc_node *node)
 {
     struct lysc_action **actions;
+
     actions = lysc_node_actions_p((struct lysc_node *)node);
     if (actions) {
         return *actions;
@@ -1338,6 +1343,7 @@
 lysc_node_notifs(const struct lysc_node *node)
 {
     struct lysc_notif **notifs;
+
     notifs = lysc_node_notifs_p((struct lysc_node *)node);
     if (notifs) {
         return *notifs;
@@ -1399,7 +1405,7 @@
 {
     for (uint32_t u = 0; u < ctx->list.count; ++u) {
         if (((struct lys_module *)ctx->list.objs[u])->parsed == mod) {
-            return ((struct lys_module *)ctx->list.objs[u]);
+            return (struct lys_module *)ctx->list.objs[u];
         }
     }
     return NULL;
diff --git a/src/tree_schema_internal.h b/src/tree_schema_internal.h
index 5d9bb9c..420d96e 100644
--- a/src/tree_schema_internal.h
+++ b/src/tree_schema_internal.h
@@ -297,8 +297,7 @@
  * @param[in] mod Parsed module to be updated.
  * @return LY_ERR value (currently only LY_SUCCESS, but it can change in future).
  */
-LY_ERR
-lysp_parse_finalize_reallocated(struct lys_parser_ctx *ctx, struct lysp_grp *groupings, struct lysp_augment *augments,
+LY_ERR lysp_parse_finalize_reallocated(struct lys_parser_ctx *ctx, struct lysp_grp *groupings, struct lysp_augment *augments,
         struct lysp_action *actions, struct lysp_notif *notifs);
 
 /**
diff --git a/src/validation.c b/src/validation.c
index 4fc7158..c8e3125 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -19,8 +19,8 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "compat.h"
 #include "common.h"
+#include "compat.h"
 #include "diff.h"
 #include "hash_table.h"
 #include "log.h"
@@ -79,7 +79,7 @@
 
     /* evaluate when */
     ret = lyxp_eval(when->cond, LY_PREF_SCHEMA, when->module, ctx_node, ctx_node ? LYXP_NODE_ELEM : LYXP_NODE_ROOT_CONFIG,
-                    *tree, &xp_set, LYXP_SCHEMA);
+            *tree, &xp_set, LYXP_SCHEMA);
     lyxp_set_cast(&xp_set, LYXP_SET_BOOLEAN);
 
     /* return error or LY_EINCOMPLETE for dependant unresolved when */
@@ -641,7 +641,7 @@
                     ++ptr;
                 }
                 ptr = lysc_path_until((struct lysc_node *)slist->uniques[u][v], (struct lysc_node *)slist, LYSC_PATH_LOG,
-                                      ptr, 1024 - (ptr - uniq_str));
+                        ptr, 1024 - (ptr - uniq_str));
                 if (!ptr) {
                     /* path will be incomplete, whatever */
                     break;
@@ -934,7 +934,7 @@
 
         /* evaluate must */
         LY_CHECK_RET(lyxp_eval(musts[u].cond, LY_PREF_SCHEMA, musts[u].module, node, LYXP_NODE_ELEM, tree, &xp_set,
-                               LYXP_SCHEMA));
+                LYXP_SCHEMA));
 
         /* check the result */
         lyxp_set_cast(&xp_set, LYXP_SET_BOOLEAN);
@@ -1055,8 +1055,8 @@
 
                 /* add nested defaults */
                 LY_CHECK_RET(lyd_new_implicit_r(node, lyd_node_children_p((struct lyd_node *)node), NULL, NULL, type_check,
-                                                when_check, val_opts & LYD_VALIDATE_NO_STATE ? LYD_IMPLICIT_NO_STATE : 0,
-                                                diff));
+                        when_check, val_opts & LYD_VALIDATE_NO_STATE ? LYD_IMPLICIT_NO_STATE : 0,
+                        diff));
             }
 
             if (!(node->schema->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)) && node->schema->when) {
@@ -1119,8 +1119,8 @@
         LY_CHECK_GOTO(ret, cleanup);
 
         /* add all top-level defaults for this module */
-        ret = lyd_new_implicit_r(NULL, first2, NULL, mod, &type_check, &when_check, val_opts & LYD_VALIDATE_NO_STATE
-                                 ? LYD_IMPLICIT_NO_STATE : 0, diff);
+        ret = lyd_new_implicit_r(NULL, first2, NULL, mod, &type_check, &when_check, val_opts & LYD_VALIDATE_NO_STATE ?
+                LYD_IMPLICIT_NO_STATE : 0, diff);
         LY_CHECK_GOTO(ret, cleanup);
 
         /* process nested nodes */
@@ -1223,14 +1223,14 @@
 
     /* find the operation/notification */
     LYD_TREE_DFS_BEGIN(op_tree, op_node) {
-        if ((op == LYD_VALIDATE_OP_RPC || op == LYD_VALIDATE_OP_REPLY) && (op_node->schema->nodetype & (LYS_RPC | LYS_ACTION))) {
+        if (((op == LYD_VALIDATE_OP_RPC) || (op == LYD_VALIDATE_OP_REPLY)) && (op_node->schema->nodetype & (LYS_RPC | LYS_ACTION))) {
             break;
         } else if ((op == LYD_VALIDATE_OP_NOTIF) && (op_node->schema->nodetype == LYS_NOTIF)) {
             break;
         }
         LYD_TREE_DFS_END(op_tree, op_node);
     }
-    if (op == LYD_VALIDATE_OP_RPC || op == LYD_VALIDATE_OP_REPLY) {
+    if ((op == LYD_VALIDATE_OP_RPC) || (op == LYD_VALIDATE_OP_REPLY)) {
         if (!(op_node->schema->nodetype & (LYS_RPC | LYS_ACTION))) {
             LOGERR(LYD_CTX(op_tree), LY_EINVAL, "No RPC/action to validate found.");
             return LY_EINVAL;
diff --git a/src/xml.c b/src/xml.c
index 7061538..fbf83a4 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -104,12 +104,12 @@
 
     /* check NameStartChar (minus colon) */
     LY_CHECK_ERR_RET(ly_getutf8(&in, &c, &parsed),
-                     LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LY_VCODE_INCHAR, in[0]),
-                     LY_EVALID);
+            LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LY_VCODE_INCHAR, in[0]),
+            LY_EVALID);
     LY_CHECK_ERR_RET(!is_xmlqnamestartchar(c),
-                     LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX,
-                            "Identifier \"%s\" starts with an invalid character.", in - parsed),
-                     LY_EVALID);
+            LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX,
+            "Identifier \"%s\" starts with an invalid character.", in - parsed),
+            LY_EVALID);
 
     /* check rest of the identifier */
     do {
@@ -243,7 +243,7 @@
             return LY_SUCCESS;
         } else if (xmlctx->in->current[0] != '<') {
             LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LY_VCODE_INSTREXP, LY_VCODE_INSTREXP_len(xmlctx->in->current),
-                   xmlctx->in->current, "element tag start ('<')");
+                    xmlctx->in->current, "element tag start ('<')");
             return LY_EVALID;
         }
         move_input(xmlctx, 1);
@@ -269,7 +269,7 @@
                 return LY_EVALID;
             } else {
                 LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX, "Unknown XML section \"%.20s\".",
-                       &xmlctx->in->current[-2]);
+                        &xmlctx->in->current[-2]);
                 return LY_EVALID;
             }
             rc = ign_todelim(xmlctx->in->current, endtag, endtag_len, &newlines, &parsed);
@@ -407,7 +407,7 @@
                     in += 6; /* &quot; */
                 } else {
                     LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX,
-                           "Entity reference \"%.*s\" not supported, only predefined references allowed.", 10, &in[offset - 1]);
+                            "Entity reference \"%.*s\" not supported, only predefined references allowed.", 10, &in[offset - 1]);
                     goto error;
                 }
                 offset = 0;
@@ -419,7 +419,7 @@
                     for (n = 0; isdigit(in[offset]); offset++) {
                         n = (10 * n) + (in[offset] - '0');
                     }
-                } else if (in[offset] == 'x' && isxdigit(in[offset + 1])) {
+                } else if ((in[offset] == 'x') && isxdigit(in[offset + 1])) {
                     for (n = 0, ++offset; isxdigit(in[offset]); offset++) {
                         if (isdigit(in[offset])) {
                             u = (in[offset] - '0');
@@ -437,14 +437,14 @@
                 }
 
                 LY_CHECK_ERR_GOTO(in[offset] != ';',
-                                  LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LY_VCODE_INSTREXP,
-                                         LY_VCODE_INSTREXP_len(&in[offset]), &in[offset], ";"),
-                                  error);
+                        LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LY_VCODE_INSTREXP,
+                        LY_VCODE_INSTREXP_len(&in[offset]), &in[offset], ";"),
+                        error);
                 ++offset;
                 LY_CHECK_ERR_GOTO(ly_pututf8(&buf[len], n, &u),
-                                  LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX,
-                                         "Invalid character reference \"%.*s\" (0x%08x).", 12, p, n),
-                                  error);
+                        LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX,
+                        "Invalid character reference \"%.*s\" (0x%08x).", 12, p, n),
+                        error);
                 len += u;
                 in += offset;
                 offset = 0;
@@ -525,17 +525,17 @@
     /* match opening and closing element tags */
     if (!xmlctx->elements.count) {
         LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX, "Stray closing element tag (\"%.*s\").",
-               name_len, name);
+                name_len, name);
         return LY_EVALID;
     }
 
     e = (struct lyxml_elem *)xmlctx->elements.objs[xmlctx->elements.count - 1];
-    if ((e->prefix_len != prefix_len) || (e->name_len != name_len)
-            || (prefix_len && strncmp(prefix, e->prefix, e->prefix_len)) || strncmp(name, e->name, e->name_len)) {
+    if ((e->prefix_len != prefix_len) || (e->name_len != name_len) ||
+            (prefix_len && strncmp(prefix, e->prefix, e->prefix_len)) || strncmp(name, e->name, e->name_len)) {
         LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX,
-               "Opening (\"%.*s%s%.*s\") and closing (\"%.*s%s%.*s\") elements tag mismatch.",
-               e->prefix_len, e->prefix ? e->prefix : "", e->prefix ? ":" : "", e->name_len, e->name,
-               prefix_len, prefix ? prefix : "", prefix ? ":" : "", name_len, name);
+                "Opening (\"%.*s%s%.*s\") and closing (\"%.*s%s%.*s\") elements tag mismatch.",
+                e->prefix_len, e->prefix ? e->prefix : "", e->prefix ? ":" : "", e->name_len, e->name,
+                prefix_len, prefix ? prefix : "", prefix ? ":" : "", name_len, name);
         return LY_EVALID;
     }
 
@@ -556,7 +556,7 @@
     /* parse closing tag */
     if (xmlctx->in->current[0] != '>') {
         LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LY_VCODE_INSTREXP, LY_VCODE_INSTREXP_len(xmlctx->in->current),
-               xmlctx->in->current, "element tag termination ('>')");
+                xmlctx->in->current, "element tag termination ('>')");
         return LY_EVALID;
     }
 
@@ -614,7 +614,7 @@
         /* store every namespace */
         if ((prefix && !ly_strncmp("xmlns", prefix, prefix_len)) || (!prefix && !ly_strncmp("xmlns", name, name_len))) {
             LY_CHECK_GOTO(ret = lyxml_ns_add(xmlctx, prefix ? name : NULL, prefix ? name_len : 0,
-                                             dynamic ? value : strndup(value, value_len)), cleanup);
+                    dynamic ? value : strndup(value, value_len)), cleanup);
             dynamic = 0;
         } else {
             /* not a namespace */
@@ -664,7 +664,7 @@
         return LY_EVALID;
     } else if (xmlctx->in->current[0] != '=') {
         LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LY_VCODE_INSTREXP, LY_VCODE_INSTREXP_len(xmlctx->in->current),
-               xmlctx->in->current, "'='");
+                xmlctx->in->current, "'='");
         return LY_EVALID;
     }
     move_input(xmlctx, 1);
@@ -678,7 +678,7 @@
         return LY_EVALID;
     } else if ((xmlctx->in->current[0] != '\'') && (xmlctx->in->current[0] != '\"')) {
         LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LY_VCODE_INSTREXP, LY_VCODE_INSTREXP_len(xmlctx->in->current),
-               xmlctx->in->current, "either single or double quotation mark");
+                xmlctx->in->current, "either single or double quotation mark");
         return LY_EVALID;
     }
 
@@ -725,7 +725,7 @@
             return LY_EVALID;
         } else if ((ly_getutf8(&in, &c, &parsed) || !is_xmlqnamestartchar(c))) {
             LOGVAL(xmlctx->ctx, LY_VLOG_LINE, &xmlctx->line, LY_VCODE_INSTREXP, LY_VCODE_INSTREXP_len(in - parsed), in - parsed,
-                "element tag end ('>' or '/>') or an attribute");
+                    "element tag end ('>' or '/>') or an attribute");
             return LY_EVALID;
         }
 
@@ -806,14 +806,14 @@
 
     /* parse next element, if any */
     LY_CHECK_GOTO(ret = lyxml_next_element(xmlctx, &xmlctx->prefix, &xmlctx->prefix_len, &xmlctx->name,
-                                           &xmlctx->name_len, &closing), cleanup);
+            &xmlctx->name_len, &closing), cleanup);
 
     if (xmlctx->in->current[0] == '\0') {
         /* update status */
         xmlctx->status = LYXML_END;
     } else if (closing) {
         LOGVAL(ctx, LY_VLOG_LINE, &xmlctx->line, LYVE_SYNTAX, "Stray closing element tag (\"%.*s\").",
-               xmlctx->name_len, xmlctx->name);
+                xmlctx->name_len, xmlctx->name);
         ret = LY_EVALID;
         goto cleanup;
     } else {
@@ -911,7 +911,7 @@
 
             /* parse element content */
             ret = lyxml_parse_value(xmlctx, '<', (char **)&xmlctx->value, &xmlctx->value_len, &xmlctx->ws_only,
-                                    &xmlctx->dynamic);
+                    &xmlctx->dynamic);
             LY_CHECK_GOTO(ret, cleanup);
 
             if (!xmlctx->value_len) {
diff --git a/src/xpath.c b/src/xpath.c
index 146f9dd..40cec6e 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -141,7 +141,7 @@
     LOGDBG(LY_LDGXPATH, "expression \"%s\":", exp->expr);
     for (i = 0; i < exp->used; ++i) {
         sprintf(tmp, "\ttoken %s, in expression \"%.*s\"", lyxp_print_token(exp->tokens[i]), exp->tok_len[i],
-               &exp->expr[exp->tok_pos[i]]);
+                &exp->expr[exp->tok_pos[i]]);
         if (exp->repeat[i]) {
             sprintf(tmp + strlen(tmp), " (repeat %d", exp->repeat[i][0]);
             for (j = 1; exp->repeat[i][j]; ++j) {
@@ -189,13 +189,13 @@
                 LOGDBG(LY_LDGXPATH, "\t%d (pos %u): ROOT CONFIG", i + 1, item->pos);
                 break;
             case LYXP_NODE_ELEM:
-                if ((item->node->schema->nodetype == LYS_LIST)
-                        && (((struct lyd_node_inner *)item->node)->child->schema->nodetype == LYS_LEAF)) {
+                if ((item->node->schema->nodetype == LYS_LIST) &&
+                        (((struct lyd_node_inner *)item->node)->child->schema->nodetype == LYS_LEAF)) {
                     LOGDBG(LY_LDGXPATH, "\t%d (pos %u): ELEM %s (1st child val: %s)", i + 1, item->pos,
-                           item->node->schema->name, LYD_CANON_VALUE(lyd_child(item->node)));
+                            item->node->schema->name, LYD_CANON_VALUE(lyd_child(item->node)));
                 } else if (((struct lyd_node_inner *)item->node)->schema->nodetype == LYS_LEAFLIST) {
                     LOGDBG(LY_LDGXPATH, "\t%d (pos %u): ELEM %s (val: %s)", i + 1, item->pos,
-                           item->node->schema->name, LYD_CANON_VALUE(item->node));
+                            item->node->schema->name, LYD_CANON_VALUE(item->node));
                 } else {
                     LOGDBG(LY_LDGXPATH, "\t%d (pos %u): ELEM %s", i + 1, item->pos, item->node->schema->name);
                 }
@@ -203,14 +203,14 @@
             case LYXP_NODE_TEXT:
                 if (item->node->schema->nodetype & LYS_ANYDATA) {
                     LOGDBG(LY_LDGXPATH, "\t%d (pos %u): TEXT <%s>", i + 1, item->pos,
-                           item->node->schema->nodetype == LYS_ANYXML ? "anyxml" : "anydata");
+                            item->node->schema->nodetype == LYS_ANYXML ? "anyxml" : "anydata");
                 } else {
                     LOGDBG(LY_LDGXPATH, "\t%d (pos %u): TEXT %s", i + 1, item->pos, LYD_CANON_VALUE(item->node));
                 }
                 break;
             case LYXP_NODE_META:
                 LOGDBG(LY_LDGXPATH, "\t%d (pos %u): META %s = %s", i + 1, item->pos, set->val.meta[i].meta->name,
-                       set->val.meta[i].meta->value);
+                        set->val.meta[i].meta->value);
                 break;
             }
         }
@@ -1468,11 +1468,11 @@
 
     /* 1st TEXT - 2nd ELEM, 1st TEXT - any pos - 2nd META, 1st META - any pos - 2nd ELEM, 1st META - >pos> - 2nd META */
     /* 2nd is before 1st */
-    if (((item1->type == LYXP_NODE_TEXT)
-            && ((item2->type == LYXP_NODE_ELEM) || (item2->type == LYXP_NODE_META)))
-            || ((item1->type == LYXP_NODE_META) && (item2->type == LYXP_NODE_ELEM))
-            || (((item1->type == LYXP_NODE_META) && (item2->type == LYXP_NODE_META))
-            && (meta_pos1 > meta_pos2))) {
+    if (((item1->type == LYXP_NODE_TEXT) &&
+            ((item2->type == LYXP_NODE_ELEM) || (item2->type == LYXP_NODE_META))) ||
+            ((item1->type == LYXP_NODE_META) && (item2->type == LYXP_NODE_ELEM)) ||
+            (((item1->type == LYXP_NODE_META) && (item2->type == LYXP_NODE_META)) &&
+            (meta_pos1 > meta_pos2))) {
         return 1;
     }
 
@@ -1683,8 +1683,8 @@
 
     if (set->used > 1) {
         while (i < set->used - 1) {
-            if ((set->val.nodes[i].node == set->val.nodes[i + 1].node)
-                    && (set->val.nodes[i].type == set->val.nodes[i + 1].type)) {
+            if ((set->val.nodes[i].node == set->val.nodes[i + 1].node) &&
+                    (set->val.nodes[i].type == set->val.nodes[i + 1].type)) {
                 set_remove_node_none(set, i + 1);
                 ret = LY_EEXIST;
             }
@@ -1848,7 +1848,7 @@
     if (want_tok && (exp->tokens[tok_idx] != want_tok)) {
         if (ctx) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_INTOK,
-                   lyxp_print_token(exp->tokens[tok_idx]), &exp->expr[exp->tok_pos[tok_idx]]);
+                    lyxp_print_token(exp->tokens[tok_idx]), &exp->expr[exp->tok_pos[tok_idx]]);
         }
         return LY_ENOT;
     }
@@ -1882,7 +1882,7 @@
     if ((exp->tokens[tok_idx] != want_tok1) && (exp->tokens[tok_idx] != want_tok2)) {
         if (ctx) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_INTOK,
-                   lyxp_print_token(exp->tokens[tok_idx]), &exp->expr[exp->tok_pos[tok_idx]]);
+                    lyxp_print_token(exp->tokens[tok_idx]), &exp->expr[exp->tok_pos[tok_idx]]);
         }
         return LY_ENOT;
     }
@@ -1989,7 +1989,7 @@
             LY_CHECK_RET(rc);
             if ((exp->tokens[*tok_idx] != LYXP_TOKEN_NAMETEST) && (exp->tokens[*tok_idx] != LYXP_TOKEN_NODETYPE)) {
                 LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_INTOK,
-                       lyxp_print_token(exp->tokens[*tok_idx]), &exp->expr[exp->tok_pos[*tok_idx]]);
+                        lyxp_print_token(exp->tokens[*tok_idx]), &exp->expr[exp->tok_pos[*tok_idx]]);
                 return LY_EVALID;
             }
         /* fall through */
@@ -2020,7 +2020,7 @@
             break;
         default:
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_INTOK,
-                   lyxp_print_token(exp->tokens[*tok_idx]), &exp->expr[exp->tok_pos[*tok_idx]]);
+                    lyxp_print_token(exp->tokens[*tok_idx]), &exp->expr[exp->tok_pos[*tok_idx]]);
             return LY_EVALID;
         }
     } while (!exp_check_token2(NULL, exp, *tok_idx, LYXP_TOKEN_OPER_PATH, LYXP_TOKEN_OPER_RPATH));
@@ -2276,7 +2276,7 @@
 
     if ((arg_count < (uint32_t)min_arg_count) || (arg_count > max_arg_count)) {
         LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_INARGCOUNT, arg_count, exp->tok_len[func_tok_idx],
-               &exp->expr[exp->tok_pos[func_tok_idx]]);
+                &exp->expr[exp->tok_pos[func_tok_idx]]);
         return LY_EVALID;
     }
 
@@ -2352,7 +2352,7 @@
         break;
     default:
         LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_INTOK,
-               lyxp_print_token(exp->tokens[*tok_idx]), &exp->expr[exp->tok_pos[*tok_idx]]);
+                lyxp_print_token(exp->tokens[*tok_idx]), &exp->expr[exp->tok_pos[*tok_idx]]);
         return LY_EVALID;
     }
 
@@ -2397,8 +2397,8 @@
 
     /* ('-')* */
     prev_exp = *tok_idx;
-    while (!lyxp_check_token(NULL, exp, *tok_idx, LYXP_TOKEN_OPER_MATH)
-            && (exp->expr[exp->tok_pos[*tok_idx]] == '-')) {
+    while (!lyxp_check_token(NULL, exp, *tok_idx, LYXP_TOKEN_OPER_MATH) &&
+            (exp->expr[exp->tok_pos[*tok_idx]] == '-')) {
         exp_repeat_push(exp, prev_exp, LYXP_EXPR_UNARY);
         ++(*tok_idx);
     }
@@ -2446,8 +2446,8 @@
     goto reparse_multiplicative_expr;
 
     /* ('+' / '-' MultiplicativeExpr)* */
-    while (!lyxp_check_token(NULL, exp, *tok_idx, LYXP_TOKEN_OPER_MATH)
-            && ((exp->expr[exp->tok_pos[*tok_idx]] == '+') || (exp->expr[exp->tok_pos[*tok_idx]] == '-'))) {
+    while (!lyxp_check_token(NULL, exp, *tok_idx, LYXP_TOKEN_OPER_MATH) &&
+            ((exp->expr[exp->tok_pos[*tok_idx]] == '+') || (exp->expr[exp->tok_pos[*tok_idx]] == '-'))) {
         exp_repeat_push(exp, prev_add_exp, LYXP_EXPR_ADDITIVE);
         ++(*tok_idx);
 
@@ -2458,8 +2458,8 @@
         LY_CHECK_RET(rc);
 
         /* ('*' / 'div' / 'mod' UnaryExpr)* */
-        while (!lyxp_check_token(NULL, exp, *tok_idx, LYXP_TOKEN_OPER_MATH)
-                && ((exp->expr[exp->tok_pos[*tok_idx]] == '*') || (exp->tok_len[*tok_idx] == 3))) {
+        while (!lyxp_check_token(NULL, exp, *tok_idx, LYXP_TOKEN_OPER_MATH) &&
+                ((exp->expr[exp->tok_pos[*tok_idx]] == '*') || (exp->tok_len[*tok_idx] == 3))) {
             exp_repeat_push(exp, prev_mul_exp, LYXP_EXPR_MULTIPLICATIVE);
             ++(*tok_idx);
 
@@ -2709,11 +2709,11 @@
 
             if (prev_function_check && expr->used && (expr->tokens[expr->used - 1] == LYXP_TOKEN_NAMETEST)) {
                 /* it is a NodeType/FunctionName after all */
-                if (((expr->tok_len[expr->used - 1] == 4)
-                        && (!strncmp(&expr_str[expr->tok_pos[expr->used - 1]], "node", 4)
-                        || !strncmp(&expr_str[expr->tok_pos[expr->used - 1]], "text", 4))) ||
-                        ((expr->tok_len[expr->used - 1] == 7)
-                        && !strncmp(&expr_str[expr->tok_pos[expr->used - 1]], "comment", 7))) {
+                if (((expr->tok_len[expr->used - 1] == 4) &&
+                        (!strncmp(&expr_str[expr->tok_pos[expr->used - 1]], "node", 4) ||
+                        !strncmp(&expr_str[expr->tok_pos[expr->used - 1]], "text", 4))) ||
+                        ((expr->tok_len[expr->used - 1] == 7) &&
+                        !strncmp(&expr_str[expr->tok_pos[expr->used - 1]], "comment", 7))) {
                     expr->tokens[expr->used - 1] = LYXP_TOKEN_NODETYPE;
                 } else {
                     expr->tokens[expr->used - 1] = LYXP_TOKEN_FUNCNAME;
@@ -2768,8 +2768,8 @@
             /* Literal with ' */
             for (tok_len = 1; (expr_str[parsed + tok_len] != '\0') && (expr_str[parsed + tok_len] != '\''); ++tok_len) {}
             LY_CHECK_ERR_GOTO(expr_str[parsed + tok_len] == '\0',
-                              LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_EOE, expr_str[parsed], &expr_str[parsed]); ret = LY_EVALID,
-                              error);
+                    LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_EOE, expr_str[parsed], &expr_str[parsed]); ret = LY_EVALID,
+                    error);
             ++tok_len;
             tok_type = LYXP_TOKEN_LITERAL;
 
@@ -2778,8 +2778,8 @@
             /* Literal with " */
             for (tok_len = 1; (expr_str[parsed + tok_len] != '\0') && (expr_str[parsed + tok_len] != '\"'); ++tok_len) {}
             LY_CHECK_ERR_GOTO(expr_str[parsed + tok_len] == '\0',
-                              LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_EOE, expr_str[parsed], &expr_str[parsed]); ret = LY_EVALID,
-                              error);
+                    LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_EOE, expr_str[parsed], &expr_str[parsed]); ret = LY_EVALID,
+                    error);
             ++tok_len;
             tok_type = LYXP_TOKEN_LITERAL;
 
@@ -2840,18 +2840,18 @@
             tok_len = 1;
             tok_type = LYXP_TOKEN_OPER_COMP;
 
-        } else if (expr->used && (expr->tokens[expr->used - 1] != LYXP_TOKEN_AT)
-                && (expr->tokens[expr->used - 1] != LYXP_TOKEN_PAR1)
-                && (expr->tokens[expr->used - 1] != LYXP_TOKEN_BRACK1)
-                && (expr->tokens[expr->used - 1] != LYXP_TOKEN_COMMA)
-                && (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_LOG)
-                && (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_EQUAL)
-                && (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_NEQUAL)
-                && (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_COMP)
-                && (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_MATH)
-                && (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_UNI)
-                && (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_PATH)
-                && (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_RPATH)) {
+        } else if (expr->used && (expr->tokens[expr->used - 1] != LYXP_TOKEN_AT) &&
+                (expr->tokens[expr->used - 1] != LYXP_TOKEN_PAR1) &&
+                (expr->tokens[expr->used - 1] != LYXP_TOKEN_BRACK1) &&
+                (expr->tokens[expr->used - 1] != LYXP_TOKEN_COMMA) &&
+                (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_LOG) &&
+                (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_EQUAL) &&
+                (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_NEQUAL) &&
+                (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_COMP) &&
+                (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_MATH) &&
+                (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_UNI) &&
+                (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_PATH) &&
+                (expr->tokens[expr->used - 1] != LYXP_TOKEN_OPER_RPATH)) {
 
             /* Operator '*', 'or', 'and', 'mod', or 'div' */
             if (expr_str[parsed] == '*') {
@@ -2872,7 +2872,7 @@
 
             } else if (prev_function_check) {
                 LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Invalid character 0x%x ('%c'), perhaps \"%.*s\" is supposed to be a function call.",
-                       expr_str[parsed], expr_str[parsed], expr->tok_len[expr->used - 1], &expr->expr[expr->tok_pos[expr->used - 1]]);
+                        expr_str[parsed], expr_str[parsed], expr->tok_len[expr->used - 1], &expr->expr[expr->tok_pos[expr->used - 1]]);
                 ret = LY_EVALID;
                 goto error;
             } else {
@@ -2891,8 +2891,8 @@
             /* NameTest (NCName ':' '*' | QName) or NodeType/FunctionName */
             long int ncname_len = parse_ncname(&expr_str[parsed]);
             LY_CHECK_ERR_GOTO(ncname_len < 0,
-                              LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_INEXPR, parsed - ncname_len + 1, expr_str); ret = LY_EVALID,
-                              error);
+                    LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_INEXPR, parsed - ncname_len + 1, expr_str); ret = LY_EVALID,
+                    error);
             tok_len = ncname_len;
 
             if (expr_str[parsed + tok_len] == ':') {
@@ -2902,8 +2902,8 @@
                 } else {
                     ncname_len = parse_ncname(&expr_str[parsed + tok_len]);
                     LY_CHECK_ERR_GOTO(ncname_len < 0,
-                                      LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_INEXPR, parsed - ncname_len + 1, expr_str); ret = LY_EVALID,
-                                      error);
+                            LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_INEXPR, parsed - ncname_len + 1, expr_str); ret = LY_EVALID,
+                            error);
                     tok_len += ncname_len;
                 }
                 /* remove old flag to prevent ambiguities */
@@ -2934,7 +2934,7 @@
         LY_CHECK_ERR_GOTO(reparse_or_expr(ctx, expr, &tok_idx), ret = LY_EVALID, error);
         if (expr->used > tok_idx) {
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Unparsed characters \"%s\" left at the end of an XPath expression.",
-                &expr->expr[expr->tok_pos[tok_idx]]);
+                    &expr->expr[expr->tok_pos[tok_idx]]);
             ret = LY_EVALID;
             goto error;
         }
@@ -3277,10 +3277,10 @@
     }
 
     if (node1 && node2 && leaves && !numbers_only) {
-        if ((warn_is_numeric_type(node1->type) && !warn_is_numeric_type(node2->type))
-                || (!warn_is_numeric_type(node1->type) && warn_is_numeric_type(node2->type))
-                || (!warn_is_numeric_type(node1->type) && !warn_is_numeric_type(node2->type)
-                && !warn_is_equal_type(node1->type, node2->type))) {
+        if ((warn_is_numeric_type(node1->type) && !warn_is_numeric_type(node2->type)) ||
+                (!warn_is_numeric_type(node1->type) && warn_is_numeric_type(node2->type)) ||
+                (!warn_is_numeric_type(node1->type) && !warn_is_numeric_type(node2->type) &&
+                !warn_is_equal_type(node1->type, node2->type))) {
             LOGWRN(ctx, "Incompatible types of operands \"%s\" and \"%s\" for comparison.", node1->name, node2->name);
             warning = 1;
         }
@@ -3310,8 +3310,8 @@
     LY_ERR rc;
     struct ly_err_item *err = NULL;
 
-    if ((scnode = warn_get_scnode_in_ctx(set)) && (scnode->nodetype & (LYS_LEAF | LYS_LEAFLIST))
-            && ((exp->tokens[val_exp] == LYXP_TOKEN_LITERAL) || (exp->tokens[val_exp] == LYXP_TOKEN_NUMBER))) {
+    if ((scnode = warn_get_scnode_in_ctx(set)) && (scnode->nodetype & (LYS_LEAF | LYS_LEAFLIST)) &&
+            ((exp->tokens[val_exp] == LYXP_TOKEN_LITERAL) || (exp->tokens[val_exp] == LYXP_TOKEN_NUMBER))) {
         /* check that the node can have the specified value */
         if (exp->tokens[val_exp] == LYXP_TOKEN_LITERAL) {
             value = strndup(exp->expr + exp->tok_pos[val_exp] + 1, exp->tok_len[val_exp] - 2);
@@ -3325,10 +3325,10 @@
 
         if ((((struct lysc_node_leaf *)scnode)->type->basetype == LY_TYPE_IDENT) && !strchr(value, ':')) {
             LOGWRN(set->ctx, "Identityref \"%s\" comparison with identity \"%s\" without prefix, consider adding"
-                   " a prefix or best using \"derived-from(-or-self)()\" functions.", scnode->name, value);
+                    " a prefix or best using \"derived-from(-or-self)()\" functions.", scnode->name, value);
             LOGWRN(set->ctx, "Previous warning generated by XPath subexpression[%u] \"%.*s\".", exp->tok_pos[equal_exp],
                     (exp->tok_pos[last_equal_exp] - exp->tok_pos[equal_exp]) + exp->tok_len[last_equal_exp],
-                   exp->expr + exp->tok_pos[equal_exp]);
+                    exp->expr + exp->tok_pos[equal_exp]);
         }
 
         type = ((struct lysc_node_leaf *)scnode)->type;
@@ -3345,7 +3345,7 @@
             if (rc != LY_SUCCESS) {
                 LOGWRN(set->ctx, "Previous warning generated by XPath subexpression[%u] \"%.*s\".", exp->tok_pos[equal_exp],
                         (exp->tok_pos[last_equal_exp] - exp->tok_pos[equal_exp]) + exp->tok_len[last_equal_exp],
-                    exp->expr + exp->tok_pos[equal_exp]);
+                        exp->expr + exp->tok_pos[equal_exp]);
             } else {
                 type->plugin->free(set->ctx, &storage);
             }
@@ -3407,8 +3407,8 @@
     set_fill_boolean(set, 0);
     if (args[0]->used) {
         leaf = (struct lyd_node_term *)args[0]->val.nodes[0].node;
-        if ((leaf->schema->nodetype & (LYS_LEAF | LYS_LEAFLIST))
-                && (((struct lysc_node_leaf *)leaf->schema)->type->basetype == LY_TYPE_BITS)) {
+        if ((leaf->schema->nodetype & (LYS_LEAF | LYS_LEAFLIST)) &&
+                (((struct lysc_node_leaf *)leaf->schema)->type->basetype == LY_TYPE_BITS)) {
             bits = (struct lysc_type_bits *)((struct lysc_node_leaf *)leaf->schema)->type;
             LY_ARRAY_FOR(bits->bits, u) {
                 if (!strcmp(bits->bits[u].name, args[1]->val.str)) {
@@ -3512,7 +3512,7 @@
             if ((args[i]->type == LYXP_SET_SCNODE_SET) && (sleaf = (struct lysc_node_leaf *)warn_get_scnode_in_ctx(args[i]))) {
                 if (!(sleaf->nodetype & (LYS_LEAF | LYS_LEAFLIST))) {
                     LOGWRN(set->ctx, "Argument #%u of %s is a %s node \"%s\".",
-                           i + 1, __func__, lys_nodetype2str(sleaf->nodetype), sleaf->name);
+                            i + 1, __func__, lys_nodetype2str(sleaf->nodetype), sleaf->name);
                 } else if (!warn_is_string_type(sleaf->type)) {
                     LOGWRN(set->ctx, "Argument #%u of %s is node \"%s\", not of string-type.", i + 1, __func__, sleaf->name);
                 }
@@ -3689,7 +3689,7 @@
             LOGWRN(set->ctx, "Argument #1 of %s is a %s node \"%s\".", __func__, lys_nodetype2str(sleaf->nodetype), sleaf->name);
         } else if (!warn_is_specific_type(sleaf->type, LY_TYPE_LEAFREF) && !warn_is_specific_type(sleaf->type, LY_TYPE_INST)) {
             LOGWRN(set->ctx, "Argument #1 of %s is node \"%s\", not of type \"leafref\" nor \"instance-identifier\".",
-                   __func__, sleaf->name);
+                    __func__, sleaf->name);
         }
         set_scnode_clear_ctx(set);
         if (sleaf && (sleaf->type->basetype == LY_TYPE_LEAFREF)) {
@@ -3724,7 +3724,7 @@
             if (sleaf->type->basetype == LY_TYPE_LEAFREF) {
                 /* find leafref target */
                 if (ly_type_find_leafref((struct lysc_type_leafref *)sleaf->type, (struct lyd_node *)leaf,
-                                         &leaf->value, set->tree, &node, &errmsg)) {
+                        &leaf->value, set->tree, &node, &errmsg)) {
                     LOGERR(set->ctx, LY_EVALID, errmsg);
                     free(errmsg);
                     return LY_EVALID;
@@ -3733,7 +3733,7 @@
                 assert(sleaf->type->basetype == LY_TYPE_INST);
                 if (ly_path_eval(leaf->value.target, set->tree, &node)) {
                     LOGERR(set->ctx, LY_EVALID, "Invalid instance-identifier \"%s\" value - required instance not found.",
-                           LYD_CANON_VALUE(leaf));
+                            LYD_CANON_VALUE(leaf));
                     return LY_EVALID;
                 }
             }
@@ -3764,7 +3764,7 @@
             LOGWRN(set->ctx, "Argument #1 of %s not a node-set as expected.", func);
         } else if (!(sleaf->nodetype & (LYS_LEAF | LYS_LEAFLIST))) {
             LOGWRN(set->ctx, "Argument #1 of %s is a %s node \"%s\".", func, lys_nodetype2str(sleaf->nodetype),
-                   sleaf->name);
+                    sleaf->name);
         } else if (!warn_is_specific_type(sleaf->type, LY_TYPE_IDENT)) {
             LOGWRN(set->ctx, "Argument #1 of %s is node \"%s\", not of type \"identityref\".", func, sleaf->name);
         }
@@ -3772,7 +3772,7 @@
         if ((args[1]->type == LYXP_SET_SCNODE_SET) && (sleaf = (struct lysc_node_leaf *)warn_get_scnode_in_ctx(args[1]))) {
             if (!(sleaf->nodetype & (LYS_LEAF | LYS_LEAFLIST))) {
                 LOGWRN(set->ctx, "Argument #2 of %s is a %s node \"%s\".", func, lys_nodetype2str(sleaf->nodetype),
-                       sleaf->name);
+                        sleaf->name);
             } else if (!warn_is_string_type(sleaf->type)) {
                 LOGWRN(set->ctx, "Argument #2 of %s is node \"%s\", not of string-type.", func, sleaf->name);
             }
@@ -3783,7 +3783,7 @@
 
     if (args[0]->type != LYXP_SET_NODE_SET) {
         LOGVAL(set->ctx, LY_VLOG_LYD, set->ctx_node, LY_VCODE_XP_INARGTYPE, 1, print_set_type(args[0]),
-               "derived-from(-or-self)(node-set, string)");
+                "derived-from(-or-self)(node-set, string)");
         return LY_EVALID;
     }
     rc = lyxp_set_cast(args[1], LYXP_SET_STRING);
@@ -4117,6 +4117,7 @@
 xpath_local_name(struct lyxp_set **args, uint16_t arg_count, struct lyxp_set *set, uint32_t options)
 {
     struct lyxp_set_node *item;
+
     /* suppress unused variable warning */
     (void)options;
 
@@ -4279,6 +4280,7 @@
 {
     struct lyxp_set_node *item;
     struct lys_module *mod;
+
     /* suppress unused variable warning */
     (void)options;
 
@@ -4290,7 +4292,7 @@
     if (arg_count) {
         if (args[0]->type != LYXP_SET_NODE_SET) {
             LOGVAL(set->ctx, LY_VLOG_LYD, set->ctx_node, LY_VCODE_XP_INARGTYPE, 1, print_set_type(args[0]),
-                   "namespace-uri(node-set?)");
+                    "namespace-uri(node-set?)");
             return LY_EVALID;
         } else if (!args[0]->used) {
             set_fill_string(set, "", 0);
@@ -4838,8 +4840,8 @@
             }
         }
 
-        if ((arg_count == 3) && (args[2]->type == LYXP_SET_SCNODE_SET)
-                && (sleaf = (struct lysc_node_leaf *)warn_get_scnode_in_ctx(args[2]))) {
+        if ((arg_count == 3) && (args[2]->type == LYXP_SET_SCNODE_SET) &&
+                (sleaf = (struct lysc_node_leaf *)warn_get_scnode_in_ctx(args[2]))) {
             if (!(sleaf->nodetype & (LYS_LEAF | LYS_LEAFLIST))) {
                 LOGWRN(set->ctx, "Argument #3 of %s is a %s node \"%s\".", __func__, lys_nodetype2str(sleaf->nodetype), sleaf->name);
             } else if (!warn_is_numeric_type(sleaf->type)) {
@@ -5030,7 +5032,7 @@
                     sleaf = (struct lysc_node_leaf *)args[0]->val.scnodes[i].scnode;
                     if (!(sleaf->nodetype & (LYS_LEAF | LYS_LEAFLIST))) {
                         LOGWRN(set->ctx, "Argument #1 of %s is a %s node \"%s\".", __func__,
-                               lys_nodetype2str(sleaf->nodetype), sleaf->name);
+                                lys_nodetype2str(sleaf->nodetype), sleaf->name);
                     } else if (!warn_is_numeric_type(sleaf->type)) {
                         LOGWRN(set->ctx, "Argument #1 of %s is node \"%s\", not of numeric type.", __func__, sleaf->name);
                     }
@@ -5525,8 +5527,8 @@
     if ((set->root_type == LYXP_NODE_ROOT_CONFIG) && (scnode->flags & LYS_CONFIG_R)) {
         lyxp_set_free_content(set);
         goto cleanup;
-    } else if (set->context_op && (scnode->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF))
-            && (scnode != set->context_op)) {
+    } else if (set->context_op && (scnode->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)) &&
+            (scnode != set->context_op)) {
         lyxp_set_free_content(set);
         goto cleanup;
     }
@@ -6153,7 +6155,7 @@
 
         /* add all the children */
         rc = moveto_self_add_children_r(set->val.nodes[i].node, set->val.nodes[i].pos, set->val.nodes[i].type, &ret_set,
-                                        set, options);
+                set, options);
         if (rc != LY_SUCCESS) {
             lyxp_set_free_content(&ret_set);
             return rc;
@@ -6690,7 +6692,7 @@
 
     /* '[' */
     LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-           lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+            lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
     ++(*tok_idx);
 
     if (!set) {
@@ -6811,7 +6813,7 @@
     /* ']' */
     assert(exp->tokens[*tok_idx] == LYXP_TOKEN_BRACK2);
     LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-           lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+            lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
     ++(*tok_idx);
 
     return LY_SUCCESS;
@@ -6835,7 +6837,7 @@
         }
     }
     LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+            lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
     ++(*tok_idx);
 }
 
@@ -6916,11 +6918,11 @@
 
     /* parse the predicate(s) */
     LY_CHECK_GOTO(ret = ly_path_parse_predicate(scnode->module->ctx, scnode, exp->expr + exp->tok_pos[*tok_idx], pred_len,
-                                                LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_SIMPLE, &exp2), cleanup);
+            LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_SIMPLE, &exp2), cleanup);
 
     /* compile */
     ret = ly_path_compile_predicate(scnode->module->ctx, scnode, scnode->module, scnode, exp2, &pred_idx,
-                                    format, scnode->module, predicates, pred_type);
+            format, scnode->module, predicates, pred_type);
     LY_CHECK_GOTO(ret, cleanup);
 
     /* success, the predicate must include all the needed information for hash-based search */
@@ -6961,7 +6963,7 @@
     LY_ERR rc = LY_SUCCESS;
 
     LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-           lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+            lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
     ++(*tok_idx);
 
     if (!set) {
@@ -6980,8 +6982,8 @@
         for (uint32_t i = 0; i < set->used; ++i) {
             if (set->val.nodes[i].type == set->root_type) {
                 tmp = lys_find_child(NULL, moveto_mod, ncname, ncname_len, 0, 0);
-            } else if ((set->val.nodes[i].type == LYXP_NODE_ELEM)
-                    && (!scnode || (lysc_data_parent(scnode) != set->val.nodes[i].node->schema))) {
+            } else if ((set->val.nodes[i].type == LYXP_NODE_ELEM) &&
+                    (!scnode || (lysc_data_parent(scnode) != set->val.nodes[i].node->schema))) {
                 /* do not repeat the same search */
                 tmp = lys_find_child(set->val.nodes[i].node->schema, moveto_mod, ncname, ncname_len, 0, 0);
             } else {
@@ -7052,7 +7054,7 @@
             if (i == -1) {
                 path = lysc_path(set->ctx_scnode, LYSC_PATH_LOG, NULL, 0);
                 LOGWRN(set->ctx, "Schema node \"%.*s\" not found (%.*s) with context node \"%s\".",
-                       ncname_len, ncname, ncname - exp->expr, exp->expr, path);
+                        ncname_len, ncname, ncname - exp->expr, exp->expr, path);
                 free(path);
             }
         } else {
@@ -7126,19 +7128,19 @@
         }
     }
     LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-           lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+            lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
     ++(*tok_idx);
 
     /* '(' */
     assert(exp->tokens[*tok_idx] == LYXP_TOKEN_PAR1);
     LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-           lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+            lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
     ++(*tok_idx);
 
     /* ')' */
     assert(exp->tokens[*tok_idx] == LYXP_TOKEN_PAR2);
     LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-           lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+            lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
     ++(*tok_idx);
 
     /* Predicate* */
@@ -7180,7 +7182,7 @@
             all_desc = 1;
         }
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
 step:
@@ -7189,7 +7191,7 @@
             attr_axis = 1;
 
             LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-                   lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                    lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
             ++(*tok_idx);
         } else {
             attr_axis = 0;
@@ -7206,7 +7208,7 @@
             }
             LY_CHECK_RET(rc);
             LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-                   lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                    lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
             ++(*tok_idx);
             break;
 
@@ -7219,7 +7221,7 @@
             }
             LY_CHECK_RET(rc);
             LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-                   lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                    lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
             ++(*tok_idx);
             break;
 
@@ -7269,7 +7271,7 @@
         /* evaluate '/' - deferred */
         all_desc = 0;
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
         if (lyxp_check_token(NULL, exp, *tok_idx, LYXP_TOKEN_NONE)) {
@@ -7292,7 +7294,7 @@
         /* evaluate '//' - deferred so as not to waste memory by remembering all the nodes */
         all_desc = 1;
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
         LY_CHECK_RET(eval_relative_location_path(exp, tok_idx, all_desc, set, options));
@@ -7316,6 +7318,7 @@
 eval_function_call(struct lyxp_expr *exp, uint16_t *tok_idx, struct lyxp_set *set, uint32_t options)
 {
     LY_ERR rc;
+
     LY_ERR (*xpath_func)(struct lyxp_set **, uint16_t, struct lyxp_set *, uint32_t) = NULL;
     uint16_t arg_count = 0, i;
     struct lyxp_set **args = NULL, **args_aux;
@@ -7440,13 +7443,13 @@
     }
 
     LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+            lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
     ++(*tok_idx);
 
     /* '(' */
     assert(exp->tokens[*tok_idx] == LYXP_TOKEN_PAR1);
     LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+            lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
     ++(*tok_idx);
 
     /* ( Expr ( ',' Expr )* )? */
@@ -7470,7 +7473,7 @@
     }
     while (!lyxp_check_token(NULL, exp, *tok_idx, LYXP_TOKEN_COMMA)) {
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
         if (set) {
@@ -7495,7 +7498,7 @@
     /* ')' */
     assert(exp->tokens[*tok_idx] == LYXP_TOKEN_PAR2);
     LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+            lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
     ++(*tok_idx);
 
     if (set) {
@@ -7543,12 +7546,12 @@
         if (errno) {
             LOGVAL(ctx, LY_VLOG_LYD, set->ctx_node, LY_VCODE_XP_INTOK, "Unknown", &exp->expr[exp->tok_pos[*tok_idx]]);
             LOGVAL(ctx, LY_VLOG_LYD, set->ctx_node, LYVE_XPATH, "Failed to convert \"%.*s\" into a long double (%s).",
-                   exp->tok_len[*tok_idx], &exp->expr[exp->tok_pos[*tok_idx]], strerror(errno));
+                    exp->tok_len[*tok_idx], &exp->expr[exp->tok_pos[*tok_idx]], strerror(errno));
             return LY_EVALID;
         } else if (endptr - &exp->expr[exp->tok_pos[*tok_idx]] != exp->tok_len[*tok_idx]) {
             LOGVAL(ctx, LY_VLOG_LYD, set->ctx_node, LY_VCODE_XP_INTOK, "Unknown", &exp->expr[exp->tok_pos[*tok_idx]]);
             LOGVAL(ctx, LY_VLOG_LYD, set->ctx_node, LYVE_XPATH, "Failed to convert \"%.*s\" into a long double.",
-                   exp->tok_len[*tok_idx], &exp->expr[exp->tok_pos[*tok_idx]]);
+                    exp->tok_len[*tok_idx], &exp->expr[exp->tok_pos[*tok_idx]]);
             return LY_EVALID;
         }
 
@@ -7556,7 +7559,7 @@
     }
 
     LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+            lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
     ++(*tok_idx);
     return LY_SUCCESS;
 }
@@ -7588,7 +7591,7 @@
 
         /* '(' */
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
         /* Expr */
@@ -7598,7 +7601,7 @@
         /* ')' */
         assert(exp->tokens[*tok_idx] == LYXP_TOKEN_PAR2);
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
         parent_pos_pred = 0;
@@ -7664,7 +7667,7 @@
 
     default:
         LOGVAL(set->ctx, LY_VLOG_LYD, set->ctx_node, LY_VCODE_XP_INTOK, lyxp_print_token(exp->tokens[*tok_idx]),
-               &exp->expr[exp->tok_pos[*tok_idx]]);
+                &exp->expr[exp->tok_pos[*tok_idx]]);
         return LY_EVALID;
     }
 
@@ -7688,7 +7691,7 @@
         }
 
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
         rc = eval_relative_location_path(exp, tok_idx, all_desc, set, options);
@@ -7731,7 +7734,7 @@
     for (i = 0; i < repeat; ++i) {
         assert(exp->tokens[*tok_idx] == LYXP_TOKEN_OPER_UNI);
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
         if (!set) {
@@ -7785,7 +7788,7 @@
         assert(!lyxp_check_token(NULL, exp, *tok_idx, LYXP_TOKEN_OPER_MATH) && (exp->expr[exp->tok_pos[*tok_idx]] == '-'));
 
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
     }
 
@@ -7843,7 +7846,7 @@
 
         assert(exp->tokens[*tok_idx] == LYXP_TOKEN_OPER_MATH);
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
         if (!set) {
@@ -7911,7 +7914,7 @@
 
         assert(exp->tokens[*tok_idx] == LYXP_TOKEN_OPER_MATH);
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
         if (!set) {
@@ -7981,7 +7984,7 @@
 
         assert(exp->tokens[*tok_idx] == LYXP_TOKEN_OPER_COMP);
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
         if (!set) {
@@ -8048,7 +8051,7 @@
 
         assert((exp->tokens[*tok_idx] == LYXP_TOKEN_OPER_EQUAL) || (exp->tokens[*tok_idx] == LYXP_TOKEN_OPER_NEQUAL));
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (set ? "parsed" : "skipped"),
-               lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
         if (!set) {
@@ -8120,7 +8123,7 @@
     for (i = 0; i < repeat; ++i) {
         assert(exp->tokens[*tok_idx] == LYXP_TOKEN_OPER_LOG);
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (!set || !set->val.bln ? "skipped" : "parsed"),
-            lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
         /* lazy evaluation */
@@ -8190,7 +8193,7 @@
     for (i = 0; i < repeat; ++i) {
         assert(exp->tokens[*tok_idx] == LYXP_TOKEN_OPER_LOG);
         LOGDBG(LY_LDGXPATH, "%-27s %s %s[%u]", __func__, (!set || set->val.bln ? "skipped" : "parsed"),
-            lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
+                lyxp_print_token(exp->tokens[*tok_idx]), exp->tok_pos[*tok_idx]);
         ++(*tok_idx);
 
         /* lazy evaluation */
diff --git a/src/xpath.h b/src/xpath.h
index 099f810..38ba4b2 100644
--- a/src/xpath.h
+++ b/src/xpath.h
@@ -15,8 +15,8 @@
 #ifndef LY_XPATH_H
 #define LY_XPATH_H
 
-#include <stdint.h>
 #include <stddef.h>
+#include <stdint.h>
 
 #include "compat.h"
 #include "log.h"
@@ -128,7 +128,7 @@
     LYXP_EXPR_ADDITIVE,
     LYXP_EXPR_MULTIPLICATIVE,
     LYXP_EXPR_UNARY,
-    LYXP_EXPR_UNION,
+    LYXP_EXPR_UNION
 };
 
 /**