From 04017c97baf98039b0b5b5f7461a29bb36c88359 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 21 Apr 2020 10:16:55 +0200 Subject: [PATCH] Length of xml vector in many structs changed from to since it is a vector size, not byte size. This includes `transaction_data_t` --- CHANGELOG.md | 1 + apps/backend/backend_plugin.h | 6 +++--- example/main/example_backend.c | 2 +- lib/clixon/clixon_path.h | 8 ++++---- lib/clixon/clixon_xml.h | 6 +++--- lib/clixon/clixon_xml_map.h | 6 +++--- lib/clixon/clixon_xml_vec.h | 2 +- lib/clixon/clixon_xpath.h | 4 ++-- lib/clixon/clixon_xpath_ctx.h | 2 +- lib/clixon/clixon_xpath_optimize.h | 5 ++++- lib/src/clixon_instance_id_parse.y | 6 +----- lib/src/clixon_json_parse.h | 2 +- lib/src/clixon_nacm.c | 4 ++-- lib/src/clixon_path.c | 6 +++--- lib/src/clixon_xml.c | 16 +++++++++------- lib/src/clixon_xml_map.c | 12 ++++++------ lib/src/clixon_xml_parse.h | 2 +- lib/src/clixon_xml_vec.c | 2 +- lib/src/clixon_xpath.c | 4 ++-- lib/src/clixon_xpath_eval.c | 6 +++--- lib/src/clixon_xpath_optimize.c | 2 +- util/clixon_util_path.c | 2 +- util/clixon_util_xml_mod.c | 5 +++-- 23 files changed, 57 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec239b23..63a869cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ Expected: May 2020 ### C-API changes on existing features (you may need to change your plugin C-code) +* Length of xml vector in many structs changed from `size_t` to `int`since it is a vector size, not byte size. This includes `transaction_data_t` * `xml_merge()` changed to use 3-value return: 1:OK, 0:Yang failed, -1: Error * `clixon_netconf_error(category, xerr, msg, arg)` removed first argument -> `clixon_netconf_error(xerr, msg, arg)` * CLI diff --git a/apps/backend/backend_plugin.h b/apps/backend/backend_plugin.h index 270272c7..5aea3d12 100644 --- a/apps/backend/backend_plugin.h +++ b/apps/backend/backend_plugin.h @@ -56,12 +56,12 @@ typedef struct { cxobj *td_src; /* Source database xml tree */ cxobj *td_target; /* Target database xml tree */ cxobj **td_dvec; /* Delete xml vector */ - size_t td_dlen; /* Delete xml vector length */ + int td_dlen; /* Delete xml vector length */ cxobj **td_avec; /* Add xml vector */ - size_t td_alen; /* Add xml vector length */ + int td_alen; /* Add xml vector length */ cxobj **td_scvec; /* Source changed xml vector */ cxobj **td_tcvec; /* Target changed xml vector */ - size_t td_clen; /* Changed xml vector length */ + int td_clen; /* Changed xml vector length */ } transaction_data_t; /* diff --git a/example/main/example_backend.c b/example/main/example_backend.c index 9cbf5c9e..b32ded55 100644 --- a/example/main/example_backend.c +++ b/example/main/example_backend.c @@ -135,7 +135,7 @@ main_commit(clicon_handle h, cxobj *target = transaction_target(td); /* wanted XML tree */ cxobj **vec = NULL; int i; - size_t len; + int len; cvec *nsc = NULL; if (_transaction_log) diff --git a/lib/clixon/clixon_path.h b/lib/clixon/clixon_path.h index dd2c5ea0..69a7f798 100644 --- a/lib/clixon/clixon_path.h +++ b/lib/clixon/clixon_path.h @@ -85,13 +85,13 @@ int api_path2xml(char *api_path, yang_stmt *yspec, cxobj *xtop, cxobj **xpathp, yang_stmt **ypathp, cxobj **xerr); int xml2api_path_1(cxobj *x, cbuf *cb); #if defined(__GNUC__) && __GNUC__ >= 3 -int clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, cxobj ***xvec, size_t *xlen, char *format, +int clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, char *format, ...) __attribute__ ((format (printf, 5, 6)));; -int clixon_xml_find_instance_id(cxobj *xt, yang_stmt *yt, cxobj ***xvec, size_t *xlen, char *format, +int clixon_xml_find_instance_id(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, char *format, ...) __attribute__ ((format (printf, 5, 6)));; #else -int clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, clixon_xvec **xvec, char *format, ...); -int clixon_xml_find_instance_id(cxobj *xt, yang_stmt *yt, clixon_xvec **xvec, char *format, ...); +int clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, char *format, ...); +int clixon_xml_find_instance_id(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, char *format, ...); #endif #endif /* _CLIXON_PATH_H_ */ diff --git a/lib/clixon/clixon_xml.h b/lib/clixon/clixon_xml.h index c4769116..28fba1f6 100644 --- a/lib/clixon/clixon_xml.h +++ b/lib/clixon/clixon_xml.h @@ -226,9 +226,9 @@ int xml_copy_one(cxobj *xn0, cxobj *xn1); int xml_copy(cxobj *x0, cxobj *x1); cxobj *xml_dup(cxobj *x0); -int cxvec_dup(cxobj **vec0, size_t len0, cxobj ***vec1, size_t *len1); -int cxvec_append(cxobj *x, cxobj ***vec, size_t *len); -int cxvec_prepend(cxobj *x, cxobj ***vec, size_t *len); +int cxvec_dup(cxobj **vec0, int len0, cxobj ***vec1, int *len1); +int cxvec_append(cxobj *x, cxobj ***vec, int *len); +int cxvec_prepend(cxobj *x, cxobj ***vec, int *len); int xml_apply(cxobj *xn, enum cxobj_type type, xml_applyfn_t fn, void *arg); int xml_apply0(cxobj *xn, enum cxobj_type type, xml_applyfn_t fn, void *arg); int xml_apply_ancestor(cxobj *xn, xml_applyfn_t fn, void *arg); diff --git a/lib/clixon/clixon_xml_map.h b/lib/clixon/clixon_xml_map.h index 5aa19999..e4faa7a3 100644 --- a/lib/clixon/clixon_xml_map.h +++ b/lib/clixon/clixon_xml_map.h @@ -53,9 +53,9 @@ int xmlns_assign(cxobj *x); int xml2cvec(cxobj *xt, yang_stmt *ys, cvec **cvv0); int cvec2xml_1(cvec *cvv, char *toptag, cxobj *xp, cxobj **xt0); int xml_diff(yang_stmt *yspec, cxobj *x0, cxobj *x1, - cxobj ***first, size_t *firstlen, - cxobj ***second, size_t *secondlen, - cxobj ***changed_x0, cxobj ***changed_x1, size_t *changedlen); + cxobj ***first, int *firstlen, + cxobj ***second, int *secondlen, + cxobj ***changed_x0, cxobj ***changed_x1, int *changedlen); int xml_tree_prune_flagged_sub(cxobj *xt, int flag, int test, int *upmark); int xml_tree_prune_flagged(cxobj *xt, int flag, int test); int xml_namespace_change(cxobj *x, char *namespace, char *prefix); diff --git a/lib/clixon/clixon_xml_vec.h b/lib/clixon/clixon_xml_vec.h index 043b6bb1..92ecc477 100644 --- a/lib/clixon/clixon_xml_vec.h +++ b/lib/clixon/clixon_xml_vec.h @@ -51,7 +51,7 @@ clixon_xvec *clixon_xvec_dup(clixon_xvec *xv0); int clixon_xvec_free(clixon_xvec *xv); int clixon_xvec_len(clixon_xvec *xv); cxobj *clixon_xvec_i(clixon_xvec *xv, int i); -int clixon_xvec_extract(clixon_xvec *xv, cxobj ***xvec, size_t *xlen); +int clixon_xvec_extract(clixon_xvec *xv, cxobj ***xvec, int *xlen); int clixon_xvec_append(clixon_xvec *xv, cxobj *x); int clixon_xvec_prepend(clixon_xvec *xv, cxobj *x); int clixon_xvec_insert_pos(clixon_xvec *xv, cxobj *x, int i); diff --git a/lib/clixon/clixon_xpath.h b/lib/clixon/clixon_xpath.h index 6d4ad064..02594837 100644 --- a/lib/clixon/clixon_xpath.h +++ b/lib/clixon/clixon_xpath.h @@ -135,12 +135,12 @@ int xpath_vec_ctx(cxobj *xcur, cvec *nsc, char *xpath, int localonly, xp_ctx #if defined(__GNUC__) && __GNUC__ >= 3 int xpath_vec_bool(cxobj *xcur, cvec *nsc, char *xpformat, ...) __attribute__ ((format (printf, 3, 4))); int xpath_vec_flag(cxobj *xcur, cvec *nsc, char *xpformat, uint16_t flags, - cxobj ***vec, size_t *veclen, ...) __attribute__ ((format (printf, 3, 7))); + cxobj ***vec, int *veclen, ...) __attribute__ ((format (printf, 3, 7))); #else int xpath_vec_bool(cxobj *xcur, cvec *nsc, char *xpformat, ...); int xpath_vec_flag(cxobj *xcur, cvec *nsc, char *xpformat, uint16_t flags, - cxobj ***vec, size_t *veclen, ...); + cxobj ***vec, int *veclen, ...); #endif /* Functions with explicit namespace context (nsc) set. If you do not need diff --git a/lib/clixon/clixon_xpath_ctx.h b/lib/clixon/clixon_xpath_ctx.h index 3a2d2af4..eb1929c6 100644 --- a/lib/clixon/clixon_xpath_ctx.h +++ b/lib/clixon/clixon_xpath_ctx.h @@ -75,7 +75,7 @@ enum xp_objtype{ struct xp_ctx{ enum xp_objtype xc_type; cxobj **xc_nodeset; /* if type XT_NODESET */ - size_t xc_size; /* Length of nodeset */ + int xc_size; /* Length of nodeset */ int xc_bool; /* if xc_type XT_BOOL */ double xc_number; /* if xc_type XT_NUMBER */ char *xc_string; /* if xc_type XT_STRING */ diff --git a/lib/clixon/clixon_xpath_optimize.h b/lib/clixon/clixon_xpath_optimize.h index dc492905..adefe451 100644 --- a/lib/clixon/clixon_xpath_optimize.h +++ b/lib/clixon/clixon_xpath_optimize.h @@ -41,7 +41,10 @@ int xpath_list_optimize_stats(int *hits); int xpath_list_optimize_set(int enable); void xpath_optimize_exit(void); -//int xpath_optimize_check(xpath_tree *xs, cxobj *xv, cxobj ***xvec0, size_t *xlen0); +#if 0 /* XXX kludge for include file dependencies */ +int xpath_optimize_check(xpath_tree *xs, cxobj *xv, cxobj ***xvec0, int *xlen0); +#else int xpath_optimize_check(); +#endif #endif /* _CLIXON_XPATH_OPTIMIZE_H */ diff --git a/lib/src/clixon_instance_id_parse.y b/lib/src/clixon_instance_id_parse.y index 7f873f7c..6ec94595 100644 --- a/lib/src/clixon_instance_id_parse.y +++ b/lib/src/clixon_instance_id_parse.y @@ -225,11 +225,7 @@ keyval_pos(char *uint) goto done; } cv = cvec_i(cvv, 0); - if (cv_type_set(cv, CGV_UINT32) < 0){ - clicon_err(OE_UNIX, errno, "cv_type_set"); - cvv = NULL; - goto done; - } + cv_type_set(cv, CGV_UINT32); if ((ret = cv_parse1(uint, cv, &reason)) < 0){ clicon_err(OE_UNIX, errno, "cv_parse1"); cvv = NULL; diff --git a/lib/src/clixon_json_parse.h b/lib/src/clixon_json_parse.h index e0a37b40..0843c5b3 100644 --- a/lib/src/clixon_json_parse.h +++ b/lib/src/clixon_json_parse.h @@ -47,7 +47,7 @@ struct clixon_json_yacc { cxobj *jy_xtop; /* cxobj top element (fixed) */ cxobj *jy_current; /* cxobj active element (changes with parse context) */ cxobj **jy_xvec; /* Vector of created top-level nodes (to know which are created) */ - size_t jy_xlen; /* Length of jy_xvec */ + int jy_xlen; /* Length of jy_xvec */ }; typedef struct clixon_json_yacc clixon_json_yacc; diff --git a/lib/src/clixon_nacm.c b/lib/src/clixon_nacm.c index 01c6f863..4c70d5d9 100644 --- a/lib/src/clixon_nacm.c +++ b/lib/src/clixon_nacm.c @@ -344,7 +344,7 @@ nacm_datanode_prepare(clicon_handle h, cvec *nsc0 = NULL; /* Non-canonical namespace context */ yang_stmt *yspec; cxobj **xvec = NULL; - size_t xlen = 0; + int xlen = 0; int ret; yspec = clicon_dbspec_yang(h); @@ -422,7 +422,7 @@ nacm_datanode_prepare(clicon_handle h, if (ret == 0) continue; if (xlen > 1) - clicon_log(LOG_WARNING, "%s path:%s Clixon only supports single returns, this had: %lu", __FUNCTION__, path, xlen); + clicon_log(LOG_WARNING, "%s path:%s Clixon only supports single returns, this had: %d", __FUNCTION__, path, xlen); if (clixon_xvec_append(xpathvec, xvec?xvec[0]:NULL) < 0) /* XXX: vector of vectors? */ goto done; if (xvec){ diff --git a/lib/src/clixon_path.c b/lib/src/clixon_path.c index b2b4c341..3b226983 100644 --- a/lib/src/clixon_path.c +++ b/lib/src/clixon_path.c @@ -1507,7 +1507,7 @@ int clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, cxobj ***xvec, - size_t *xlen, + int *xlen, char *format, ...) { @@ -1584,7 +1584,7 @@ clixon_xml_find_api_path(cxobj *xt, * - Number of keys in key-value list does not match Yang list * @code * cxobj **vec = NULL; - * size_t len = 0; + * int len = 0; * if (clixon_xml_find_instance_id(x, yspec, &vec, &len, "/symbol/%s", "foo") < 0) * goto err; * for (i=0; ixs_c0; xp_ctx *xc = NULL; int ret; diff --git a/lib/src/clixon_xpath_optimize.c b/lib/src/clixon_xpath_optimize.c index d5231e9e..c641c433 100644 --- a/lib/src/clixon_xpath_optimize.c +++ b/lib/src/clixon_xpath_optimize.c @@ -321,7 +321,7 @@ int xpath_optimize_check(xpath_tree *xs, cxobj *xv, cxobj ***xvec0, - size_t *xlen0) + int *xlen0) { #ifdef XPATH_LIST_OPTIMIZE int ret; diff --git a/util/clixon_util_path.c b/util/clixon_util_path.c index 7aff8f01..85a24ea6 100644 --- a/util/clixon_util_path.c +++ b/util/clixon_util_path.c @@ -92,7 +92,7 @@ main(int argc, cxobj *x = NULL; cxobj *xc; cxobj **xvec = NULL; - size_t xlen = 0; + int xlen = 0; int c; int len; char *buf = NULL; diff --git a/util/clixon_util_xml_mod.c b/util/clixon_util_xml_mod.c index b2a07462..aeea2a96 100644 --- a/util/clixon_util_xml_mod.c +++ b/util/clixon_util_xml_mod.c @@ -69,6 +69,7 @@ #define UTIL_XML_MOD_OPTS "hD:o:y:b:x:p:s" enum opx{ + OPX_ERROR = -1, OPX_INSERT, OPX_MERGE, OPX_PARENT @@ -126,7 +127,7 @@ main(int argc, char **argv) int sort = 0; int ret; clicon_handle h; - enum opx opx = -1; + enum opx opx = OPX_ERROR; char *reason = NULL; clicon_log_init("clixon_insert", LOG_DEBUG, CLICON_LOG_STDERR); @@ -168,7 +169,7 @@ main(int argc, char **argv) /* Sanity check: check mandatory arguments */ if (x1str == NULL || x0str == NULL || yangfile == NULL) usage(argv0); - if (opx == -1) + if (opx == OPX_ERROR) usage(argv0); if ((yspec = yspec_new()) == NULL) goto done;