summaryrefslogtreecommitdiffstats
path: root/src/table.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2013-07-18 20:01:27 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-07-18 20:08:25 +0200
commit6cdc49ffbe0a672c27f4fffe831563b12a8e2e61 (patch)
tree76e1b5318bfdd9627f8ab5138293cbe569c25da4 /src/table.c
parent5ecac519cd78043d0a5bfead1922a683d32db9d2 (diff)
src: simplify getter logic
This patch refactors the getter code to simplify it. The default cases have been removed so gcc will spot a warning if an attribute is not handled appropriately. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/table.c')
-rw-r--r--src/table.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/table.c b/src/table.c
index bdab178..e1dbd38 100644
--- a/src/table.c
+++ b/src/table.c
@@ -1,5 +1,5 @@
/*
- * (C) 2012 by Pablo Neira Ayuso <pablo@netfilter.org>
+ * (C) 2012-2013 by Pablo Neira Ayuso <pablo@netfilter.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
@@ -112,23 +112,18 @@ EXPORT_SYMBOL(nft_table_attr_set_str);
const void *nft_table_attr_get(struct nft_table *t, uint16_t attr)
{
- const void *ret = NULL;
+ if (!(t->flags & (1 << attr)))
+ return NULL;
switch(attr) {
case NFT_TABLE_ATTR_NAME:
- if (t->flags & (1 << NFT_TABLE_ATTR_NAME))
- ret = t->name;
- break;
+ return t->name;
case NFT_TABLE_ATTR_FLAGS:
- if (t->flags & (1 << NFT_TABLE_ATTR_FLAGS))
- ret = &t->table_flags;
- break;
+ return &t->table_flags;
case NFT_TABLE_ATTR_FAMILY:
- if (t->flags & (1 << NFT_TABLE_ATTR_FAMILY))
- ret = &t->family;
- break;
+ return &t->family;
}
- return ret;
+ return NULL;
}
EXPORT_SYMBOL(nft_table_attr_get);