[igt-dev] [PATCH i-g-t 3/7] igt_list: Add the igt_list_empty_or_null helper
Ryszard Knop
ryszard.knop at intel.com
Tue Jun 28 09:44:31 UTC 2022
Checks if the list is empty or uninitialized.
Signed-off-by: Ryszard Knop <ryszard.knop at intel.com>
---
lib/igt_list.c | 5 +++++
lib/igt_list.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/lib/igt_list.c b/lib/igt_list.c
index 37ae139c..dc94fad8 100644
--- a/lib/igt_list.c
+++ b/lib/igt_list.c
@@ -81,3 +81,8 @@ bool igt_list_empty(const struct igt_list_head *head)
{
return head->next == head;
}
+
+bool igt_list_empty_or_null(const struct igt_list_head *head)
+{
+ return head->next == NULL || head->prev == NULL || igt_list_empty(head);
+}
diff --git a/lib/igt_list.h b/lib/igt_list.h
index be63fd80..4efb7a22 100644
--- a/lib/igt_list.h
+++ b/lib/igt_list.h
@@ -80,6 +80,7 @@ void igt_list_move(struct igt_list_head *elem, struct igt_list_head *list);
void igt_list_move_tail(struct igt_list_head *elem, struct igt_list_head *list);
int igt_list_length(const struct igt_list_head *head);
bool igt_list_empty(const struct igt_list_head *head);
+bool igt_list_empty_or_null(const struct igt_list_head *head);
#define igt_container_of(ptr, sample, member) \
(__typeof__(sample))((char *)(ptr) - \
--
2.36.1
More information about the igt-dev
mailing list