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 <yupingso@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/91113 Reviewed-by: Jakub "Kuba" Czapiga <czapiga@google.com> Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
parent
f91f18cdc4
commit
283359601e
2 changed files with 12 additions and 9 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue