libyang MAINTENANCE uninitializes variables in optimized code
Silent (probably false positive, but who knows with optimizations)
compiler's warnings (mostly) about uninitialized variables when being
compiled as Release build type.
diff --git a/src/parser_json.c b/src/parser_json.c
index f0cde12..79d58e1 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1096,7 +1096,7 @@
enum LYJSON_PARSER_STATUS *status, struct lyd_node **node)
{
LY_ERR ret;
- uint32_t type_hints;
+ uint32_t type_hints = 0;
uint32_t prev_opts;
struct lyd_node *tree = NULL;
@@ -1693,7 +1693,6 @@
struct lyd_json_ctx *lydctx = NULL;
struct lyd_node *rpc_e = NULL, *act_e = NULL;
struct lyd_node *tree = NULL;
- enum LYJSON_PARSER_STATUS status;
/* init */
ret = lyd_parse_json_init(ctx, in, LYD_PARSE_ONLY | LYD_PARSE_STRICT, 0, &lydctx);
@@ -1720,9 +1719,7 @@
}
parse_content:
-
- status = lyjson_ctx_status(lydctx->jsonctx, 0);
- assert(status == LYJSON_OBJECT);
+ assert(lyjson_ctx_status(lydctx->jsonctx, 0) == LYJSON_OBJECT);
/* read subtree(s) */
ret = lydjson_subtree_r(lydctx, act_e ? (struct lyd_node_inner *)act_e : (struct lyd_node_inner *)rpc_e, &tree);
diff --git a/src/path.c b/src/path.c
index 7086a97..a64e668 100644
--- a/src/path.c
+++ b/src/path.c
@@ -451,7 +451,7 @@
{
struct ly_path_predicate *p;
const struct lysc_node *key;
- const struct lys_module *mod;
+ const struct lys_module *mod = NULL;
const char *name;
size_t name_len, key_count;
@@ -725,7 +725,7 @@
{
LY_ERR ret = LY_SUCCESS;
uint16_t tok_idx = 0;
- const struct lys_module *mod;
+ const struct lys_module *mod = NULL;
const struct lysc_node *node2, *cur_node, *op;
struct ly_path *p = NULL;
uint32_t getnext_opts;
diff --git a/src/plugins_types.c b/src/plugins_types.c
index 8a7428e..fc7e0e1 100644
--- a/src/plugins_types.c
+++ b/src/plugins_types.c
@@ -791,7 +791,7 @@
{
LY_ERR ret;
uint64_t num;
- int base;
+ int base = 0;
struct lysc_type_num *type_num = (struct lysc_type_num *)type;
char *str;
@@ -1387,7 +1387,7 @@
const char *id_name, *prefix = value;
size_t id_len, prefix_len;
char *errmsg = NULL, *str;
- const struct lys_module *mod;
+ const struct lys_module *mod = NULL;
LY_ARRAY_COUNT_TYPE u;
struct lysc_ident *ident = NULL, *identities;
int rc = 0;
diff --git a/src/schema_compile_amend.c b/src/schema_compile_amend.c
index f84cdca..cb37fbd 100644
--- a/src/schema_compile_amend.c
+++ b/src/schema_compile_amend.c
@@ -135,8 +135,8 @@
{
uint32_t i;
const struct lys_module *mod1, *mod2;
- const char *name1, *name2;
- size_t name1_len, name2_len;
+ const char *name1 = NULL, *name2 = NULL;
+ size_t name1_len = 0, name2_len = 0;
if (exp1->used != exp2->used) {
return 0;
@@ -1510,8 +1510,8 @@
{
uint32_t i;
const struct lys_module *mod;
- const char *name;
- size_t name_len;
+ const char *name = NULL;
+ size_t name_len = 0;
/* compare last node in the node ID */
i = exp->used - 1;
diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c
index ccca636..a060aa1 100644
--- a/src/schema_compile_node.c
+++ b/src/schema_compile_node.c
@@ -451,7 +451,7 @@
{
LY_ERR ret = LY_SUCCESS;
char *valcopy = NULL;
- size_t len;
+ size_t len = 0;
if (value) {
ret = range_part_check_value_syntax(ctx, basetype, frdigits, *value, &len, &valcopy);
@@ -1157,8 +1157,8 @@
{
LY_ERR ret = LY_SUCCESS;
LY_ARRAY_COUNT_TYPE u, v, match = 0;
- int32_t value = 0, cur_val;
- uint32_t position = 0, cur_pos;
+ int32_t value = 0, cur_val = 0;
+ uint32_t position = 0, cur_pos = 0;
struct lysc_type_bitenum_item *e, storage;
ly_bool enabled;
@@ -2496,7 +2496,7 @@
LY_ERR ret = LY_EVALID;
const char *name, *prefix, *id;
size_t name_len, prefix_len;
- const struct lys_module *mod;
+ const struct lys_module *mod = NULL;
const char *nodeid_type;
uint32_t getnext_extra_flag = 0;
uint16_t current_nodetype = 0;
diff --git a/src/tree_data.c b/src/tree_data.c
index 8e348f6..7a9af79 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1145,7 +1145,7 @@
lyd_change_meta(struct lyd_meta *meta, const char *val_str)
{
LY_ERR ret = LY_SUCCESS;
- struct lyd_meta *m2;
+ struct lyd_meta *m2 = NULL;
struct lyd_value val;
ly_bool val_change;
@@ -1374,7 +1374,7 @@
{
LY_ERR ret;
const struct lysc_node *iter = NULL;
- struct lyd_node *node;
+ struct lyd_node *node = NULL;
struct lyd_value **dflts;
LY_ARRAY_COUNT_TYPE u;