This patch refactor code to parse the set in two functions nft_jansson_parse_set_info and nft_jansson_parse_set. Those changes is used in follow up patches. Signed-off-by: Alvaro Neira Ayuso <alvaroneay@xxxxxxxxx> --- src/set.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/set.c b/src/set.c index 61e0632..4fd786a 100644 --- a/src/set.c +++ b/src/set.c @@ -410,19 +410,15 @@ int nft_set_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_set *s) EXPORT_SYMBOL(nft_set_nlmsg_parse); #ifdef JSON_PARSING -int nft_jansson_parse_set(struct nft_set *s, json_t *tree, - struct nft_parse_err *err) +static int nft_jansson_parse_set_info(struct nft_set *s, json_t *tree, + struct nft_parse_err *err) { - json_t *root, *array, *json_elem; + json_t *root = tree, *array, *json_elem; uint32_t flags, key_type, key_len, data_type, data_len, policy, size; int family, i; const char *name, *table; struct nft_set_elem *elem; - root = nft_jansson_get_node(tree, "set", err); - if (root == NULL) - return -1; - name = nft_jansson_parse_str(root, "name", err); if (name == NULL) return -1; @@ -503,6 +499,18 @@ int nft_jansson_parse_set(struct nft_set *s, json_t *tree, return 0; } + +int nft_jansson_parse_set(struct nft_set *s, json_t *tree, + struct nft_parse_err *err) +{ + json_t *root; + + root = nft_jansson_get_node(tree, "set", err); + if (root == NULL) + return -1; + + return nft_jansson_parse_set_info(s, root, err); +} #endif static int nft_set_json_parse(struct nft_set *s, const void *json, -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html