Change in libosmocore[master]: linuxlist: add macro to get last element of a list

laforge gerrit-no-reply at lists.osmocom.org
Fri Jul 9 11:50:36 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/24801 )

Change subject: linuxlist: add macro to get last element of a list
......................................................................

linuxlist: add macro to get last element of a list

It is not be obvious on the first look that ->prev actually points to the last
element of a list, lets add a macro for that to make the API easier to use

Change-Id: Icf455bf6ba9d60bd311af17c9e80febaa42cacc9
Related: SYS#4971
---
M include/osmocom/core/linuxlist.h
1 file changed, 6 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve



diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h
index f28f88b..725c60c 100644
--- a/include/osmocom/core/linuxlist.h
+++ b/include/osmocom/core/linuxlist.h
@@ -238,6 +238,12 @@
 #define llist_last_entry(ptr, type, member) \
 	llist_entry((ptr)->prev, type, member)
 
+/*! Return the last element of the list.
+ *  \param head the llist head of the list.
+ *  \returns last element of the list, head if the list is empty.
+ */
+#define llist_last(head) (head)->prev
+
 /*! Get the first element from a list, or NULL.
  *  \param ptr    the list head to take the element from.
  *  \param type   the type of the struct this is embedded in.

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/24801
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Icf455bf6ba9d60bd311af17c9e80febaa42cacc9
Gerrit-Change-Number: 24801
Gerrit-PatchSet: 5
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210709/2fedc2d4/attachment.htm>


More information about the gerrit-log mailing list