From a00d9d06b5021c27333e52e88b99493fa56d15a1 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 9 Mar 2021 13:41:44 +0100 Subject: 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 Signed-off-by: Phil Sutter --- src/set.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/set.c') diff --git a/src/set.c b/src/set.c index 021543e..1c29dd2 100644 --- a/src/set.c +++ b/src/set.c @@ -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; } -- cgit v1.2.3