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_elem.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src/set_elem.c') diff --git a/src/set_elem.c b/src/set_elem.c index a1764e2..90632a2 100644 --- a/src/set_elem.c +++ b/src/set_elem.c @@ -757,19 +757,12 @@ static int nftnl_set_elem_cmd_snprintf(char *buf, size_t remain, { int ret, offset = 0; - switch(type) { - case NFTNL_OUTPUT_DEFAULT: - ret = nftnl_set_elem_snprintf_default(buf + offset, remain, e, - NFT_DATA_VALUE); - SNPRINTF_BUFFER_SIZE(ret, remain, offset); - break; - case NFTNL_OUTPUT_XML: - case NFTNL_OUTPUT_JSON: - break; - default: + if (type != NFTNL_OUTPUT_DEFAULT) return -1; - } + ret = nftnl_set_elem_snprintf_default(buf + offset, remain, e, + NFT_DATA_VALUE); + SNPRINTF_BUFFER_SIZE(ret, remain, offset); return offset; } -- cgit v1.2.3