]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
expr: numgen: use switch to handle numgen types from snprintf
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 30 Aug 2016 10:14:05 +0000 (12:14 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 30 Aug 2016 10:16:13 +0000 (12:16 +0200)
Use switch instead of if branch.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/expr/numgen.c

index 0981d72fd61b4796410ff652354f2ec90827c6a0..7be8270c5912fffb1ae2896ad1809b6c7631c69b 100644 (file)
@@ -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;