From 3a135363c9e73dd51535c58b65afd4be65a4be64 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Wed, 31 Jan 2024 21:03:25 +0100 Subject: xtables-eb: Eliminate 'opts' define It is more harm than good as it hides assignments to xt_params->opts field and does funny things if statements actually use xt_params->opts instead of the define. Replace it by local variables where sensible (cf. command_match() and command_jump() in xshared.c). Signed-off-by: Phil Sutter --- iptables/xtables-eb.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c index 250169c3..d197b37e 100644 --- a/iptables/xtables-eb.c +++ b/iptables/xtables-eb.c @@ -141,7 +141,6 @@ struct xtables_globals ebtables_globals = { .compat_rev = nft_compatible_revision, }; -#define opts ebtables_globals.opts #define prog_name ebtables_globals.program_name #define prog_vers ebtables_globals.program_version @@ -281,6 +280,7 @@ static int list_rules(struct nft_handle *h, const char *chain, const char *table /* This code is very similar to iptables/xtables.c:command_match() */ static void ebt_load_match(const char *name) { + struct option *opts = xt_params->opts; struct xtables_match *m; size_t size; @@ -305,10 +305,12 @@ static void ebt_load_match(const char *name) m->extra_opts, &m->option_offset); if (opts == NULL) xtables_error(OTHER_PROBLEM, "Can't alloc memory"); + xt_params->opts = opts; } static void ebt_load_watcher(const char *name) { + struct option *opts = xt_params->opts; struct xtables_target *watcher; size_t size; @@ -337,11 +339,12 @@ static void ebt_load_watcher(const char *name) &watcher->option_offset); if (opts == NULL) xtables_error(OTHER_PROBLEM, "Can't alloc memory"); + xt_params->opts = opts; } static void ebt_load_match_extensions(void) { - opts = ebt_original_options; + xt_params->opts = ebt_original_options; ebt_load_match("802_3"); ebt_load_match("arp"); ebt_load_match("ip"); @@ -358,7 +361,7 @@ static void ebt_load_match_extensions(void) /* assign them back so do_parse() may * reset opts to orig_opts upon each call */ - xt_params->orig_opts = opts; + xt_params->orig_opts = xt_params->opts; } void ebt_add_match(struct xtables_match *m, @@ -528,6 +531,7 @@ int nft_init_eb(struct nft_handle *h, const char *pname) void nft_fini_eb(struct nft_handle *h) { + struct option *opts = xt_params->opts; struct xtables_match *match; struct xtables_target *target; -- cgit v1.2.3