summaryrefslogtreecommitdiffstats
path: root/tests/monitor/testcases
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2025-07-09 00:51:24 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2025-07-10 00:13:04 +0200
commite0d92243be1cf1a485450a56d845e7bf2d1c6051 (patch)
treef4617c607751577a635ed4c9ce4a386c19bd8add /tests/monitor/testcases
parent01fdd7c7f445337c460738aa872cbdaabb5316ea (diff)
src: detach set, list and concatenation expression layout
These three expressions use the same layout, but they have a different purpose. Several fields are specific of a given expression: - set_flags is only required by set expressions. - field_len and field_count are only used by concatenation expressions. Add accessors to validate the expression type before accessing the union fields: #define expr_set(__expr) (assert((__expr)->etype == EXPR_SET), &(__expr)->expr_set) #define expr_concat(__expr) (assert((__expr)->etype == EXPR_CONCAT), &(__expr)->expr_concat) #define expr_list(__expr) (assert((__expr)->etype == EXPR_LIST), &(__expr)->expr_list) This should help catch subtle bugs due to type confusion. assert() could be later enabled only in debugging builds to run tests, keep it by now. compound_expr_*() still works and it needs the same initial layout for all of these expressions: struct list_head expressions; unsigned int size; This is implicitly reducing the size of one of the largest structs in the union area of struct expr, still EXPR_SET_ELEM remains the largest so no gain is achieved in this iteration. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests/monitor/testcases')
0 files changed, 0 insertions, 0 deletions