libyang MAINTENANCE change format of the empty loops

To improve readability and because of processing by the formatting
tools, add explicit empty block to the empty loops (for, while).
diff --git a/src/common.c b/src/common.c
index 7a8d83a..11a4b9b 100644
--- a/src/common.c
+++ b/src/common.c
@@ -344,10 +344,13 @@
 size_t
 ly_utf8len(const char *str, size_t bytes)
 {
-    size_t len;
-    const char *ptr;
+    size_t len = 0;
+    const char *ptr = str;
 
-    for (len = 0, ptr = str; *ptr && (size_t)(ptr - str) < bytes; ++len, ptr += utf8_char_length_table[((unsigned char)(*ptr))]);
+    while(*ptr && (size_t)(ptr - str) < bytes) {
+        ++len;
+        ptr += utf8_char_length_table[((unsigned char)(*ptr))];
+    }
     return len;
 }
 
@@ -360,7 +363,7 @@
     } else if (!str[0]) {
         return 1;
     }
-    for (len = 1; len < LY_VCODE_INSTREXP_MAXLEN && str[len]; ++len);
+    for (len = 1; len < LY_VCODE_INSTREXP_MAXLEN && str[len]; ++len) {}
     return len;
 }
 
@@ -581,7 +584,7 @@
     *prefix_len = *id_len = *value_len = 0;
 
     /* leading *WSP */
-    for (; isspace(in[offset]); offset++);
+    for (; isspace(in[offset]); offset++) {}
 
     if (isdigit(in[offset])) {
         /* pos: "[" *WSP positive-integer-value *WSP "]" */
@@ -593,7 +596,7 @@
 
         /* positive-integer-value */
         *value = &in[offset++];
-        for (; isdigit(in[offset]); offset++);
+        for (; isdigit(in[offset]); offset++) {}
         *value_len = &in[offset] - *value;
 
     } else if (in[offset] == '.') {
@@ -625,7 +628,7 @@
 
     if (expr) {
         /*  *WSP "=" *WSP quoted-string *WSP "]" */
-        for (; isspace(in[offset]); offset++);
+        for (; isspace(in[offset]); offset++) {}
 
         if (in[offset] != '=') {
             if (expr == 1) {
@@ -636,7 +639,7 @@
             goto error;
         }
         offset++;
-        for (; isspace(in[offset]); offset++);
+        for (; isspace(in[offset]); offset++) {}
 
         /* quoted-string */
         quot = in[offset++];
@@ -645,7 +648,7 @@
             goto error;
         }
         *value = &in[offset];
-        for (;offset < limit && (in[offset] != quot || (offset && in[offset - 1] == '\\')); offset++);
+        for (;offset < limit && (in[offset] != quot || (offset && in[offset - 1] == '\\')); offset++) {}
         if (in[offset] == quot) {
             *value_len = &in[offset] - *value;
             offset++;
@@ -656,7 +659,7 @@
     }
 
     /* *WSP "]" */
-    for(; isspace(in[offset]); offset++);
+    for(; isspace(in[offset]); offset++) {}
     if (in[offset] != ']') {
         if (expr == 0) {
             *errmsg = "Predicate (pos) is not terminated by \']\' character.";
diff --git a/src/common.h b/src/common.h
index f7f9b77..ac2c328 100644
--- a/src/common.h
+++ b/src/common.h
@@ -651,7 +651,7 @@
     } else { \
         do { \
             __typeof__(*(LIST)) iterator; \
-            for (iterator = *(LIST); iterator->LINKER; iterator = iterator->LINKER); \
+            for (iterator = *(LIST); iterator->LINKER; iterator = iterator->LINKER) {} \
             iterator->LINKER = (__typeof__(*(LIST)))NEW_ITEM; \
         } while (0); \
     }
diff --git a/src/context.c b/src/context.c
index 442050a..5ddfded 100644
--- a/src/context.c
+++ b/src/context.c
@@ -214,7 +214,7 @@
 #endif
 
     /* initialize thread-specific key */
-    while ((pthread_key_create(&ctx->errlist_key, ly_err_free)) == EAGAIN);
+    while ((pthread_key_create(&ctx->errlist_key, ly_err_free)) == EAGAIN) {}
 
     /* models list */
     ctx->flags = options;
diff --git a/src/diff.c b/src/diff.c
index 595957f..09ea1fb 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -199,7 +199,7 @@
         if (first->parent) {
             iter = first->parent->child;
         } else {
-            for (iter = first; iter->prev->next; iter = iter->prev);
+            for (iter = first; iter->prev->next; iter = iter->prev) {}
         }
         for (; iter; iter = iter->next) {
             if (iter->schema == first->schema) {
diff --git a/src/log.c b/src/log.c
index 7720aa8..9e470d2 100644
--- a/src/log.c
+++ b/src/log.c
@@ -168,7 +168,7 @@
     }
     if (eitem) {
         /* disconnect the error */
-        for (i = first; i && (i->next != eitem); i = i->next);
+        for (i = first; i && (i->next != eitem); i = i->next) {}
         assert(i);
         i->next = NULL;
         first->prev = i;
diff --git a/src/parser_json.c b/src/parser_json.c
index 86102b5..788a6c3 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -300,7 +300,7 @@
         if (is_yangidentstartchar(c)) {
             for (ly_getutf8(&stop, &c, &bytes);
                     is_yangidentchar(c) && (size_t)(stop - value) < value_len;
-                    ly_getutf8(&stop, &c, &bytes));
+                    ly_getutf8(&stop, &c, &bytes)) {}
             stop = stop - bytes;
             if (*stop == ':') {
                 /* we have a possible prefix */
@@ -1849,7 +1849,7 @@
     if (op_p) {
         *op_p = rep_op;
     }
-    for (tree = rep_op; tree->parent; tree = LYD_PARENT(tree));
+    for (tree = rep_op; tree->parent; tree = LYD_PARENT(tree)) {}
     if (rpcr_e) {
         /* connect to the operation */
         lyd_insert_node(rpcr_e, NULL, tree);
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index b12f035..a164e71 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -1049,7 +1049,7 @@
         if (op_p) {
             *op_p = (struct lyd_node*)(*parent);
         }
-        for (iter = *parent; iter->parent; iter = iter->parent);
+        for (iter = *parent; iter->parent; iter = iter->parent) {}
         tree = (struct lyd_node *)iter;
         *parent = NULL;
 
diff --git a/src/parser_xml.c b/src/parser_xml.c
index 3bf8de0..5a4fb80 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -1021,7 +1021,7 @@
     if (op_p) {
         *op_p = rep_op;
     }
-    for (tree = rep_op; tree->parent; tree = LYD_PARENT(tree));
+    for (tree = rep_op; tree->parent; tree = LYD_PARENT(tree)) {}
     if (rpcr_e) {
         /* connect to the operation */
         lyd_insert_node(rpcr_e, NULL, tree);
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 94cce2c..0c50d57 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -778,7 +778,7 @@
     if (!*child) {
         *child = stmt;
     } else {
-        for (par_child = *child; par_child->next; par_child = par_child->next);
+        for (par_child = *child; par_child->next; par_child = par_child->next) {}
         par_child->next = stmt;
     }
 
diff --git a/src/path.c b/src/path.c
index 09ccaf6..eb78599 100644
--- a/src/path.c
+++ b/src/path.c
@@ -708,7 +708,7 @@
     assert((target == LY_PATH_TARGET_SINGLE) || (target == LY_PATH_TARGET_MANY));
 
     /* find operation, if we are in any */
-    for (op = ctx_node; op && !(op->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)); op = op->parent);
+    for (op = ctx_node; op && !(op->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)); op = op->parent) {}
 
     /* remember original context node */
     cur_node = ctx_node;
diff --git a/src/plugins_types.c b/src/plugins_types.c
index 13a9c95..788a5cb 100644
--- a/src/plugins_types.c
+++ b/src/plugins_types.c
@@ -216,7 +216,7 @@
     LY_CHECK_ARG_RET(NULL, err, datatype, LY_EINVAL);
 
     /* consume leading whitespaces */
-    for (;value_len && isspace(*value); ++value, --value_len);
+    for (;value_len && isspace(*value); ++value, --value_len) {}
 
     if (!value || !value[0] || !value_len) {
         rc = asprintf(&errmsg, "Invalid empty %s value.", datatype);
@@ -254,7 +254,7 @@
     LY_CHECK_ARG_RET(NULL, err, datatype, LY_EINVAL);
 
     /* consume leading whitespaces */
-    for (;value_len && isspace(*value); ++value, --value_len);
+    for (;value_len && isspace(*value); ++value, --value_len) {}
 
     if (!value || !value[0] || !value_len) {
         rc = asprintf(&errmsg, "Invalid empty %s value.", datatype);
@@ -293,7 +293,7 @@
     int64_t d;
 
     /* consume leading whitespaces */
-    for (;value_len && isspace(*value); ++value, --value_len);
+    for (;value_len && isspace(*value); ++value, --value_len) {}
 
     /* parse value */
     if (!value_len) {
@@ -350,7 +350,7 @@
     if (len + trailing_zeros < value_len) {
         /* consume trailing whitespaces to check that there is nothing after it */
         unsigned long int u;
-        for (u = len + trailing_zeros; u < value_len && isspace(value[u]); ++u);
+        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) {
@@ -714,8 +714,8 @@
     /* validate characters and remember the number of octets for length validation */
     if (value_len) {
         /* silently skip leading/trailing whitespaces */
-        for (start = 0; (start < value_len) && isspace(value[start]); start++);
-        for (stop = value_len - 1; stop > start && isspace(value[stop]); stop--);
+        for (start = 0; (start < value_len) && isspace(value[start]); start++) {}
+        for (stop = value_len - 1; stop > start && isspace(value[stop]); stop--) {}
         if (start == stop) {
             /* empty string */
             goto finish;
@@ -877,7 +877,7 @@
 
         /* start of the item */
         item = &value[index];
-        for (item_len = 0; index + item_len < value_len && !isspace(item[item_len]); item_len++);
+        for (item_len = 0; index + item_len < value_len && !isspace(item[item_len]); item_len++) {}
         LY_ARRAY_FOR(type_bits->bits, u) {
             if (!ly_strncmp(type_bits->bits[u].name, item, item_len)) {
                 /* we have the match */
@@ -1212,7 +1212,7 @@
     }
 
     /* locate prefix if any */
-    for (prefix_len = 0; prefix_len < value_len && value[prefix_len] != ':'; ++prefix_len);
+    for (prefix_len = 0; prefix_len < value_len && value[prefix_len] != ':'; ++prefix_len) {}
     if (prefix_len < value_len) {
         id_name = &value[prefix_len + 1];
         id_len = value_len - (prefix_len + 1);
@@ -1959,7 +1959,7 @@
         if (is_xmlqnamestartchar(c)) {
             for (ly_getutf8(&stop, &c, &bytes);
                     is_xmlqnamechar(c) && (size_t)(stop - value) < value_len;
-                    ly_getutf8(&stop, &c, &bytes));
+                    ly_getutf8(&stop, &c, &bytes)) {}
             stop = stop - bytes;
             if (*stop == ':') {
                 /* we have a possible prefix */
diff --git a/src/printer_lyb.c b/src/printer_lyb.c
index 0cb070d..12dc0a8 100644
--- a/src/printer_lyb.c
+++ b/src/printer_lyb.c
@@ -860,7 +860,7 @@
     }
 
     /* written hash was a collision, write also all the preceding hashes */
-    for (i = 0; !(hash & (LYB_HASH_COLLISION_ID >> i)); ++i);
+    for (i = 0; !(hash & (LYB_HASH_COLLISION_ID >> i)); ++i) {}
 
     for (; i; --i) {
         hash = lyb_hash(schema, i - 1);
diff --git a/src/tree_data.c b/src/tree_data.c
index a6963ba..6baa2d5 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -283,7 +283,7 @@
         size_t len = strlen(path);
 
         /* ignore trailing whitespaces */
-        for (; len > 0 && isspace(path[len - 1]); len--);
+        for (; len > 0 && isspace(path[len - 1]); len--) {}
 
         if (len >= 5 && !strncmp(&path[len - 4], ".xml", 4)) {
             format = LYD_XML;
@@ -1700,7 +1700,7 @@
         if (sibling->parent) {
             sibling = sibling->parent->child;
         } else {
-            for (; sibling->prev->next != node; sibling = sibling->prev);
+            for (; sibling->prev->next != node; sibling = sibling->prev) {}
         }
         sibling->prev = node;
     }
@@ -2103,7 +2103,7 @@
 
     /* insert as the last attribute */
     if (parent->meta) {
-        for (last = parent->meta; last->next; last = last->next);
+        for (last = parent->meta; last->next; last = last->next) {}
         last->next = meta;
     } else {
         parent->meta = meta;
@@ -2158,7 +2158,7 @@
     if (parent) {
         lyd_insert_meta(parent, mt);
     } else if (*meta) {
-        for (last = *meta; last->next; last = last->next);
+        for (last = *meta; last->next; last = last->next) {}
         last->next = mt;
     }
 
@@ -2187,7 +2187,7 @@
 
     /* insert as the last attribute */
     if (opaq->attr) {
-        for (last = opaq->attr; last->next; last = last->next);
+        for (last = opaq->attr; last->next; last = last->next) {}
         last->next = attr;
     } else {
         opaq->attr = attr;
@@ -2233,7 +2233,7 @@
     if (parent) {
         lyd_insert_attr(parent, at);
     } else if (*attr) {
-        for (last = *attr; last->next; last = last->next);
+        for (last = *attr; last->next; last = last->next) {}
         last->next = at;
     }
 
@@ -2736,7 +2736,7 @@
 
     /* insert as the last attribute */
     if (node->meta) {
-        for (last = node->meta; last->next; last = last->next);
+        for (last = node->meta; last->next; last = last->next) {}
         last->next = mt;
     } else {
         node->meta = mt;
@@ -2975,7 +2975,7 @@
     if (node->parent) {
         first = node->parent->child;
     } else {
-        for (first = node; node->prev->next; node = node->prev);
+        for (first = node; node->prev->next; node = node->prev) {}
     }
     pos = 1;
     for (iter = first; iter != node; iter = iter->next) {
@@ -3028,7 +3028,7 @@
         goto iter_print;
         while (depth) {
             /* find the right node */
-            for (iter = node, i = 1; i < depth; iter = (const struct lyd_node *)iter->parent, ++i);
+            for (iter = node, i = 1; i < depth; iter = (const struct lyd_node *)iter->parent, ++i) {}
 iter_print:
             /* print prefix and name */
             mod = NULL;
diff --git a/src/tree_data_free.c b/src/tree_data_free.c
index 8dda446..bb6231c 100644
--- a/src/tree_data_free.c
+++ b/src/tree_data_free.c
@@ -40,7 +40,7 @@
                 meta->parent->meta = meta->next;
             }
         } else {
-            for (iter = meta->parent->meta; iter->next != meta; iter = iter->next);
+            for (iter = meta->parent->meta; iter->next != meta; iter = iter->next) {}
             if (iter->next) {
                 if (siblings) {
                     iter->next = NULL;
@@ -96,7 +96,7 @@
                 attr->parent->attr = attr->next;
             }
         } else {
-            for (iter = attr->parent->attr; iter->next != attr; iter = iter->next);
+            for (iter = attr->parent->attr; iter->next != attr; iter = iter->next) {}
             if (iter->next) {
                 if (siblings) {
                     iter->next = NULL;
@@ -233,7 +233,7 @@
 
     /* get the first (top-level) sibling */
     if (top) {
-        for (; node->parent; node = (struct lyd_node *)node->parent);
+        for (; node->parent; node = (struct lyd_node *)node->parent) {}
     }
     while (node->prev->next) {
         node = node->prev;
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index e3a090b..b113140 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -114,7 +114,7 @@
         return NULL;
     }
 
-    for (schema = node->schema; schema->parent; schema = schema->parent);
+    for (schema = node->schema; schema->parent; schema = schema->parent) {}
     return schema->module;
 }
 
diff --git a/src/tree_schema_compile.c b/src/tree_schema_compile.c
index da27d78..cde221b 100644
--- a/src/tree_schema_compile.c
+++ b/src/tree_schema_compile.c
@@ -243,7 +243,7 @@
     if (!name) {
         /* removing last path segment */
         if (ctx->path[ctx->path_len - 1] == '}') {
-            for (; ctx->path[ctx->path_len] != '=' && ctx->path[ctx->path_len] != '{'; --ctx->path_len);
+            for (; ctx->path[ctx->path_len] != '=' && ctx->path[ctx->path_len] != '{'; --ctx->path_len) {}
             if (ctx->path[ctx->path_len] == '=') {
                 ctx->path[ctx->path_len++] = '}';
             } else {
@@ -252,7 +252,7 @@
             }
         } else {
 remove_nodelevel:
-            for (; ctx->path[ctx->path_len] != '/' ; --ctx->path_len);
+            for (; ctx->path[ctx->path_len] != '/' ; --ctx->path_len) {}
             if (ctx->path_len == 0) {
                 /* top-level (last segment) */
                 ctx->path_len = 1;
@@ -559,7 +559,7 @@
     lysc_update_path(ctx, ext->parent_type == LYEXT_PAR_NODE ? (struct lysc_node*)ext->parent : NULL, "{extension}");
 
     /* get module where the extension definition should be placed */
-    for (u = strlen(ext_p->name); u && ext_p->name[u - 1] != ':'; --u);
+    for (u = strlen(ext_p->name); u && ext_p->name[u - 1] != ':'; --u) {}
     if (ext_p->yin) {
         /* YIN parser has to replace prefixes by the namespace - XML namespace/prefix pairs may differs form the YANG schema's
          * namespace/prefix pair. YIN parser does not have the imports available, so mapping from XML namespace to the
@@ -888,7 +888,7 @@
 lysc_xpath_context(struct lysc_node *start)
 {
     for (; start && !(start->nodetype & (LYS_CONTAINER | LYS_LEAF | LYS_LEAFLIST | LYS_LIST | LYS_ANYDATA | LYS_RPC | LYS_ACTION | LYS_NOTIF));
-            start = start->parent);
+            start = start->parent) {}
     return start;
 }
 
@@ -2364,7 +2364,7 @@
 
         if (basetype == LY_TYPE_BITS) {
             /* keep bits ordered by position */
-            for (v = u; v && (*enums)[v - 1].value > e->value; --v);
+            for (v = u; v && (*enums)[v - 1].value > e->value; --v) {}
             if (v != u) {
                 memcpy(&storage, e, sizeof *e);
                 memmove(&(*enums)[v + 1], &(*enums)[v], (u - v) * sizeof **enums);
@@ -4424,7 +4424,7 @@
          * here we gets the last created node as last children of our parent */
         if (target->nodetype == LYS_CASE) {
             /* the compiled node is the last child of the target (but it is a case, so we have to be careful and stop) */
-            for (node = (struct lysc_node*)lysc_node_children(target, flags); node->next && node->next->parent == node->parent; node = node->next);
+            for (node = (struct lysc_node*)lysc_node_children(target, flags); node->next && node->next->parent == node->parent; node = node->next) {}
         } else if (target->nodetype == LYS_CHOICE) {
             /* to pass when statement, we need the last case no matter if it is explicit or implicit case */
             node = ((struct lysc_node_choice*)target)->cases->prev;
@@ -6999,7 +6999,7 @@
 
     /* check config */
     if (lref->require_instance) {
-        for (siter = node->parent; siter && !(siter->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)); siter = siter->parent);
+        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);
@@ -7216,14 +7216,14 @@
         if (type->basetype == LY_TYPE_LEAFREF) {
             for (typeiter = ((struct lysc_type_leafref*)type)->realtype;
                     typeiter->basetype == LY_TYPE_LEAFREF;
-                    typeiter = ((struct lysc_type_leafref*)typeiter)->realtype);
+                    typeiter = ((struct lysc_type_leafref*)typeiter)->realtype) {}
             ((struct lysc_type_leafref*)type)->realtype = typeiter;
         } else if (type->basetype == LY_TYPE_UNION) {
             LY_ARRAY_FOR(((struct lysc_type_union*)type)->types, v) {
                 if (((struct lysc_type_union*)type)->types[v]->basetype == LY_TYPE_LEAFREF) {
                     for (typeiter = ((struct lysc_type_leafref*)((struct lysc_type_union*)type)->types[v])->realtype;
                             typeiter->basetype == LY_TYPE_LEAFREF;
-                            typeiter = ((struct lysc_type_leafref*)typeiter)->realtype);
+                            typeiter = ((struct lysc_type_leafref*)typeiter)->realtype) {}
                     ((struct lysc_type_leafref*)((struct lysc_type_union*)type)->types[v])->realtype = typeiter;
                 }
             }
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index 6eebbf5..5edbdd6 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -1643,7 +1643,7 @@
 {
     const struct lysc_node *parent;
 
-    for (parent = schema->parent; parent && (parent->nodetype & (LYS_CHOICE | LYS_CASE)); parent = parent->parent);
+    for (parent = schema->parent; parent && (parent->nodetype & (LYS_CHOICE | LYS_CASE)); parent = parent->parent) {}
 
     return parent;
 }
@@ -1655,7 +1655,7 @@
 
     assert(schema);
 
-    for (parent = schema->parent; parent && !(parent->nodetype & (LYS_RPC | LYS_ACTION)); parent = parent->parent);
+    for (parent = schema->parent; parent && !(parent->nodetype & (LYS_RPC | LYS_ACTION)); parent = parent->parent) {}
     if (parent && (schema->flags & LYS_CONFIG_R)) {
         return 1;
     }
diff --git a/src/validation.c b/src/validation.c
index b5e86d9..316946a 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -919,7 +919,7 @@
     }
 
     /* find first top-level node */
-    for (tree = node; tree->parent; tree = (struct lyd_node *)tree->parent);
+    for (tree = node; tree->parent; tree = (struct lyd_node *)tree->parent) {}
     while (tree->prev->next) {
         tree = tree->prev;
     }
diff --git a/src/xml.c b/src/xml.c
index e8e8894..8b83876 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -1094,7 +1094,7 @@
         if (is_xmlqnamestartchar(c)) {
             for (ly_getutf8(&stop, &c, &bytes);
                     is_xmlqnamechar(c) && (size_t)(stop - value) < value_len;
-                    ly_getutf8(&stop, &c, &bytes));
+                    ly_getutf8(&stop, &c, &bytes)) {}
             stop = stop - bytes;
             if (*stop == ':') {
                 /* we have a possible prefix */
diff --git a/src/xpath.c b/src/xpath.c
index 0a2f834..c1f043e 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -1285,7 +1285,7 @@
     if (*prev) {
         /* start from the previous element instead from the root */
         pos = *prev_pos;
-        for (top_sibling = *prev; top_sibling->parent; top_sibling = (struct lyd_node *)top_sibling->parent);
+        for (top_sibling = *prev; top_sibling->parent; top_sibling = (struct lyd_node *)top_sibling->parent) {}
         goto dfs_search;
     }
 
@@ -1594,8 +1594,8 @@
     }
 
     /* find first top-level node to be used as anchor for positions */
-    for (root = set->ctx_node; root->parent; root = (const struct lyd_node *)root->parent);
-    for (; root->prev->next; root = root->prev);
+    for (root = set->ctx_node; root->parent; root = (const struct lyd_node *)root->parent) {}
+    for (; root->prev->next; root = root->prev) {}
 
     /* fill positions */
     if (set_assign_pos(set, root, set->root_type)) {
@@ -1714,8 +1714,8 @@
     }
 
     /* find first top-level node to be used as anchor for positions */
-    for (root = trg->ctx_node; root->parent; root = (const struct lyd_node *)root->parent);
-    for (; root->prev->next; root = root->prev);
+    for (root = trg->ctx_node; root->parent; root = (const struct lyd_node *)root->parent) {}
+    for (; root->prev->next; root = root->prev) {}
 
     /* fill positions */
     if (set_assign_pos(trg, root, trg->root_type) || set_assign_pos(src, root, src->root_type)) {
@@ -1892,7 +1892,7 @@
     uint16_t i;
 
     if (exp->repeat[tok_idx]) {
-        for (i = 0; exp->repeat[tok_idx][i]; ++i);
+        for (i = 0; exp->repeat[tok_idx][i]; ++i) {}
         exp->repeat[tok_idx] = realloc(exp->repeat[tok_idx], (i + 2) * sizeof *exp->repeat[tok_idx]);
         LY_CHECK_ERR_RET(!exp->repeat[tok_idx], LOGMEM(NULL), );
         exp->repeat[tok_idx][i] = repeat_op_idx;
@@ -2754,7 +2754,7 @@
         } else if (expr[parsed] == '\'') {
 
             /* Literal with ' */
-            for (tok_len = 1; (expr[parsed + tok_len] != '\0') && (expr[parsed + tok_len] != '\''); ++tok_len);
+            for (tok_len = 1; (expr[parsed + tok_len] != '\0') && (expr[parsed + tok_len] != '\''); ++tok_len) {}
             LY_CHECK_ERR_GOTO(expr[parsed + tok_len] == '\0',
                               LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_EOE, expr[parsed], &expr[parsed]), error);
             ++tok_len;
@@ -2763,7 +2763,7 @@
         } else if (expr[parsed] == '\"') {
 
             /* Literal with " */
-            for (tok_len = 1; (expr[parsed + tok_len] != '\0') && (expr[parsed + tok_len] != '\"'); ++tok_len);
+            for (tok_len = 1; (expr[parsed + tok_len] != '\0') && (expr[parsed + tok_len] != '\"'); ++tok_len) {}
             LY_CHECK_ERR_GOTO(expr[parsed + tok_len] == '\0',
                               LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_XP_EOE, expr[parsed], &expr[parsed]), error);
             ++tok_len;
@@ -2772,10 +2772,10 @@
         } else if ((expr[parsed] == '.') || (isdigit(expr[parsed]))) {
 
             /* Number */
-            for (tok_len = 0; isdigit(expr[parsed + tok_len]); ++tok_len);
+            for (tok_len = 0; isdigit(expr[parsed + tok_len]); ++tok_len) {}
             if (expr[parsed + tok_len] == '.') {
                 ++tok_len;
-                for (; isdigit(expr[parsed + tok_len]); ++tok_len);
+                for (; isdigit(expr[parsed + tok_len]); ++tok_len) {}
             }
             tok_type = LYXP_TOKEN_NUMBER;
 
@@ -2955,7 +2955,7 @@
         if (!exp->repeat[i]) {
             dup->repeat[i] = NULL;
         } else {
-            for (j = 0; exp->repeat[i][j]; ++j);
+            for (j = 0; exp->repeat[i][j]; ++j) {}
             /* the ending 0 as well */
             ++j;
 
@@ -6839,7 +6839,7 @@
         if (scnode->flags & LYS_KEYLESS) {
             return LY_EINVAL;
         }
-        for (key_count = 0, key = lysc_node_children(scnode, 0); key && (key->flags & LYS_KEY); key = key->next, ++key_count);
+        for (key_count = 0, key = lysc_node_children(scnode, 0); key && (key->flags & LYS_KEY); key = key->next, ++key_count) {}
         assert(key_count);
 
         /* learn where the predicates end */
@@ -8215,13 +8215,13 @@
         next_etype = LYXP_EXPR_NONE;
     } else {
         /* find etype repeat */
-        for (i = 0; exp->repeat[*tok_idx][i] > etype; ++i);
+        for (i = 0; exp->repeat[*tok_idx][i] > etype; ++i) {}
 
         /* select one-priority lower because etype expression called us */
         if (i) {
             next_etype = exp->repeat[*tok_idx][i - 1];
             /* count repeats for that expression */
-            for (count = 0; i && exp->repeat[*tok_idx][i - 1] == next_etype; ++count, --i);
+            for (count = 0; i && exp->repeat[*tok_idx][i - 1] == next_etype; ++count, --i) {}
         } else {
             next_etype = LYXP_EXPR_NONE;
         }
@@ -8277,7 +8277,7 @@
     const struct lysc_node *op;
 
     if (options & LYXP_SCNODE_ALL) {
-        for (op = ctx_scnode; op && !(op->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)); op = op->parent);
+        for (op = ctx_scnode; op && !(op->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)); op = op->parent) {}
 
         if (op || (options & LYXP_SCNODE)) {
             /* general root that can access everything */
@@ -8290,7 +8290,7 @@
     }
 
     op = ctx_node ? ctx_node->schema : NULL;
-    for (; op && !(op->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)); op = op->parent);
+    for (; op && !(op->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)); op = op->parent) {}
 
     if (!ctx_node || (!op && (ctx_node->schema->flags & LYS_CONFIG_W))) {
         /* root context node can access only config data (because we said so, it is unspecified) */
@@ -8327,7 +8327,7 @@
     set->root_type = lyxp_get_root_type(real_ctx_node, NULL, options);
     for (set->context_op = ctx_node->schema;
          set->context_op && !(set->context_op->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF));
-         set->context_op = set->context_op->parent);
+         set->context_op = set->context_op->parent) {}
     set->local_mod = local_mod;
     set->tree = tree;
     set->format = format;
@@ -8598,7 +8598,7 @@
     set->root_type = lyxp_get_root_type(NULL, real_ctx_scnode, options);
     for (set->context_op = ctx_scnode;
          set->context_op && !(set->context_op->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF));
-         set->context_op = set->context_op->parent);
+         set->context_op = set->context_op->parent) {}
     set->local_mod = local_mod;
     set->format = format;