<p style="white-space: pre-wrap; word-wrap: break-word;">I have used this exact technique for the same reasons.<br>Freeing an item often has effects in FSMs / triggers cleanup actions which then tear down other instances as well.</p><p style="white-space: pre-wrap; word-wrap: break-word;">(re dexter: FSM events get processed inline immediately, not on the next select().)</p><p style="white-space: pre-wrap; word-wrap: break-word;">llist_for_each_entry_safe() is not actually safe: if the *next* entry gets deallocated from cleanup actions, then it falls on its face the same way llist_for_each_entry() does.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Getting the first entry of an llist is always safe, so it is the simplest and safest way to clear a list. The alternatives would be to implement an *actually* safe llist_for_each_entry, e.g. to compare against active iterators on each llist_del(); would be quite complex, and would not match the thin simple nature of the llist implementation.</p><p style="white-space: pre-wrap; word-wrap: break-word;">For me personally, seeing this code is perfectly clear and I wouldn't ask for spreading comments explaining the same concept on every such clearing loop.</p><p style="white-space: pre-wrap; word-wrap: break-word;">But would be nicer to have a single function like gprs_ns2_clear() instead of duplicating the loop all over. (Then there could also be a single comment in that function, explaining for the other reviewers...)</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/25147">View Change</a></p><p>1 comment:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/25147/1/src/gb/gprs_ns2.c">File src/gb/gprs_ns2.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/libosmocore/+/25147/1/src/gb/gprs_ns2.c@1490">Patch Set #1, Line 1490:</a> <code style="font-family:monospace,monospace"></code></p><p style="white-space: pre-wrap; word-wrap: break-word;">looks like moving this free loop is fixing a separate issue?</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/25147">change 25147</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/25147"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I902557fb6e56e6588728a46e43a9cbe3215d5c68 </div>
<div style="display:none"> Gerrit-Change-Number: 25147 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: lynxis lazus <lynxis@fe80.eu> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-CC: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-CC: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Comment-Date: Mon, 09 Aug 2021 12:30:29 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Gerrit-MessageType: comment </div>