aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Kay <chris.kay@arm.com>2019-01-23 17:30:20 +0000
committerronald-cron-arm <39518861+ronald-cron-arm@users.noreply.github.com>2019-02-26 08:40:42 +0100
commitf13dfd8e4cd01003031b167885cb78c03b1d03df (patch)
tree45dff0fe3ea04b2216be10ce579d2ce77a2b691d
parent866fd8c5f6467c3fbf29a7ecc9ffdb38c46acadd (diff)
fwk: Always zero list nodes when they are removed
This patch ensures that list nodes are always cleared after being removed from a list. This ensures that functions operating on lists do not have to manually zero these fields if they need to move the node to another list. Change-Id: I2c9b6e135a85ca8b8d1845db1df1c3004c1b49c9 Signed-off-by: Chris Kay <chris.kay@arm.com>
-rw-r--r--framework/src/fwk_dlist.c4
-rw-r--r--framework/src/fwk_slist.c7
2 files changed, 3 insertions, 8 deletions
diff --git a/framework/src/fwk_dlist.c b/framework/src/fwk_dlist.c
index 020d076a..09c0101b 100644
--- a/framework/src/fwk_dlist.c
+++ b/framework/src/fwk_dlist.c
@@ -54,10 +54,8 @@ struct fwk_dlist_node *__fwk_dlist_pop_head(struct fwk_dlist *list)
list->head->prev = (struct fwk_dlist_node *)list;
-#ifdef BUILD_MODE_DEBUG
if (popped != NULL)
popped->prev = NULL;
-#endif
return popped;
}
@@ -79,10 +77,8 @@ void __fwk_dlist_remove(
node->prev->next = node->next;
node->next->prev = node->prev;
-#ifdef BUILD_MODE_DEBUG
node->prev = NULL;
node->next = NULL;
-#endif
}
void __fwk_dlist_insert(
diff --git a/framework/src/fwk_slist.c b/framework/src/fwk_slist.c
index 1787756e..99642304 100644
--- a/framework/src/fwk_slist.c
+++ b/framework/src/fwk_slist.c
@@ -89,9 +89,7 @@ struct fwk_slist_node *__fwk_slist_pop_head(struct fwk_slist *list)
list->head = popped->next;
-#ifdef BUILD_MODE_DEBUG
popped->next = NULL;
-#endif
return popped;
}
@@ -121,11 +119,12 @@ void __fwk_slist_remove(
while (node_iter->next != (struct fwk_slist_node *)list) {
if (node_iter->next == node) {
node_iter->next = node->next;
+
if (node->next == (struct fwk_slist_node *)list)
list->tail = (struct fwk_slist_node *)node_iter;
- #ifdef BUILD_MODE_DEBUG
+
node->next = NULL;
- #endif
+
return;
}
node_iter = node_iter->next;