From 46b887ca6b0382d135599a83ed0884aeaf97a357 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 10 Jun 2016 15:07:13 +0200 Subject: 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 --- src/set.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/set.c') diff --git a/src/set.c b/src/set.c index c23c378..46a0007 100644 --- a/src/set.c +++ b/src/set.c @@ -65,20 +65,15 @@ EXPORT_SYMBOL_ALIAS(nftnl_set_is_set, nft_set_attr_is_set); void nftnl_set_unset(struct nftnl_set *s, uint16_t attr) { + if (!(s->flags & (1 << attr))) + return; + switch (attr) { case NFTNL_SET_TABLE: - if (s->flags & (1 << NFTNL_SET_TABLE)) - if (s->table) { - xfree(s->table); - s->table = NULL; - } + xfree(s->table); break; case NFTNL_SET_NAME: - if (s->flags & (1 << NFTNL_SET_NAME)) - if (s->name) { - xfree(s->name); - s->name = NULL; - } + xfree(s->name); break; case NFTNL_SET_FLAGS: case NFTNL_SET_KEY_TYPE: -- cgit v1.2.3