ipe: check parser token table sizes

The parser token tables contain one entry for each enum value followed
by a terminator. Add static assertions so adding an enum value without a
corresponding token fails the build.

Assisted-by: LLM
Signed-off-by: Fan Wu <wufan@kernel.org>
This commit is contained in:
Fan Wu 2026-10-02 19:51:32 -07:00
parent e4933dbcb7
commit 6adc404a98

View File

@ -128,6 +128,8 @@ static const match_table_t header_tokens = {
{__IPE_HEADER_MAX, NULL}
};
static_assert(ARRAY_SIZE(header_tokens) == __IPE_HEADER_MAX + 1);
/**
* parse_header() - Parse policy header information.
* @line: Supplies header line to be parsed.
@ -240,6 +242,8 @@ static const match_table_t operation_tokens = {
{IPE_OP_INVALID, NULL}
};
static_assert(ARRAY_SIZE(operation_tokens) == __IPE_OP_MAX + 1);
/**
* parse_operation() - Parse the operation type given a token string.
* @t: Supplies the token string to be parsed.
@ -259,6 +263,8 @@ static const match_table_t action_tokens = {
{IPE_ACTION_INVALID, NULL}
};
static_assert(ARRAY_SIZE(action_tokens) == __IPE_ACTION_MAX + 1);
/**
* parse_action() - Parse the action type given a token string.
* @t: Supplies the token string to be parsed.
@ -284,6 +290,8 @@ static const match_table_t property_tokens = {
{IPE_PROP_INVALID, NULL}
};
static_assert(ARRAY_SIZE(property_tokens) == __IPE_PROP_MAX + 1);
/**
* parse_property() - Parse a rule property given a token string.
* @t: Supplies the token string to be parsed.