All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Ingyu Jang <ingyujang25@korea.ac.kr>
Cc: netfilter-devel@vger.kernel.org, pablo@netfilter.org, phil@nwl.cc
Subject: Re: [Question] Dead code in xt_register_matches/targets()?
Date: Sat, 31 Jan 2026 22:34:34 +0100	[thread overview]
Message-ID: <aX51asLGZ8ojgrrW@strlen.de> (raw)
In-Reply-To: <20260131145516.3289625-1-ingyujang25@korea.ac.kr>

Ingyu Jang <ingyujang25@korea.ac.kr> wrote:
> 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,

No, leftover.  It could be cleaned up but I would prefer to keep it
as-is, x_tables is in maintenance mode.

      parent reply	other threads:[~2026-01-31 21:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aX51asLGZ8ojgrrW@strlen.de \
    --to=fw@strlen.de \
    --cc=ingyujang25@korea.ac.kr \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.