summaryrefslogtreecommitdiffstats
path: root/src/chain.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2016-06-10 15:07:13 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-06-15 13:26:32 +0200
commit46b887ca6b0382d135599a83ed0884aeaf97a357 (patch)
tree7e252be40ff5ba4b7978bc19228714cfef33df4d /src/chain.c
parent5b8ae79fae3bc8be9663bd752c7ec466a95ac180 (diff)
src: simplify unsetters
If the attribute is set as we already check at the beginning of this function, then we can release the object. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/chain.c')
-rw-r--r--src/chain.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/chain.c b/src/chain.c
index f5433d6..516b553 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -119,18 +119,12 @@ void nftnl_chain_unset(struct nftnl_chain *c, uint16_t attr)
switch (attr) {
case NFTNL_CHAIN_TABLE:
- if (c->table) {
- xfree(c->table);
- c->table = NULL;
- }
+ xfree(c->table);
break;
case NFTNL_CHAIN_USE:
break;
case NFTNL_CHAIN_TYPE:
- if (c->type) {
- xfree(c->type);
- c->type = NULL;
- }
+ xfree(c->type);
break;
case NFTNL_CHAIN_NAME:
case NFTNL_CHAIN_HOOKNUM:
@@ -142,10 +136,7 @@ void nftnl_chain_unset(struct nftnl_chain *c, uint16_t attr)
case NFTNL_CHAIN_FAMILY:
break;
case NFTNL_CHAIN_DEV:
- if (c->dev) {
- xfree(c->dev);
- c->dev = NULL;
- }
+ xfree(c->dev);
break;
default:
return;