From 292c8ae660024b4dc33f754697ad0a6db2a864c7 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 28 Mar 2024 09:04:53 -0400 Subject: [PATCH] MT#55283 add a few more missing nft cleanups These don't actually do anything right now as these function don't do an early return, but having these in place will make things more future proof. Change-Id: I05b82a4366847e0eff1d1392885cf086516df053 --- daemon/nftables.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/daemon/nftables.c b/daemon/nftables.c index 7c9c1566e..978a0c047 100644 --- a/daemon/nftables.c +++ b/daemon/nftables.c @@ -438,7 +438,7 @@ static const char *input_immediate(struct nftnl_rule *r, int family, struct add_ if (err) return err; - struct nftnl_expr *e = nftnl_expr_alloc("immediate"); + g_autoptr(_nftnl_expr) e = nftnl_expr_alloc("immediate"); if (!e) return "failed to allocate immediate expr"; @@ -447,13 +447,14 @@ static const char *input_immediate(struct nftnl_rule *r, int family, struct add_ nftnl_expr_set_str(e, NFTNL_EXPR_IMM_CHAIN, callbacks->chain); nftnl_rule_add_expr(r, e); + e = NULL; return NULL; } static const char *rtpe_target_base(struct nftnl_rule *r, struct add_rule_callbacks *callbacks) { - struct nftnl_expr *e = nftnl_expr_alloc("target"); + g_autoptr(_nftnl_expr) e = nftnl_expr_alloc("target"); if (!e) return "failed to allocate target expr for RTPENGINE"; @@ -468,6 +469,7 @@ static const char *rtpe_target_base(struct nftnl_rule *r, struct add_rule_callba nftnl_expr_set(e, NFTNL_EXPR_TG_INFO, info, sizeof(*info)); nftnl_rule_add_expr(r, e); + e = NULL; return NULL; } @@ -480,10 +482,11 @@ static const char *rtpe_target(struct nftnl_rule *r, int family, struct add_rule if (err) return err; - struct nftnl_expr *e = nftnl_expr_alloc("counter"); + g_autoptr(_nftnl_expr) e = nftnl_expr_alloc("counter"); if (!e) return "failed to allocate counter expr for RTPENGINE"; nftnl_rule_add_expr(r, e); + e = NULL; return NULL; }