netfilter: xtables: untangle spaghetti if clauses in checkentry
authorJan Engelhardt <jengelh@medozas.de>
Tue, 23 Mar 2010 16:40:13 +0000 (17:40 +0100)
committerJan Engelhardt <jengelh@medozas.de>
Thu, 25 Mar 2010 15:03:12 +0000 (16:03 +0100)
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
net/netfilter/xt_sctp.c

index 0989f29ade2ea0e559b53e7afac854a2bb09d54a..8f6014f7c8813b97ca638afb4aeb6f779b5a92bd 100644 (file)
@@ -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 = {
index 43c7e1de532c4c79521836ff7ce807a63d671bfd..977b182dea594ab34c983dafa3cc4ba16aa71520 100644 (file)
@@ -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 = {