From cc9573dfa25585a415f6c12950758ce32f337294 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 21 Jul 2013 15:26:02 +0200 Subject: src: remove default case from nft_*_attr_unset This patch removes the default case in nft_*_attr_unset, thus, the compiler will spot a warning if we add a new attribute in the future and you forget to handle it. Signed-off-by: Pablo Neira Ayuso --- src/chain.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/chain.c') diff --git a/src/chain.c b/src/chain.c index 3fb1d03..4f9741a 100644 --- a/src/chain.c +++ b/src/chain.c @@ -77,23 +77,24 @@ EXPORT_SYMBOL(nft_chain_attr_is_set); void nft_chain_attr_unset(struct nft_chain *c, uint16_t attr) { + if (!(c->flags & (1 << attr))) + return; + switch (attr) { case NFT_CHAIN_ATTR_TABLE: - if (c->flags & (1 << NFT_CHAIN_ATTR_TABLE)) - if (c->table) { - free(c->table); - c->table = NULL; - } + if (c->table) { + free(c->table); + c->table = NULL; + } break; case NFT_CHAIN_ATTR_USE: /* cannot be unset?, ignore it */ return; case NFT_CHAIN_ATTR_TYPE: - if (c->flags & (1 << NFT_CHAIN_ATTR_TYPE)) - if (c->type) { - free(c->type); - c->type = NULL; - } + if (c->type) { + free(c->type); + c->type = NULL; + } break; case NFT_CHAIN_ATTR_NAME: case NFT_CHAIN_ATTR_HOOKNUM: -- cgit v1.2.3