Skip to content

Commit e746a50

Browse files
committed
parser CHANGE LYD_OPT_NOAUTODEL flag allowed for operations too
1 parent a827ef6 commit e746a50

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/parser.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ lyp_is_rpc_action(struct lys_node *node)
217217
}
218218

219219
int
220-
lyp_check_options(int options, const char *func)
220+
lyp_data_check_options(int options, const char *func)
221221
{
222222
int x = options & LYD_OPT_TYPEMASK;
223223

224224
/* LYD_OPT_NOAUTODEL can be used only with LYD_OPT_DATA or LYD_OPT_CONFIG */
225225
if (options & LYD_OPT_NOAUTODEL) {
226-
if (x != LYD_OPT_DATA && x != LYD_OPT_CONFIG) {
226+
if ((x == LYD_OPT_EDIT) || (x == LYD_OPT_NOTIF_FILTER)) {
227227
LOGERR(LY_EINVAL, "%s: Invalid options 0x%x (LYD_OPT_DATA_NOAUTODEL can be used only with LYD_OPT_DATA or LYD_OPT_CONFIG)", func, options);
228228
return 1;
229229
}
@@ -1267,7 +1267,7 @@ make_canonical(struct ly_ctx *ctx, int type, const char **value, void *data1, vo
12671267
c = *((uint8_t *)data2);
12681268
if (num) {
12691269
count = sprintf(buf, "%"PRId64" ", num);
1270-
if ( (num > 0 && (count - 1) <= c)
1270+
if ( (num > 0 && (count - 1) <= c)
12711271
|| (count - 2) <= c ) {
12721272
/* we have 0. value, print the value with the leading zeros
12731273
* (one for 0. and also keep the correct with of num according

src/parser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ int dup_identities_check(const char *id, struct lys_module *module);
118118
int lyp_is_rpc_action(struct lys_node *node);
119119

120120
/**
121-
* @brief Check validity of parser options.
121+
* @brief Check validity of data parser options.
122122
*
123123
* @param options Parser options to be checked.
124124
* @param func name of the function where called
125125
* @return 0 for ok, 1 when multiple data types bits are set, or incompatible options are used together.
126126
*/
127-
int lyp_check_options(int options, const char *func);
127+
int lyp_data_check_options(int options, const char *func);
128128

129129
int lyp_check_identifier(const char *id, enum LY_IDENT type, struct lys_module *module, struct lys_node *parent);
130130
int lyp_check_date(const char *date);

src/parser_xml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ lyd_parse_xml(struct ly_ctx *ctx, struct lyxml_elem **root, int options, ...)
551551
return NULL;
552552
}
553553

554-
if (lyp_check_options(options, __func__)) {
554+
if (lyp_data_check_options(options, __func__)) {
555555
return NULL;
556556
}
557557

src/tree_data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ lyd_parse_data_(struct ly_ctx *ctx, const char *data, LYD_FORMAT format, int opt
449449
{
450450
const struct lyd_node *rpc_act = NULL, *data_tree = NULL, *iter;
451451

452-
if (lyp_check_options(options, __func__)) {
452+
if (lyp_data_check_options(options, __func__)) {
453453
return NULL;
454454
}
455455

@@ -4131,7 +4131,7 @@ lyd_validate(struct lyd_node **node, int options, void *var_arg)
41314131
return EXIT_FAILURE;
41324132
}
41334133

4134-
if (lyp_check_options(options, __func__)) {
4134+
if (lyp_data_check_options(options, __func__)) {
41354135
return EXIT_FAILURE;
41364136
}
41374137

0 commit comments

Comments
 (0)