From 085e3300620806a7d9eed8a01cf5ff17a8ec85e4 Mon Sep 17 00:00:00 2001 From: James Carter Date: Thu, 13 Apr 2023 09:10:31 -0400 Subject: [PATCH] libsepol/cil: Add cil_list_is_empty macro Add a macro, called cil_list_is_empty, that returns true if the list pointer or list head is NULL. Signed-off-by: James Carter Reviewed-by: Daniel Burgener Acked-by: Petr Lautrbach --- libsepol/cil/src/cil_list.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libsepol/cil/src/cil_list.h b/libsepol/cil/src/cil_list.h index 6b4708a0..f974fddc 100644 --- a/libsepol/cil/src/cil_list.h +++ b/libsepol/cil/src/cil_list.h @@ -44,6 +44,9 @@ struct cil_list_item { void *data; }; +#define cil_list_is_empty(list) \ + ((list) == NULL || (list)->head == NULL) + #define cil_list_for_each(item, list) \ for (item = (list)->head; item != NULL; item = item->next)