<p><a href="https://gerrit.osmocom.org/c/libosmocore/+/21930">View Change</a></p><p>10 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/21930/2/include/osmocom/core/it_q.h">File include/osmocom/core/it_q.h:</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/+/21930/2/include/osmocom/core/it_q.h@37">Patch Set #2, Line 37:</a> <code style="font-family:monospace,monospace">  void (*read_cb)(struct osmo_it_q *q, void *item);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">why not passing the pointer to the item's llist instead? This way it's up to the reader to infer item form llist using well-known container_of().<br>This way you avoid the limitation of requiring llit at the beggining of item's struct. (see like 17 "IMPORTANT").</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/21930/2/src/it_q.c">File src/it_q.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/+/21930/2/src/it_q.c@67">Patch Set #2, Line 67:</a> <code style="font-family:monospace,monospace">/* global (for all threads) list of message queues in a program + associated lock */</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">typo: queued</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/libosmocore/+/21930/2/src/it_q.c@69">Patch Set #2, Line 69:</a> <code style="font-family:monospace,monospace">static pthread_rwlock_t it_queues_rwlock;</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">you can probably init this statically?</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/libosmocore/+/21930/2/src/it_q.c@113">Patch Set #2, Line 113:</a> <code style="font-family:monospace,monospace">              q->read_cb(q, item);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">See, simply change function signature to pass struct llist_head and let the user implementing the callback to use container_of.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/libosmocore/+/21930/2/src/it_q.c@142">Patch Set #2, Line 142:</a> <code style="font-family:monospace,monospace">      q->event_ofd.fd = -1;</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">q->mutex needs no init()?</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/libosmocore/+/21930/2/src/it_q.c@220">Patch Set #2, Line 220:</a> <code style="font-family:monospace,monospace">        osmo_it_q_flush(q);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">don't you need to somehow free q->mutex?</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/21930/2/tests/it_q/it_q_test.c">File tests/it_q/it_q_test.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/+/21930/2/tests/it_q/it_q_test.c@10">Patch Set #2, Line 10:</a> <code style="font-family:monospace,monospace">        int foo;</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">You could put a pointer to g_read_cb_count here to have better coverage on struct being correctly used instead of simply allocating and freeing it.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/libosmocore/+/21930/2/tests/it_q/it_q_test.c@73">Patch Set #2, Line 73:</a> <code style="font-family:monospace,monospace">static void q_read_cb(struct osmo_it_q *q, void *item)</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">struct llist_head *item</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/libosmocore/+/21930/2/tests/it_q/it_q_test.c@75">Patch Set #2, Line 75:</a> <code style="font-family:monospace,monospace">    g_read_cb_count++;</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">struct it_q_test1 *it = container_of(item, struct it_q_test1, list);<br>(*it->foo)++</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/c/libosmocore/+/21930/2/tests/it_q/it_q_test.c@100">Patch Set #2, Line 100:</a> <code style="font-family:monospace,monospace">         item = talloc_zero(OTC_GLOBAL, struct it_q_test1);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">item->foo = &g_read_cb_count;</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/21930">change 21930</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/+/21930"/><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: Ie7d0c5fec715a2a577fae014b0b8a0e9c38418ef </div>
<div style="display:none"> Gerrit-Change-Number: 21930 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: daniel <dwillmann@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Comment-Date: Mon, 04 Jan 2021 11:12:11 +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>