MAC/do: toast_rules(): Minor simplification

Use the most common pattern to browse and delete elements of a list, as it reads quicker.

Reviewed by:    bapt
Approved by:    markj (mentor)
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D47622

(cherry picked from commit 2110eef4bf)
This commit is contained in:
Olivier Certner 2024-08-13 10:53:24 +02:00
parent 68c46c41a7
commit 5e00a28b2f
No known key found for this signature in database
GPG key ID: 8CA13040971E2627

View file

@ -311,10 +311,9 @@ static void
toast_rules(struct rules *const rules)
{
struct rulehead *const head = &rules->head;
struct rule *rule;
struct rule *rule, *rule_next;
while ((rule = TAILQ_FIRST(head)) != NULL) {
TAILQ_REMOVE(head, rule, r_entries);
TAILQ_FOREACH_SAFE(rule, head, r_entries, rule_next) {
free(rule->uids, M_DO);
free(rule->gids, M_DO);
free(rule, M_DO);