unit-tests: Fix compiler warning with empty message assertion

The empty array of rules for `assert_message_empty()` and the resulting
size 0 triggers warnings like these:

  allocation of insufficient size '0' for type 'listener_message_rule_t' with size '12'

Using calloc() with `nmemb` set to 0 triggers the same warning.
This commit is contained in:
Tobias Brunner 2024-07-15 16:55:29 +02:00
parent 6eec5cc07d
commit 0602ed1043

View File

@ -357,7 +357,7 @@ bool exchange_test_asserts_message(listener_t *this, ike_sa_t *ike_sa,
.line = __LINE__, \
.incoming = streq(dir, "IN") ? TRUE : FALSE, \
.count = c, \
.rules = malloc(sizeof(_rules)), \
.rules = sizeof(_rules) ? malloc(sizeof(_rules)) : NULL, \
.num_rules = countof(_rules), \
); \
memcpy(_listener->rules, _rules, sizeof(_rules)); \