netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft] src: fix always-true assertions
Date: Tue, 26 Apr 2022 12:29:35 +0200	[thread overview]
Message-ID: <20220426102935.14950-1-fw@strlen.de> (raw)

assert(1) is a no-op, this should be assert(0). Use BUG() instead.
Add missing CATCHALL to avoid BUG().

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 src/evaluate.c  | 2 +-
 src/intervals.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/evaluate.c b/src/evaluate.c
index b5f74d2f5051..1447a4c28aee 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -1499,7 +1499,7 @@ static int interval_set_eval(struct eval_ctx *ctx, struct set *set,
 	case CMD_GET:
 		break;
 	default:
-		assert(1);
+		BUG("unhandled op %d\n", ctx->cmd->op);
 		break;
 	}
 
diff --git a/src/intervals.c b/src/intervals.c
index a74238525d8d..85ec59eda36a 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -20,6 +20,7 @@ static void setelem_expr_to_range(struct expr *expr)
 	assert(expr->etype == EXPR_SET_ELEM);
 
 	switch (expr->key->etype) {
+	case EXPR_SET_ELEM_CATCHALL:
 	case EXPR_RANGE:
 		break;
 	case EXPR_PREFIX:
@@ -53,7 +54,7 @@ static void setelem_expr_to_range(struct expr *expr)
 		expr->key = key;
 		break;
 	default:
-		assert(1);
+		BUG("unhandled key type %d\n", expr->key->etype);
 	}
 }
 
@@ -185,7 +186,7 @@ static struct expr *interval_expr_key(struct expr *i)
 		elem = i;
 		break;
 	default:
-		assert(1);
+		BUG("unhandled expression type %d\n", i->etype);
 		return NULL;
 	}
 
-- 
2.35.1


             reply	other threads:[~2022-04-26 10:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26 10:29 Florian Westphal [this message]
2022-04-26 10:45 ` [PATCH nft] src: fix always-true assertions Pablo Neira Ayuso
2022-04-26 11:22   ` Florian Westphal

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=20220426102935.14950-1-fw@strlen.de \
    --to=fw@strlen.de \
    --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).