From 07e6ebd3cc0ca08fba936c6547726ce6dbbaa166 Mon Sep 17 00:00:00 2001 From: apio Date: Tue, 6 Dec 2022 18:22:45 +0100 Subject: [PATCH] LinkedList: Fix nonnull_or_error --- luna/include/luna/LinkedList.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/luna/include/luna/LinkedList.h b/luna/include/luna/LinkedList.h index c4ab8f58..081dec8e 100644 --- a/luna/include/luna/LinkedList.h +++ b/luna/include/luna/LinkedList.h @@ -3,7 +3,9 @@ template inline Result nonnull_or_error(T* ptr) { - return ptr == nullptr ? err(ENONE) : ptr; + if (ptr == nullptr) return err(ENONE); + else + return ptr; } template class DoublyLinkedList; @@ -69,12 +71,12 @@ template class DoublyLinkedList Result next(T* item) { - return nonnull_or_error(((DoublyLinkedListNode*)item)->m_next_node); + return nonnull_or_error((T*)((DoublyLinkedListNode*)item)->m_next_node); } Result previous(T* item) { - return nonnull_or_error(((DoublyLinkedListNode*)item)->m_last_node); + return nonnull_or_error((T*)((DoublyLinkedListNode*)item)->m_last_node); } template void for_each(Callback callback)