* [nft] add default branch for code integrality
@ 2015-11-26 3:09 Linmujia
2015-11-26 10:34 ` Florian Westphal
0 siblings, 1 reply; 2+ messages in thread
From: Linmujia @ 2015-11-26 3:09 UTC (permalink / raw)
To: pablo@netfilter.org; +Cc: netfilter-devel@vger.kernel.org
Hi,I reviewed nftables code and add some default branch for code itegrality.
Thanks!
Signed-off-by: linmujia <linmujia@huawei.com>
---
src/netlink.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/netlink.c b/src/netlink.c
index 974afb1..c6dc2ed 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -307,6 +307,8 @@ static void netlink_gen_verdict(const struct expr *expr,
strncpy(data->chain, expr->chain, NFT_CHAIN_MAXNAMELEN);
data->chain[NFT_CHAIN_MAXNAMELEN-1] = '\0';
break;
+ default:
+ BUG("invalid verdict value %u\n", expr->verdict);
}
}
@@ -1670,6 +1672,8 @@ static uint32_t netlink_msg2nftnl_of(uint32_t msg)
case NFT_MSG_DELSETELEM:
case NFT_MSG_DELRULE:
return NFTNL_OF_EVENT_DEL;
+ default:
+ break;
}
return 0;
@@ -1741,6 +1745,8 @@ static int netlink_events_table_cb(const struct nlmsghdr *nlh, int type,
netlink_msg2nftnl_of(type));
fprintf(stdout, "\n");
break;
+ default:
+ break;
}
nftnl_table_free(nlt);
@@ -1778,14 +1784,17 @@ static int netlink_events_chain_cb(const struct nlmsghdr *nlh, int type,
nftnl_chain_get_str(nlc,
NFTNL_CHAIN_NAME));
break;
+ default:
+ break;
}
- break;
case NFTNL_OUTPUT_XML:
case NFTNL_OUTPUT_JSON:
nftnl_chain_fprintf(stdout, nlc, monh->format,
netlink_msg2nftnl_of(type));
fprintf(stdout, "\n");
break;
+ default:
+ break;
}
nftnl_chain_free(nlc);
@@ -1826,14 +1835,17 @@ static int netlink_events_set_cb(const struct nlmsghdr *nlh, int type,
nftnl_set_get_str(nls, NFTNL_SET_TABLE),
nftnl_set_get_str(nls, NFTNL_SET_NAME));
break;
+ default:
+ break;
}
- break;
case NFTNL_OUTPUT_XML:
case NFTNL_OUTPUT_JSON:
nftnl_set_fprintf(stdout, nls, monh->format,
netlink_msg2nftnl_of(type));
fprintf(stdout, "\n");
break;
+ default:
+ break;
}
out:
nftnl_set_free(nls);
@@ -1914,6 +1926,8 @@ static int netlink_events_setelem_cb(const struct nlmsghdr *nlh, int type,
netlink_msg2nftnl_of(type));
fprintf(stdout, "\n");
break;
+ default:
+ break;
}
out:
nftnl_set_free(nls);
@@ -1961,14 +1975,17 @@ static int netlink_events_rule_cb(const struct nlmsghdr *nlh, int type,
printf("delete rule %s %s %s handle %u\n",
family, table, chain, (unsigned int)handle);
break;
+ default:
+ break;
}
- break;
case NFTNL_OUTPUT_XML:
case NFTNL_OUTPUT_JSON:
nftnl_rule_fprintf(stdout, nlr, monh->format,
netlink_msg2nftnl_of(type));
fprintf(stdout, "\n");
break;
+ default:
+ break;
}
nftnl_rule_free(nlr);
@@ -2122,6 +2139,8 @@ static void netlink_events_cache_update(struct netlink_mon_handler *monh,
/* there are no notification for anon-set deletion */
netlink_events_cache_delsets(monh, nlh);
break;
+ default:
+ break;
}
}
@@ -2157,6 +2176,8 @@ static int netlink_events_cb(const struct nlmsghdr *nlh, void *data)
case NFT_MSG_DELRULE:
ret = netlink_events_rule_cb(nlh, type, monh);
break;
+ default:
+ break;
}
fflush(stdout);
--
2.5.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [nft] add default branch for code integrality
2015-11-26 3:09 [nft] add default branch for code integrality Linmujia
@ 2015-11-26 10:34 ` Florian Westphal
0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2015-11-26 10:34 UTC (permalink / raw)
To: Linmujia; +Cc: pablo@netfilter.org, netfilter-devel@vger.kernel.org
Linmujia <linmujia@huawei.com> wrote:
> @@ -1778,14 +1784,17 @@ static int netlink_events_chain_cb(const struct nlmsghdr *nlh, int type,
> nftnl_chain_get_str(nlc,
> NFTNL_CHAIN_NAME));
> break;
> + default:
> + break;
> }
> - break;
> case NFTNL_OUTPUT_XML:
That looks bogus. We would now fallthough to XML label?
Did you test this...?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-26 10:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-26 3:09 [nft] add default branch for code integrality Linmujia
2015-11-26 10:34 ` Florian Westphal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).