From 283359601e01c35c1d191de67531e8151ed73b70 Mon Sep 17 00:00:00 2001 From: Yu-Ping Wu Date: Fri, 6 Feb 2026 09:55:45 +0800 Subject: [PATCH] commonlib/list: Drop 'const' qualifier from return type The 'const' qualifier is unnecessary for the return values of the following: - list_next() - list_prev() - list_first() - list_last() Therefore, drop it. No caller needs to be changed. Change-Id: I0f5bc2b0ed3cd47d0d6355c8dffea17f6e085407 Signed-off-by: Yu-Ping Wu Reviewed-on: https://review.coreboot.org/c/coreboot/+/91113 Reviewed-by: Jakub "Kuba" Czapiga Reviewed-by: Paul Menzel Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner --- src/commonlib/include/commonlib/list.h | 12 ++++++------ src/commonlib/list.c | 9 ++++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/commonlib/include/commonlib/list.h b/src/commonlib/include/commonlib/list.h index 9bad52f3a3..ce74ca34b6 100644 --- a/src/commonlib/include/commonlib/list.h +++ b/src/commonlib/include/commonlib/list.h @@ -29,27 +29,27 @@ static inline bool list_is_empty(const struct list_node *head) } // Get next node. -static inline const struct list_node *list_next(const struct list_node *node, - const struct list_node *head) +static inline struct list_node *list_next(const struct list_node *node, + const struct list_node *head) { return node->next; }; // Get prev node. -static inline const struct list_node *list_prev(const struct list_node *node, - const struct list_node *head) +static inline struct list_node *list_prev(const struct list_node *node, + const struct list_node *head) { return node->prev == head ? NULL : node->prev; }; // Get first node. -static inline const struct list_node *list_first(const struct list_node *head) +static inline struct list_node *list_first(const struct list_node *head) { return list_is_empty(head) ? NULL : head->next; } // Get last node. -const struct list_node *list_last(const struct list_node *head); +struct list_node *list_last(const struct list_node *head); // Get the number of list elements. size_t list_length(const struct list_node *head); diff --git a/src/commonlib/list.c b/src/commonlib/list.c index 9d11d9606c..1af92c8ac5 100644 --- a/src/commonlib/list.c +++ b/src/commonlib/list.c @@ -37,12 +37,15 @@ void list_append(struct list_node *node, struct list_node *head) list_insert_after(node, head); } -const struct list_node *list_last(const struct list_node *head) +struct list_node *list_last(const struct list_node *head) { - const struct list_node *ptr = head; + if (!head->next) + return NULL; + + struct list_node *ptr = head->next; while (ptr->next) ptr = ptr->next; - return ptr == head ? NULL : ptr; + return ptr; } size_t list_length(const struct list_node *head)