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;
                         }
