]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
cache: do not set error code twice
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 12 Jan 2022 00:33:59 +0000 (01:33 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sat, 15 Jan 2022 17:15:23 +0000 (18:15 +0100)
The 'ret' variable is already set to a negative value to report an
error, do not set it again to a negative value.

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

index 6ca6bbc6645b6557edb9e6a1bb8ef0033a8c28fd..0e9e7fe5381d58ac7f7980d3ebb423b3bc762671 100644 (file)
@@ -847,10 +847,8 @@ static int cache_init_objects(struct netlink_ctx *ctx, unsigned int flags,
        list_for_each_entry(table, &ctx->nft->cache.table_cache.list, cache.list) {
                if (flags & NFT_CACHE_SET_BIT) {
                        ret = set_cache_init(ctx, table, set_list);
-                       if (ret < 0) {
-                               ret = -1;
+                       if (ret < 0)
                                goto cache_fails;
-                       }
                }
                if (flags & NFT_CACHE_SETELEM_BIT) {
                        list_for_each_entry(set, &table->set_cache.list, cache.list) {
@@ -862,10 +860,8 @@ static int cache_init_objects(struct netlink_ctx *ctx, unsigned int flags,
 
                                ret = netlink_list_setelems(ctx, &set->handle,
                                                            set);
-                               if (ret < 0) {
-                                       ret = -1;
+                               if (ret < 0)
                                        goto cache_fails;
-                               }
                        }
                } else if (flags & NFT_CACHE_SETELEM_MAYBE) {
                        list_for_each_entry(set, &table->set_cache.list, cache.list) {
@@ -877,25 +873,19 @@ static int cache_init_objects(struct netlink_ctx *ctx, unsigned int flags,
 
                                ret = netlink_list_setelems(ctx, &set->handle,
                                                            set);
-                               if (ret < 0) {
-                                       ret = -1;
+                               if (ret < 0)
                                        goto cache_fails;
-                               }
                        }
                }
                if (flags & NFT_CACHE_CHAIN_BIT) {
                        ret = chain_cache_init(ctx, table, chain_list);
-                       if (ret < 0) {
-                               ret = -1;
+                       if (ret < 0)
                                goto cache_fails;
-                       }
                }
                if (flags & NFT_CACHE_FLOWTABLE_BIT) {
                        ret = ft_cache_init(ctx, table, ft_list);
-                       if (ret < 0) {
-                               ret = -1;
+                       if (ret < 0)
                                goto cache_fails;
-                       }
                }
                if (flags & NFT_CACHE_OBJECT_BIT) {
                        obj_list = obj_cache_dump(ctx, table);
@@ -907,10 +897,8 @@ static int cache_init_objects(struct netlink_ctx *ctx, unsigned int flags,
 
                        nftnl_obj_list_free(obj_list);
 
-                       if (ret < 0) {
-                               ret = -1;
+                       if (ret < 0)
                                goto cache_fails;
-                       }
                }
 
                if (flags & NFT_CACHE_RULE_BIT) {
@@ -927,10 +915,8 @@ static int cache_init_objects(struct netlink_ctx *ctx, unsigned int flags,
 
                                list_move_tail(&rule->list, &chain->rules);
                        }
-                       if (ret < 0) {
-                               ret = -1;
+                       if (ret < 0)
                                goto cache_fails;
-                       }
                }
        }