All of lore.kernel.org
 help / color / mirror / Atom feed
* [Question] Dead code in xt_register_matches/targets()?
@ 2026-01-31 14:55 Ingyu Jang
  2026-01-31 17:33 ` Jan Engelhardt
  2026-01-31 21:34 ` Florian Westphal
  0 siblings, 2 replies; 3+ messages in thread
From: Ingyu Jang @ 2026-01-31 14:55 UTC (permalink / raw)
  To: netfilter-devel; +Cc: pablo, fw, phil, Ingyu Jang

Hi,

I noticed that in net/netfilter/x_tables.c, the functions
xt_register_match() and xt_register_target() always return 0.

Both functions simply perform:
  - mutex_lock()
  - list_add()
  - mutex_unlock()
  - return 0

However, xt_register_matches() and xt_register_targets() check
the return values and have error handling paths:

  for (i = 0; i < n; i++) {
      err = xt_register_match(&match[i]);
      if (err)
          goto err;
  }

Since xt_register_match/target() never fail, these error checks
appear to be dead code.

I found multiple callers that check these return values:
  - net/netfilter/xt_set.c
  - net/netfilter/xt_MASQUERADE.c
  - and others

Is this intentional defensive coding for potential future changes,
or could this be cleaned up by making xt_register_match/target()
return void?

Thanks,
Ingyu Jang

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

end of thread, other threads:[~2026-01-31 21:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-31 14:55 [Question] Dead code in xt_register_matches/targets()? Ingyu Jang
2026-01-31 17:33 ` Jan Engelhardt
2026-01-31 21:34 ` Florian Westphal

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.