Skip to content

Commit cba757c

Browse files
committed
libyang UPDATE improved argument checks
1 parent 17e0bad commit cba757c

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

src/context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ LIBYANG_API_DECL LY_ERR ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct
660660
* Note that the data stored by user into the ::lysc_node.priv pointer are kept
661661
* untouched and the caller is responsible for freeing this private data.
662662
*
663-
* @param[in] ctx libyang context to destroy
663+
* @param[in] ctx Context to destroy.
664664
*/
665665
LIBYANG_API_DECL void ly_ctx_destroy(struct ly_ctx *ctx);
666666

src/plugins_exts.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ lyplg_ext_sprinter_ctree_add_ext_nodes(const struct lyspr_tree_ctx *ctx, struct
420420
uint32_t i;
421421
struct lysc_node *schema;
422422

423-
LY_CHECK_ARG_RET2(NULL, ctx, ext, LY_EINVAL);
423+
LY_CHECK_ARG_RET(NULL, ctx, ext, LY_EINVAL);
424424

425425
LY_ARRAY_FOR(ext->substmts, i) {
426426
switch (ext->substmts[i].stmt) {
@@ -458,7 +458,7 @@ lyplg_ext_sprinter_ptree_add_ext_nodes(const struct lyspr_tree_ctx *ctx, struct
458458
uint32_t i;
459459
struct lysp_node *schema;
460460

461-
LY_CHECK_ARG_RET2(NULL, ctx, ext, LY_EINVAL);
461+
LY_CHECK_ARG_RET(NULL, ctx, ext, LY_EINVAL);
462462

463463
LY_ARRAY_FOR(ext->substmts, i) {
464464
switch (ext->substmts[i].stmt) {
@@ -494,7 +494,7 @@ lyplg_ext_sprinter_ctree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysc
494494
{
495495
struct lyspr_tree_schema *new;
496496

497-
LY_CHECK_ARG_RET1(NULL, ctx, LY_EINVAL);
497+
LY_CHECK_ARG_RET(NULL, ctx, LY_EINVAL);
498498

499499
if (!nodes) {
500500
return LY_SUCCESS;
@@ -514,7 +514,7 @@ lyplg_ext_sprinter_ptree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysp
514514
{
515515
struct lyspr_tree_schema *new;
516516

517-
LY_CHECK_ARG_RET1(NULL, ctx, LY_EINVAL);
517+
LY_CHECK_ARG_RET(NULL, ctx, LY_EINVAL);
518518

519519
if (!nodes) {
520520
return LY_SUCCESS;
@@ -531,7 +531,7 @@ lyplg_ext_sprinter_ptree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysp
531531
LIBYANG_API_DECL LY_ERR
532532
lyplg_ext_sprinter_tree_set_priv(const struct lyspr_tree_ctx *ctx, void *plugin_priv, void (*free_clb)(void *plugin_priv))
533533
{
534-
LY_CHECK_ARG_RET1(NULL, ctx, LY_EINVAL);
534+
LY_CHECK_ARG_RET(NULL, ctx, LY_EINVAL);
535535

536536
((struct lyspr_tree_ctx *)ctx)->plugin_priv = plugin_priv;
537537
((struct lyspr_tree_ctx *)ctx)->free_plugin_priv = free_clb;
@@ -636,6 +636,8 @@ lyplg_ext_parsed_get_storage(const struct lysc_ext_instance *ext, int stmt, uint
636636
enum ly_stmt match = 0;
637637
void **s_p = NULL;
638638

639+
LY_CHECK_ARG_RET(NULL, ext, ext->module->parsed, LY_EINVAL);
640+
639641
/* find the parsed ext instance */
640642
LY_ARRAY_FOR(ext->module->parsed->exts, u) {
641643
extp = &ext->module->parsed->exts[u];

src/schema_features.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ lys_identity_iffeature_value(const struct lysc_ident *ident)
105105
const struct lysp_ident *idents_p, *found_ident = NULL;
106106
struct lysp_include *includes;
107107

108-
assert(ident);
108+
LY_CHECK_ARG_RET(NULL, ident, ident->module->parsed, LY_EINVAL);
109109

110110
/* Search parsed identity in the module. */
111111
idents_p = ident->module->parsed->identities;
@@ -146,6 +146,8 @@ lysp_feature_next(const struct lysp_feature *last, const struct lysp_module *pmo
146146
{
147147
struct lysp_feature *features;
148148

149+
LY_CHECK_ARG_RET(NULL, pmod, NULL);
150+
149151
if (!*idx) {
150152
/* module features */
151153
features = pmod->features;

src/tree_schema.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ lys_set_implemented(struct lys_module *mod, const char **features)
11791179
LY_ERR ret = LY_SUCCESS;
11801180
struct lys_glob_unres *unres = &mod->ctx->unres;
11811181

1182-
LY_CHECK_ARG_RET(NULL, mod, LY_EINVAL);
1182+
LY_CHECK_ARG_RET(NULL, mod, mod->parsed, LY_EINVAL);
11831183

11841184
/* implement */
11851185
ret = _lys_set_implemented(mod, features, unres);

0 commit comments

Comments
 (0)