summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/regs.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/regs.c b/src/regs.c
index 8dd70b3..daedaba 100644
--- a/src/regs.c
+++ b/src/regs.c
@@ -84,9 +84,9 @@ static void nft_expr_reg_update(struct nftnl_regs *regs,
return expr->ops->reg.update(&regs->reg[i], expr);
}
-static int reg_space(int i)
+static int reg_space(const struct nftnl_regs *regs, int i)
{
- return sizeof(uint32_t) * 16 - sizeof(uint32_t) * i;
+ return sizeof(uint32_t) * regs->num_regs - sizeof(uint32_t) * i;
}
struct nftnl_reg_ctx {
@@ -98,7 +98,7 @@ struct nftnl_reg_ctx {
static void register_track(struct nftnl_reg_ctx *ctx,
const struct nftnl_regs *regs, int i, int len)
{
- if (ctx->reg >= 0 || regs->reg[i].word || reg_space(i) < len)
+ if (ctx->reg >= 0 || regs->reg[i].word || reg_space(regs, i) < len)
return;
if (regs->reg[i].type == NFT_EXPR_UNSPEC) {
@@ -183,7 +183,7 @@ uint32_t nftnl_reg_get(struct nftnl_regs *regs, const struct nftnl_expr *expr)
type = nftnl_expr_type(expr);
len = nftnl_expr_reg_len(expr);
- for (i = 0; i < 16; i++) {
+ for (i = 0; i < regs->num_regs; i++) {
register_track(&ctx, regs, i, len);
if (!nftnl_expr_reg_cmp(regs, expr, i))
@@ -215,7 +215,7 @@ uint32_t nftnl_reg_get_scratch(struct nftnl_regs *regs, uint32_t len)
};
int i;
- for (i = 0; i < 16; i++)
+ for (i = 0; i < regs->num_regs; i++)
register_track(&ctx, regs, i, len);
register_evict(&ctx);