summaryrefslogtreecommitdiffstats
path: root/src/chain.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2013-07-21 15:26:02 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-07-21 15:33:56 +0200
commitcc9573dfa25585a415f6c12950758ce32f337294 (patch)
tree95471849b13a864f01be62e5961f087ab199022e /src/chain.c
parentd4faa02971e3924512f93e1d369bb134aa6d96b1 (diff)
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 <pablo@netfilter.org>
Diffstat (limited to 'src/chain.c')
-rw-r--r--src/chain.c21
1 files changed, 11 insertions, 10 deletions
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: