<p>Patch set 6:<span style="border-radius: 3px; display: inline-block; margin: 0 2px; padding: 4px;background-color: #ffd4d4; color: #000000;">Code-Review -1</span></p><p><a href="https://gerrit.asterisk.org/10929">View Change</a></p><p>4 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.asterisk.org/#/c/10929/6/main/stasis.c">File main/stasis.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/10929/6/main/stasis.c@476">Patch Set #6, Line 476:</a> <code style="font-family:monospace,monospace">              ast_log(LOG_ERROR, "Could not allocate the memory. name: %s\n", name);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">A generic message is already printed via ao2_calloc.  Honestly I'm not in favor of adding any of the LOG_ERROR messages in this function except for the "same topic already exists", that's the only non-system error that can occur here.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Also nit: I'd prefer the blank line in these error blocks be before the 'return -1'.  This makes the fact that the blocks return stand out.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/10929/6/main/stasis.c@2222">Patch Set #6, Line 2222:</a> <code style="font-family:monospace,monospace">    iter = ao2_iterator_init(topic_all, 0);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This CLI command should produce output sorted by name.  The way I know to do this is:</p><ul><li>Create a temporary container with ao2_container_alloc_list (be sure to include a sort function).</li><li>Use ao2_container_dup to copy items from topic_all to the temporary container.</li><li>Iterate the temporary container.  Using AO2_ITERATOR_UNLINK on ao2_iterator_init will avoid an extra ref/unref per item.</li><li>Cleanup the iterator and temporary container.</li></ul></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/10929/6/main/stasis.c@2252">Patch Set #6, Line 2252:</a> <code style="font-family:monospace,monospace">          if (!strncasecmp(word, topic->name, wordlen) && ++which > state) {</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">The which variable and state argument are not needed (this comparison is always true), they should be removed.  When using ast_cli_completion_add the a->n (state) variable will always be 0.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/10929/6/main/stasis.c@2253">Patch Set #6, Line 2253:</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;">                     ret = ast_cli_completion_add(ast_strdup(topic->name));<br>                     ao2_ref(topic, -1);<br>                   if (ret) {<br>                            break;<br>                        }<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Currently this causes an extra call to ao2_ref(topic, -1) on the non-failure path.  You can fix this and remove the 'ret' variable using the following code:</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  if (ast_cli_completion_add(ast_strdup(topic->name)) {<br>    ao2_ref(topic, -1);<br>    break;<br>  }</pre></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/10929">change 10929</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/10929"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: Ie86d125d2966f93de74ee00f47ae6fbc8c081c5f </div>
<div style="display:none"> Gerrit-Change-Number: 10929 </div>
<div style="display:none"> Gerrit-PatchSet: 6 </div>
<div style="display:none"> Gerrit-Owner: sungtae kim <pchero21@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: sungtae kim <pchero21@gmail.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Mon, 28 Jan 2019 14:30:05 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-HasLabels: Yes </div>