uncrustify FORMAT set various uncrustify options
PR #1228
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;