Skip to content

lunatik: add lunatik_assert for internal state checks#509

Draft
lneto wants to merge 1 commit into
masterfrom
claude_assert
Draft

lunatik: add lunatik_assert for internal state checks#509
lneto wants to merge 1 commit into
masterfrom
claude_assert

Conversation

@lneto
Copy link
Copy Markdown
Contributor

@lneto lneto commented Mar 16, 2026

Replace luaL_argcheck(L, cond, 1, msg) used for internal object state checks with a new lunatik_assert(L, cond, msg) macro that calls luaL_error directly, avoiding the misleading "bad argument #1" prefix.

Applied to: skb not-set, FRAGLIST GSO, linearization failure, forward preconditions in luaskb; read-only check in luadata; module-load and softirq-context guards in luathread.

Replace luaL_argcheck(L, cond, 1, msg) used for internal object state
checks with a new lunatik_assert(L, cond, msg) macro that calls
luaL_error directly, avoiding the misleading "bad argument #1" prefix.

Applied to: skb not-set, FRAGLIST GSO, linearization failure, forward
preconditions in luaskb; read-only check in luadata; module-load and
softirq-context guards in luathread.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lneto lneto marked this pull request as draft March 17, 2026 12:05
Comment thread lib/luaskb.c
#define luaskb_checkfraglist(L, lskb, ix) \
luaL_argcheck(L, !(skb_shinfo((lskb)->skb)->gso_type & \
SKB_GSO_FRAGLIST), (ix), "FRAGLIST GSO skbs cannot be copied")
#define luaskb_checkfraglist(L, lskb) \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beacause of \ alingment?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it looks it is a space after ) , is it github thing?

Comment thread lunatik.h

#define lunatik_enomem(L) luaL_error((L), "not enough memory")

static inline void lunatik_assert(lua_State *L, bool cond, const char *msg)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's gonna work because of __no_return.. need to check.. however, I'm still in doubt of this new API.. problem I see with argcheck everywhere is the "bad self" error message.. but I'm not sure it's worth.. what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants