From: Pablo Neira Ayuso Date: Tue, 30 Aug 2016 10:14:05 +0000 (+0200) Subject: expr: numgen: use switch to handle numgen types from snprintf X-Git-Tag: libnftnl-1.0.7~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53b83371349fbdc827db8d048eaabdc5306e2e6f;p=thirdparty%2Flibnftnl.git expr: numgen: use switch to handle numgen types from snprintf Use switch instead of if branch. Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/expr/numgen.c b/src/expr/numgen.c index 0981d72f..7be8270c 100644 --- a/src/expr/numgen.c +++ b/src/expr/numgen.c @@ -189,16 +189,17 @@ nftnl_expr_ng_snprintf_default(char *buf, size_t size, struct nftnl_expr_ng *ng = nftnl_expr_data(e); int len = size, offset = 0, ret; - if (ng->type == NFT_NG_INCREMENTAL) { + switch (ng->type) { + case NFT_NG_INCREMENTAL: ret = snprintf(buf, len, "reg %u = inc(%u)", ng->dreg, ng->until); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - } - - if (ng->type == NFT_NG_RANDOM) { + break; + case NFT_NG_RANDOM: ret = snprintf(buf, len, "reg %u = random(%u)", ng->dreg, ng->until); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); + break; } return offset;