<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/1940/">https://reviewboard.asterisk.org/r/1940/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On May 21st, 2012, 6:37 p.m., <b>rmudgett</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/1940/diff/1/?file=28179#file28179line12428" style="color: black; font-weight: bold; text-decoration: underline;">/branches/1.8/channels/chan_sip.c</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static void on_dns_update_mwi(struct ast_sockaddr *old, struct ast_sockaddr *new, void *data)</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">12427</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="n">ASTOBJ_REF</span><span class="p">(</span><span class="n">mwi</span><span class="p">);</span> <span class="cm">/* Add a ref for storing the mwi on the dnsmgr for updates */</span></pre></td>
<th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">12428</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="n">ast_dnsmgr_lookup_cb</span><span class="p">(</span><span class="n">mwi</span><span class="o">-></span><span class="n">hostname</span><span class="p">,</span> <span class="o">&</span><span class="n">mwi</span><span class="o">-></span><span class="n">us</span><span class="p">,</span> <span class="o">&</span><span class="n">mwi</span><span class="o">-></span><span class="n">dnsmgr</span><span class="p">,</span> <span class="n">sip_cfg</span><span class="p">.</span><span class="n">srvlookup</span> <span class="o">?</span> <span class="n">transport</span> <span class="o">:</span> <span class="nb">NULL</span><span class="p">,</span> <span class="n">on_dns_update_mwi</span><span class="p">,</span> <span class="p">(</span><span class="n">saved</span> <span class="o">=</span> <span class="n">ASTOBJ_REF</span><span class="p">(</span><span class="n">mwi</span><span class="p">)));</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Rather than cramming as much as you can into a single statement, why not keep the separate statements like it was before?
Remember the KISS principle.</pre>
</blockquote>
<p>On May 21st, 2012, 6:51 p.m., <b>Terry Wilson</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I initially had it the other way. To me this was clearer that we are saving a ref specifically for this function call. Although I still prefer this way, if you feel strongly about it I can change it.</pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I have had to fix a few places in Asterisk where the assignment was crammed into the if test and the parentheses were misplaced.
if ((a = b < 0))
when it should have been
if ((a = b) < 0)
Breaking the assignment and test into two statements avoids the problem altogether. It also gives better places to break long lines.
Although C is not lisp, you can still get Lost In Stupid Parentheses. :)</pre>
<br />
<p>- rmudgett</p>
<br />
<p>On May 21st, 2012, 3:52 p.m., Terry Wilson wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers and Matt Jordan.</div>
<div>By Terry Wilson.</div>
<p style="color: grey;"><i>Updated May 21, 2012, 3:52 p.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This just saves the ref to a variable and unrefs that instead.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Compiles.</pre>
</td>
</tr>
</table>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-19827">ASTERISK-19827</a>
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/branches/1.8/channels/chan_sip.c <span style="color: grey">(367176)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/1940/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>