All of lore.kernel.org
 help / color / mirror / Atom feed
* [nft PATCH 0/6] Eliminate variable declarations in switch cases
@ 2026-06-03 19:29 Phil Sutter
  2026-06-03 19:29 ` [nft PATCH 1/6] json: Introduce tunnel_obj_print_json() Phil Sutter
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Phil Sutter @ 2026-06-03 19:29 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

Older versions of gcc complain about it and there's no real need for it.

Since affected functions were pretty big due to the rather complex
tunnel object, move the tunnel-specific code into own functions in
patches 1, 2 and 4.

Patch 3 reduces duplicate code in obj_print_data() before patch 4 then
pulls out the tunnel-specific part, so this is a kind of soft dependency
there.

Remaining cases of variable declaration in switch cases are taken care
of by patch 5.

Finally, there is patch 6 which reduces code size by calling
nftnl_tunnel object getters unconditionally, leveraging the fact that
these return zero for unset attributes and thus don't change the
(zeroed) object in that case.

Phil Sutter (6):
  json: Introduce tunnel_obj_print_json()
  parser_json: Introduce json_parse_tunnel()
  rule: Turn obj_print_comment() into obj_print_header()
  rule: Introduce tunnel_obj_print_data()
  src: Avoid variable declarations in switch cases
  netlink: Call tunnel getters unconditionally

 src/json.c        | 115 +++++++++++---------
 src/mnl.c         |   3 +-
 src/netlink.c     | 117 ++++++++------------
 src/parser_json.c | 144 ++++++++++++------------
 src/rule.c        | 272 +++++++++++++++++++++-------------------------
 5 files changed, 307 insertions(+), 344 deletions(-)

-- 
2.54.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-06-26 11:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03 19:29 [nft PATCH 0/6] Eliminate variable declarations in switch cases Phil Sutter
2026-06-03 19:29 ` [nft PATCH 1/6] json: Introduce tunnel_obj_print_json() Phil Sutter
2026-06-03 19:29 ` [nft PATCH 2/6] parser_json: Introduce json_parse_tunnel() Phil Sutter
2026-06-03 19:29 ` [nft PATCH 3/6] rule: Turn obj_print_comment() into obj_print_header() Phil Sutter
2026-06-03 19:29 ` [nft PATCH 4/6] rule: Introduce tunnel_obj_print_data() Phil Sutter
2026-06-03 19:29 ` [nft PATCH 5/6] src: Avoid variable declarations in switch cases Phil Sutter
2026-06-03 19:29 ` [nft PATCH 6/6] netlink: Call tunnel getters unconditionally Phil Sutter
2026-06-26 11:53   ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.