diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-08-06 11:16:02 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-08-06 11:44:23 +0200 |
commit | d4809085e24a66239d11f7269cfec24920c1642a (patch) | |
tree | d2aad792bb1b0a67a40ae6b0707fe27416437208 /src/table.c | |
parent | b58cf8947422ba695df80fe3b012b383fff22f7a (diff) |
src: xml: consolidate error path in table and chain objects
Remove a good bunch of LOC with this cleanup.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/table.c')
-rw-r--r-- | src/table.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/table.c b/src/table.c index bb66717..baad801 100644 --- a/src/table.c +++ b/src/table.c @@ -221,27 +221,20 @@ EXPORT_SYMBOL(nft_table_nlmsg_parse); static int nft_table_xml_parse(struct nft_table *t, char *xml) { #ifdef XML_PARSING - mxml_node_t *tree = NULL; + mxml_node_t *tree; const char *name; int family; - /* NOTE: all XML nodes are mandatory */ - - /* Load the tree */ tree = mxmlLoadString(NULL, xml, MXML_OPAQUE_CALLBACK); if (tree == NULL) return -1; - if (strcmp(tree->value.opaque, "table") != 0) { - mxmlDelete(tree); - return -1; - } + if (strcmp(tree->value.opaque, "table") != 0) + goto err; name = nft_mxml_str_parse(tree, "name", MXML_DESCEND_FIRST); - if (name == NULL) { - mxmlDelete(tree); - return -1; - } + if (name == NULL) + goto err; if (t->name) xfree(t->name); @@ -250,24 +243,23 @@ static int nft_table_xml_parse(struct nft_table *t, char *xml) t->flags |= (1 << NFT_TABLE_ATTR_NAME); family = nft_mxml_family_parse(tree, "family", MXML_DESCEND_FIRST); - if (family < 0) { - mxmlDelete(tree); - return -1; - } + if (family < 0) + goto err; t->family = family; t->flags |= (1 << NFT_TABLE_ATTR_FAMILY); if (nft_mxml_num_parse(tree, "table_flags", MXML_DESCEND, BASE_DEC, - &t->table_flags, NFT_TYPE_U32) != 0) { - mxmlDelete(tree); - return -1; - } + &t->table_flags, NFT_TYPE_U32) != 0) + goto err; t->flags |= (1 << NFT_TABLE_ATTR_FLAGS); mxmlDelete(tree); return 0; +err: + mxmlDelete(tree); + return -1; #else errno = EOPNOTSUPP; return -1; |