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 <[email protected]>

Reply via email to