iptables: Address -Werror=clobbered compilation errors.
PATCH 1/1 iptables: Address -Werror=clobbered compilation errors.
This addresses -Werror=clobbered compilation errors surfaced by GCC in 'prepare_target', 'parse_xt_modules', and 'final_check_xt_modules' when --enable-maintainer-mode is asserted, optimization is enabled (that is, --disable-optimization is not asserted), and connman is configured with --with-firewall=iptables:
src/iptables.c:2666:14: error: variable 'is_builtin' might be
clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
src/iptables.c:2666:26: error: variable 'is_user_defined' might be
clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
src/iptables.c:2667:16: error: variable 'chain_head' might be
clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
src/iptables.c:3070:36: error: variable 'rm' might be clobbered by
'longjmp' or 'vfork' [-Werror=clobbered]
src/iptables.c:3170:36: error: variable 'rm' might be clobbered by
'longjmp' or 'vfork' [-Werror=clobbered]
Each of these automatic variables is live across the 'setjmp' that guards the xtables calls, and C11 7.13.2.1 leaves non-volatile automatic objects indeterminate after 'longjmp' if they were modified after 'setjmp'. No current 'longjmp' return path reads them, so this is not a live defect; however, qualifying them 'volatile' is the idiomatic way to make that so by construction and quiets the diagnostic. The cost, a handful of extra loads and stores outside any hot path, is immaterial.
--- src/iptables.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
src/iptables.c +4 -4
@@ -2663,8 +2663,8 @@ static struct xtables_target *prepare_target(struct connman_iptables *table, const char *target_name) {struct xtables_target *xt_t =NULL ; -bool is_builtin, is_user_defined; -GList *chain_head =NULL ; +volatile bool is_builtin, is_user_defined; +GList *volatile chain_head =NULL ;size_t target_size;int err;
@@ -3067,7 +3067,7 @@ static int parse_xt_modules(int c, bool invert, struct parse_context *ctx) {struct xtables_match *m; -struct xtables_rule_match *rm; +struct xtables_rule_match *volatile rm;struct ipt_entry fw;struct ip6t_entry fw6;int err;
@@ -3167,7 +3167,7 @@ static int parse_xt_modules(int c, bool invert,static int final_check_xt_modules (struct parse_context *ctx) { -struct xtables_rule_match *rm; +struct xtables_rule_match *volatile rm;int err;for (rm = ctx->xt_rm; rm; rm = rm->next) {
Signature · 1 line
2.52.0