From: Jan Engelhardt <jengelh@medozas.de>
To: kaber@trash.net
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 06/12] netfilter: xtables: untangle spaghetti if clauses in checkentry
Date: Thu, 25 Mar 2010 17:04:18 +0100 [thread overview]
Message-ID: <1269533065-22318-7-git-send-email-jengelh@medozas.de> (raw)
In-Reply-To: <1269533065-22318-1-git-send-email-jengelh@medozas.de>
As I'm changing the return values soon, I want to have a clear visual
path.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
net/netfilter/xt_dccp.c | 10 +++++++---
net/netfilter/xt_sctp.c | 20 ++++++++++++--------
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/net/netfilter/xt_dccp.c b/net/netfilter/xt_dccp.c
index 0989f29..8f6014f 100644
--- a/net/netfilter/xt_dccp.c
+++ b/net/netfilter/xt_dccp.c
@@ -127,9 +127,13 @@ static bool dccp_mt_check(const struct xt_mtchk_param *par)
{
const struct xt_dccp_info *info = par->matchinfo;
- return !(info->flags & ~XT_DCCP_VALID_FLAGS)
- && !(info->invflags & ~XT_DCCP_VALID_FLAGS)
- && !(info->invflags & ~info->flags);
+ if (info->flags & ~XT_DCCP_VALID_FLAGS)
+ return false;
+ if (info->invflags & ~XT_DCCP_VALID_FLAGS)
+ return false;
+ if (info->invflags & ~info->flags)
+ return false;
+ return true;
}
static struct xt_match dccp_mt_reg[] __read_mostly = {
diff --git a/net/netfilter/xt_sctp.c b/net/netfilter/xt_sctp.c
index 43c7e1d..977b182 100644
--- a/net/netfilter/xt_sctp.c
+++ b/net/netfilter/xt_sctp.c
@@ -148,14 +148,18 @@ static bool sctp_mt_check(const struct xt_mtchk_param *par)
{
const struct xt_sctp_info *info = par->matchinfo;
- return !(info->flags & ~XT_SCTP_VALID_FLAGS)
- && !(info->invflags & ~XT_SCTP_VALID_FLAGS)
- && !(info->invflags & ~info->flags)
- && ((!(info->flags & XT_SCTP_CHUNK_TYPES)) ||
- (info->chunk_match_type &
- (SCTP_CHUNK_MATCH_ALL
- | SCTP_CHUNK_MATCH_ANY
- | SCTP_CHUNK_MATCH_ONLY)));
+ if (info->flags & ~XT_SCTP_VALID_FLAGS)
+ return false;
+ if (info->invflags & ~XT_SCTP_VALID_FLAGS)
+ return false;
+ if (info->invflags & ~info->flags)
+ return false;
+ if (!(info->flags & XT_SCTP_CHUNK_TYPES))
+ return true;
+ if (info->chunk_match_type & (SCTP_CHUNK_MATCH_ALL |
+ SCTP_CHUNK_MATCH_ANY | SCTP_CHUNK_MATCH_ONLY))
+ return true;
+ return false;
}
static struct xt_match sctp_mt_reg[] __read_mostly = {
--
1.7.0.2
next prev parent reply other threads:[~2010-03-25 16:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-25 16:04 nf-next: error codes Jan Engelhardt
2010-03-25 16:04 ` [PATCH 01/12] netfilter: bridge: use NFPROTO values for NF_HOOK invocation Jan Engelhardt
2010-03-25 16:04 ` [PATCH 02/12] netfilter: ipv4: " Jan Engelhardt
2010-03-25 16:04 ` [PATCH 03/12] netfilter: ipv6: " Jan Engelhardt
2010-03-25 16:04 ` [PATCH 04/12] netfilter: decnet: " Jan Engelhardt
2010-03-25 16:04 ` [PATCH 05/12] netfilter: ipvs: " Jan Engelhardt
2010-03-25 16:04 ` Jan Engelhardt [this message]
2010-03-25 16:04 ` [PATCH 07/12] netfilter: xtables: change xt_match.checkentry return type Jan Engelhardt
2010-03-25 16:04 ` [PATCH 08/12] netfilter: xtables: change xt_target.checkentry " Jan Engelhardt
2010-03-25 16:04 ` [PATCH 09/12] netfilter: xtables: change matches to return error code Jan Engelhardt
2010-03-25 16:04 ` [PATCH 10/12] netfilter: xtables: change targets " Jan Engelhardt
2010-03-25 16:04 ` [PATCH 11/12] netfilter: xtables: slightly better error reporting Jan Engelhardt
2010-03-25 16:04 ` [PATCH 12/12] netfilter: xtables: shorten up return clause Jan Engelhardt
2010-03-31 6:00 ` nf-next: error codes Patrick McHardy
2010-03-31 6:07 ` nf-next: obsolete old extension revisions Jan Engelhardt
2010-03-31 6:38 ` Patrick McHardy
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=1269533065-22318-7-git-send-email-jengelh@medozas.de \
--to=jengelh@medozas.de \
--cc=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).