Change in libosmocore[master]: Don't traverse empty lists in llist_count()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Wed Nov 21 20:27:51 UTC 2018


Max has uploaded this change for review. ( https://gerrit.osmocom.org/11865


Change subject: Don't traverse empty lists in llist_count()
......................................................................

Don't traverse empty lists in llist_count()

While trying to debug odd crash in queue_limit_to(), I've checked
llist_count() as a possible culprit. Not sure if it would fix the
crash (unable to reproduce locally yet) but it seems like a meaningful
optimization anyway.

Change-Id: I1e2ede2dd1afbd9e7ed7e393f9ba244179c03b8c
---
M include/osmocom/core/linuxlist.h
1 file changed, 4 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/65/11865/1

diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h
index 8d0533f..27bd85a 100644
--- a/include/osmocom/core/linuxlist.h
+++ b/include/osmocom/core/linuxlist.h
@@ -391,6 +391,10 @@
 {
 	struct llist_head *entry;
 	unsigned int i = 0;
+
+	if (llist_empty(head))
+		return 0;
+
 	llist_for_each(entry, head)
 		i++;
 	return i;

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1e2ede2dd1afbd9e7ed7e393f9ba244179c03b8c
Gerrit-Change-Number: 11865
Gerrit-PatchSet: 1
Gerrit-Owner: Max <msuraev at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181121/b33f983b/attachment.htm>


More information about the gerrit-log mailing list