<p style="white-space: pre-wrap; word-wrap: break-word;">Thanks for the review. Please see my notes:</p><ul><li>The primary motivation to use lists instead of the original implementation is to allow dynamic adding/removal of openr2 channels/links.</li><li>As a result, the link numbering may have "holes"</li></ul><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11535">View Change</a></p><p>3 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.asterisk.org/#/c/11535/2/channels/chan_dahdi.c">File channels/chan_dahdi.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.asterisk.org/#/c/11535/2/channels/chan_dahdi.c@769">Patch Set #2, Line 769:</a> <code style="font-family:monospace,monospace">struct r2link_entry {</code></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">Why did you wrap dahdi_mfcr2 with an r2link_entry instead of just storing it directly in the linked  […]</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Wrapping allows to allocate the dahdi_mfcr2 and the list entry in one call.<br>This technique lower the number of possible error paths (first allocation fails, second allocation fails) to handle.</p><p style="white-space: pre-wrap; word-wrap: break-word;">It also doesn't "cost" anything, so I don't see what we lose.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/11535/2/channels/chan_dahdi.c@11949">Patch Set #2, Line 11949:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">              struct r2link_entry *tmp = NULL;<br>              int new_idx = r2links_count + 1;<br>              int i;<br>                for (i = 1; i <= r2links_count; i++) {<br>                     int i_unused = 1;<br>                     AST_LIST_TRAVERSE(&r2links, tmp, list) {<br>                          if (i == tmp->mfcr2.index) {<br>                                       i_unused = 0;<br>                                 break;<br>                                }<br>                     }<br>                     if (i_unused) {<br>                               new_idx = i;<br>                          break;<br>                        }<br>             }<br></pre></blockquote></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">This loop appears to be unneeded. […]</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">The assumption that the next free index would be last index + 1 only holds if there are no removals of channels/links.</p><p style="white-space: pre-wrap; word-wrap: break-word;">The next patches adds exactly this capability -- i.e: dynamic addition/removal of channels and openr2 links.</p><p style="white-space: pre-wrap; word-wrap: break-word;">That was the main motivation to convert the original array into a linked list.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/11535/2/channels/chan_dahdi.c@19466">Patch Set #2, Line 19466:</a> <code style="font-family:monospace,monospace">              int x = 0;</code></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">variable 'x' appears to be unused aside from incrementing below, so can be removed.</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">The only use of variable 'x' is to allow better error reporting.<br>If ast_pthread_create() fails, the user knows which iteration failed.</p><p style="white-space: pre-wrap; word-wrap: break-word;">(yes, that's not an important use-case, so if you prefer I can remove this)</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11535">change 11535</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.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.asterisk.org/c/asterisk/+/11535"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: Ibcb2401515a58782a1488c0b9efbed201c3f3a17 </div>
<div style="display:none"> Gerrit-Change-Number: 11535 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Oron Peled <oron.peled@xorcom.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Oron Peled <oron.peled@xorcom.com> </div>
<div style="display:none"> Gerrit-Reviewer: Tzafrir Cohen <tzafrir.cohen@xorcom.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Mon, 22 Jul 2019 14:07:07 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Comment-In-Reply-To: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Comment-In-Reply-To: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: comment </div>