MAINTENANCE structure initiation
Use more compatible way of initiating structures to all zeros.
struct x var = {0};
is ok according to c99, but some compilers can complain about it, so
use memset() way of initiating variables.
diff --git a/src/parser/yin.c b/src/parser/yin.c
index 60a0564..be8b9d5 100644
--- a/src/parser/yin.c
+++ b/src/parser/yin.c
@@ -573,10 +573,13 @@
struct lyxml_elem *yin, struct ly_type *type)
{
const char *value, *delim;
- struct lyxml_elem *next, *node, root = {0};
+ struct lyxml_elem *next, *node, root;
int i, j, r;
int64_t v, v_;
+ /* init */
+ memset(&root, 0, sizeof root);
+
GETVAL(value, yin, "name")
delim = strchr(value, ':');
if (delim) {
@@ -1947,7 +1950,7 @@
struct ly_mnode *retval, *mnode;
struct ly_mnode_list *list;
struct ly_unique *uniq_s;
- struct lyxml_elem *sub, *next, root = {0}, uniq = {0};
+ struct lyxml_elem *sub, *next, root, uniq;
int i, r;
size_t len;
int c_tpdf = 0, c_must = 0, c_uniq = 0;
@@ -1956,6 +1959,10 @@
char *auxs;
unsigned long val;
+ /* init */
+ memset(&root, 0, sizeof root);
+ memset(&uniq, 0, sizeof uniq);
+
list = calloc(1, sizeof *list);
list->nodetype = LY_NODE_LIST;
list->prev = (struct ly_mnode *)list;
@@ -2236,7 +2243,7 @@
struct lyxml_elem *yin,
int resolve, struct mnode_list **unres)
{
- struct lyxml_elem *sub, *next, root = {0};
+ struct lyxml_elem *sub, *next, root;
struct ly_mnode *mnode = NULL;
struct ly_mnode *retval;
struct ly_mnode_container *cont;
@@ -2244,6 +2251,9 @@
int r;
int c_tpdf = 0, c_must = 0;
+ /* init */
+ memset(&root, 0, sizeof root);
+
cont = calloc(1, sizeof *cont);
cont->nodetype = LY_NODE_CONTAINER;
cont->prev = (struct ly_mnode *)cont;
@@ -2368,13 +2378,16 @@
struct lyxml_elem *node,
int resolve, struct mnode_list **unres)
{
- struct lyxml_elem *sub, *next, root = {0};
+ struct lyxml_elem *sub, *next, root;
struct ly_mnode *mnode = NULL;
struct ly_mnode *retval;
struct ly_mnode_grp *grp;
int r;
int c_tpdf = 0;
+ /* init */
+ memset(&root, 0, sizeof root);
+
grp = calloc(1, sizeof *grp);
grp->nodetype = LY_NODE_GROUPING;
grp->prev = (struct ly_mnode *)grp;
@@ -2470,13 +2483,16 @@
struct lyxml_elem *yin,
int resolve, struct mnode_list **unres)
{
- struct lyxml_elem *sub, *next, root = {0};
+ struct lyxml_elem *sub, *next, root;
struct ly_mnode *mnode = NULL;
struct ly_mnode *retval;
struct ly_mnode_input_output *inout;
int r;
int c_tpdf = 0;
+ /* init */
+ memset(&root, 0, sizeof root);
+
inout = calloc(1, sizeof *inout);
if (!strcmp(yin->name, "input")) {
@@ -2587,13 +2603,16 @@
struct lyxml_elem *yin,
int resolve, struct mnode_list **unres)
{
- struct lyxml_elem *sub, *next, root = {0};
+ struct lyxml_elem *sub, *next, root;
struct ly_mnode *mnode = NULL;
struct ly_mnode *retval;
struct ly_mnode_rpc *rpc;
int r;
int c_tpdf = 0;
+ /* init */
+ memset(&root, 0, sizeof root);
+
rpc = calloc(1, sizeof *rpc);
rpc->nodetype = LY_NODE_RPC;
rpc->prev = (struct ly_mnode *)rpc;
@@ -3088,7 +3107,7 @@
{
struct ly_ctx *ctx = module->ctx;
struct ly_submodule *submodule = (struct ly_submodule *)module;
- struct lyxml_elem *next, *node, *child, root = {0}, grps = {0}, rpcs = {0};
+ struct lyxml_elem *next, *node, *child, root, grps, rpcs;
struct ly_mnode *mnode = NULL;
struct mnode_list *unres = NULL, *unres_next; /* unresolved uses */
const char *value;
@@ -3097,6 +3116,11 @@
int i;
int belongsto_flag = 0;
+ /* init */
+ memset(&root, 0, sizeof root);
+ memset(&grps, 0, sizeof grps);
+ memset(&rpcs, 0, sizeof rpcs);
+
/*
* in the first run, we process elements with cardinality of 1 or 0..1 and
* count elements with cardinality 0..n. Data elements (choices, containers,