Skip to content

Commit 0c9a1d3

Browse files
committed
schema compile REFACTOR free context handling
1 parent a8e855b commit 0c9a1d3

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

src/parser_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ lyd_parser_notif_eventtime_validate(const struct lyd_node *node)
7070
{
7171
LY_ERR rc = LY_SUCCESS;
7272
struct ly_ctx *ctx = (struct ly_ctx *)LYD_CTX(node);
73-
struct lysc_ctx cctx;
73+
struct lysc_ctx cctx = {0};
7474
const struct lys_module *mod1, *mod2;
7575
const struct lysc_node *schema;
7676
LY_ARRAY_COUNT_TYPE u;

src/schema_compile.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ lys_identity_precompile(struct lysc_ctx *ctx_sc, struct ly_ctx *ctx, struct lysp
221221
const struct lysp_ident *identities_p, struct lysc_ident **identities)
222222
{
223223
LY_ARRAY_COUNT_TYPE u;
224-
struct lysc_ctx cctx;
224+
struct lysc_ctx cctx = {0};
225225
struct lysc_ident *ident;
226226
LY_ERR ret = LY_SUCCESS;
227227

@@ -1477,7 +1477,7 @@ lys_compile_unres_depset(struct ly_ctx *ctx, struct lys_glob_unres *unres)
14771477
}
14781478

14791479
cleanup:
1480-
lysf_ctx_erase(&cctx.free_ctx);
1480+
assert(!cctx.free_ctx.ext_set.count);
14811481
return ret;
14821482
}
14831483

@@ -1557,8 +1557,8 @@ lys_compile_depset_r(struct ly_ctx *ctx, struct ly_set *dep_set, struct lys_glob
15571557
}
15581558

15591559
cleanup:
1560+
assert(!fctx.ext_set.count);
15601561
lys_compile_unres_depset_erase(ctx, unres);
1561-
lysf_ctx_erase(&fctx);
15621562
return ret;
15631563
}
15641564

@@ -1702,7 +1702,7 @@ lys_compile_unres_mod_erase(struct lysc_ctx *ctx, ly_bool error)
17021702
LY_ERR
17031703
lys_compile(struct lys_module *mod, struct lys_depset_unres *unres)
17041704
{
1705-
struct lysc_ctx ctx;
1705+
struct lysc_ctx ctx = {0};
17061706
struct lysc_module *mod_c = NULL;
17071707
struct lysp_module *sp;
17081708
struct lysp_submodule *submod;
@@ -1823,7 +1823,7 @@ LY_ERR
18231823
lys_compile_identities(struct lys_module *mod)
18241824
{
18251825
LY_ERR rc = LY_SUCCESS;
1826-
struct lysc_ctx ctx;
1826+
struct lysc_ctx ctx = {0};
18271827
struct lysp_submodule *submod;
18281828
LY_ARRAY_COUNT_TYPE u;
18291829

src/schema_compile.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ struct lysc_ctx {
6767
* @param[in] CTX libyang context.
6868
*/
6969
#define LYSC_CTX_INIT_CTX(CCTX, CTX) \
70-
memset(&(CCTX), 0, sizeof (CCTX)); \
7170
(CCTX).ctx = (CTX); \
7271
(CCTX).path_len = 1; \
7372
(CCTX).path[0] = '/'; \
@@ -81,7 +80,6 @@ struct lysc_ctx {
8180
* @param[in] EXT Ancestor extension instance.
8281
*/
8382
#define LYSC_CTX_INIT_PMOD(CCTX, PMOD, EXT) \
84-
memset(&(CCTX), 0, sizeof (CCTX)); \
8583
(CCTX).ctx = (PMOD)->mod->ctx; \
8684
(CCTX).cur_mod = (PMOD)->mod; \
8785
(CCTX).pmod = (PMOD); \

src/schema_compile_amend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2443,7 +2443,7 @@ lys_precompile_mod_augments_deviations(struct lysp_module *pmod, struct ly_set *
24432443
{
24442444
LY_ERR ret = LY_SUCCESS;
24452445
LY_ARRAY_COUNT_TYPE u, v;
2446-
struct lysc_ctx ctx;
2446+
struct lysc_ctx ctx = {0};
24472447
struct lys_module *m;
24482448
struct lysp_node_augment *aug;
24492449
struct ly_set set = {0};

0 commit comments

Comments
 (0)