diff options
author | Phil Sutter <phil@nwl.cc> | 2021-03-09 13:41:44 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2021-03-15 12:23:23 +0100 |
commit | a00d9d06b5021c27333e52e88b99493fa56d15a1 (patch) | |
tree | a6fb17354e6669cdaefd12fa78d4c3592f944b63 /src/set.c | |
parent | 960c8e6174374ee113b290c304365bf02ed346d6 (diff) |
Get rid of single option switch statements
Replace each by a conditional testing the only valid case.
There is one odd example, namely src/set.c: When printing a set with
type NFTNL_OUTPUT_XML, the relevant function would return 0 instead of
-1 like all others. Just drop it assuming nothing depends on that
(faulty) behaviour.
Cc: Arturo Borrero <arturo.borrero.glez@gmail.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src/set.c')
-rw-r--r-- | src/set.c | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -843,22 +843,15 @@ static int nftnl_set_cmd_snprintf(char *buf, size_t remain, uint32_t inner_flags = flags; int ret, offset = 0; - if (type == NFTNL_OUTPUT_XML) - return 0; + if (type != NFTNL_OUTPUT_DEFAULT) + return -1; /* prevent set_elems to print as events */ inner_flags &= ~NFTNL_OF_EVENT_ANY; - switch(type) { - case NFTNL_OUTPUT_DEFAULT: - ret = nftnl_set_snprintf_default(buf + offset, remain, s, type, - inner_flags); - SNPRINTF_BUFFER_SIZE(ret, remain, offset); - break; - default: - return -1; - } - + ret = nftnl_set_snprintf_default(buf + offset, remain, s, type, + inner_flags); + SNPRINTF_BUFFER_SIZE(ret, remain, offset); return offset; } |