<p>Corey Farrell <strong>posted comments</strong> on this change.</p><p><a href="https://gerrit.asterisk.org/7833">View Change</a></p><p>Patch set 1:</p><p>(7 comments)</p><ul style="list-style: none; padding-left: 20px;"><li><p><a href="https://gerrit.asterisk.org/#/c/7833/1/res/res_stasis.c">File res/res_stasis.c:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/7833/1/res/res_stasis.c@1778">Patch Set #1, Line 1778:</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;">         if (handler) {<br>                        res = handler(app, uri, event_source);<br>                }<br></pre></blockquote></p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">The test for handler != NULL is loop invariant and could be made a condition of even executing the loop.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">This function is static and both callers provide a handler so I'm going to use an assert at the start of the function instead.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/7833/1/res/res_stasis.c@1926">Patch Set #1, Line 1926:</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;">      if (json_variables) {<br>         struct ast_json *json_value = ast_json_string_create(event_name);<br><br>           if (json_value && !ast_json_object_set(blob, "eventname", json_value)) {<br>                    blob = ast_json_ref(json_variables);<br>          }<br>     } else {<br>              blob = ast_json_pack("{ss}", "eventname", event_name);<br>    }<br><br>   if (!blob) {<br>          ast_log(LOG_ERROR, "Failed to initialize blob\n");<br><br>                return res;<br>   }<br></pre></blockquote></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">This does not appear to be equivalent code to setup blob from json_variable</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">ast_json_object_set should run on json_variables since blob is not yet set.  Otherwise I believe the code is equivalent.</p></li></ul></li><li><p><a href="https://gerrit.asterisk.org/#/c/7833/1/res/stasis/app.c">File res/stasis/app.c:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/7833/1/res/stasis/app.c@932">Patch Set #1, Line 932:</a> <code style="font-family:monospace,monospace">struct stasis_app *app_create(const char *name, stasis_app_cb handler, void *data, enum stasis_app_subscription_model subscription_model)</code></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">A follow on patch is needed to fix app_create() leaking a partially created</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">I'm going to strip app_create changes from this patch and work on it separately, it seems to have many error handling issues.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/7833/1/res/stasis/app.c@1226">Patch Set #1, Line 1226:</a> <code style="font-family:monospace,monospace">  if (!channels || !bridges || !endpoints) {</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">These checks are pointless, if json != NULL these must exist too.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/7833/1/res/stasis/app.c@1237">Patch Set #1, Line 1237:</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;">          id = ast_json_string_create(forwards->id);<br><br>               switch (forwards->forward_type) {<br></pre></blockquote></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">id is leaked if no switch case is taken.  Adding a default case would remov</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Hmm I see that now.  I have another approach which will resolve all your concerns but still avoid the extra ref/unref.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/7833/1/res/stasis/app.c@1292">Patch Set #1, Line 1292:</a> <code style="font-family:monospace,monospace">         res = ao2_link_flags(app->forwards, forwards,</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">The bridge/endpoint functions do not check this result.  I'll add it to the bridge/endpoint functions.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/7833/1/res/stasis/app.c@1469">Patch Set #1, Line 1469:</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;">int app_is_subscribed_bridge_id(struct stasis_app *app, const char *bridge_id)<br>{<br>        struct app_forwards *forwards;<br><br>      if (ast_strlen_zero(bridge_id)) {<br>             bridge_id = BRIDGE_ALL;<br>       }<br><br>   forwards = ao2_find(app->forwards, bridge_id, OBJ_SEARCH_KEY);<br>     ao2_cleanup(forwards);<br><br>      return forwards != NULL;<br>}<br></pre></blockquote></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">I think this bug fix change deserves special mention in the commit message </blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Yeah I'll do this in a separate patch so it gets mention in 'git log --oneline'.</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/7833">change 7833</a>. To unsubscribe, 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/7833"/><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-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: I4ce67120583a446babf9adeec678b71d37fcd9e5 </div>
<div style="display:none"> Gerrit-Change-Number: 7833 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Sun, 07 Jan 2018 18:06:53 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>