[prev in list] [next in list] [prev in thread] [next in thread]
List: asterisk-dev
Subject: Re: [asterisk-dev] [Code Review] 4542: DNS: Add NAPTR support and tests
From: "Matt Jordan" <reviewboard () asterisk ! org>
Date: 2015-03-31 19:20:43
Message-ID: 20150331192043.21843.90339 () sonic ! digium ! api
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
> On March 31, 2015, 10:25 a.m., Matt Jordan wrote:
> > /team/group/dns/main/dns_naptr.c, lines 447-449
> > <https://reviewboard.asterisk.org/r/4542/diff/2/?file=73012#file73012line447>
> >
> > Suggestion: since this is repeated after each check, you may want to macro-tize \
> > it:
> > #define CHECK_END_OF_RECORD do { \
> > if (ptr => end_of_record) { \
> > return NULL; \
> > } } while (0)
> >
> >
> > Then you can just put:
> >
> > ptr += 2;
> > CHECK_END_OF_RECORD;
> >
> > Or something like that.
>
> rmudgett wrote:
> Doing this hides return points. Which adds a potential for memory and ref leaks.
True, right now all of these do not perform cleanup. In fact, the entire exercise \
here is mostly to figure out how long everything is so that things can be allocated.
This is a long routine; sometimes it's nice to take repetitive code and squish it \
down. If Mark feels like that injects too much risk, I have no problem with the \
finding being dropped.
- Matt
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4542/#review14972
-----------------------------------------------------------
On March 27, 2015, 9:45 a.m., Mark Michelson wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4542/
> -----------------------------------------------------------
>
> (Updated March 27, 2015, 9:45 a.m.)
>
>
> Review request for Asterisk Developers.
>
>
> Repository: Asterisk
>
>
> Description
> -------
>
> This adds NAPTR support for DNS in Asterisk.
>
> The main parts of this are the functions for allocating a DNS NAPTR record when a \
> resolver wishes to add a NAPTR record, the sorting algorithm for sorting DNS NAPTR \
> records, and the tests that use a mock DNS resolver.
> NOTE: There is likely to be some overlap here in this review and Josh's SRV review \
> (/r/4528). Our stance on this is that we will factor out the duplicated code once \
> both SRV and NAPTR have been merged into the main DNS branch. The factoring out of \
> common functions will be placed in its own review.
>
> Diffs
> -----
>
> /team/group/dns/tests/test_dns_naptr.c PRE-CREATION
> /team/group/dns/res/res_resolver_unbound.c 433573
> /team/group/dns/main/dns_naptr.c 433573
> /team/group/dns/main/dns_core.c 433573
> /team/group/dns/include/asterisk/dns_internal.h 433573
>
> Diff: https://reviewboard.asterisk.org/r/4542/diff/
>
>
> Testing
> -------
>
> All previous DNS tests continue to pass, and all new tests added in this review \
> pass as well.
>
> Thanks,
>
> Mark Michelson
>
>
[Attachment #5 (text/html)]
<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/4542/">https://reviewboard.asterisk.org/r/4542/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <p style="margin-top: 0;">On March 31st, 2015, 10:25 a.m. CDT, <b>Matt \
Jordan</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/4542/diff/2/?file=73012#file73012line447" \
style="color: black; font-weight: bold; text-decoration: \
underline;">/team/group/dns/main/dns_naptr.c</a> <span style="font-weight: normal;">
(Diff revision 2)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">447</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="k">if</span> <span class="p">(</span><span \
class="n">ptr</span> <span class="o">>=</span> <span \
class="n">end_of_record</span><span class="p">)</span> <span \
class="p">{</span></pre></td> </tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">448</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </span><span class="tb"> </span><span class="k">return</span> <span \
class="nb">NULL</span><span class="p">;</span></pre></td> </tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2"></font></th> <td bgcolor="#c5ffc4" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td> <th \
bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">449</font></th> <td bgcolor="#c5ffc4" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span \
class="tb"> </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;">Suggestion: since this \
is repeated after each check, you may want to macro-tize it:
#define CHECK_END_OF_RECORD do { \
if (ptr => end_of_record) { \
return NULL; \
} } while (0)
Then you can just put:
ptr += 2;
CHECK_END_OF_RECORD;
Or something like that.</pre>
</blockquote>
<p>On March 31st, 2015, 10:36 a.m. CDT, <b>rmudgett</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;">Doing this hides return \
points. Which adds a potential for memory and ref leaks.</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;">True, right \
now all of these do not perform cleanup. In fact, the entire exercise here is mostly \
to figure out how long everything is so that things can be allocated.
This is a long routine; sometimes it's nice to take repetitive code and squish it \
down. If Mark feels like that injects too much risk, I have no problem with the \
finding being dropped. </pre>
<br />
<p>- Matt</p>
<br />
<p>On March 27th, 2015, 9:45 a.m. CDT, Mark Michelson wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;"> <tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By Mark Michelson.</div>
<p style="color: grey;"><i>Updated March 27, 2015, 9:45 a.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>
<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 adds NAPTR support for DNS in Asterisk.
The main parts of this are the functions for allocating a DNS NAPTR record when a \
resolver wishes to add a NAPTR record, the sorting algorithm for sorting DNS NAPTR \
records, and the tests that use a mock DNS resolver.
NOTE: There is likely to be some overlap here in this review and Josh's SRV \
review (/r/4528). Our stance on this is that we will factor out the duplicated code \
once both SRV and NAPTR have been merged into the main DNS branch. The factoring out \
of common functions will be placed in its own review.</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;">All previous DNS tests continue to pass, and all new tests added in this \
review pass as well.</pre> </td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/team/group/dns/tests/test_dns_naptr.c <span style="color: \
grey">(PRE-CREATION)</span></li>
<li>/team/group/dns/res/res_resolver_unbound.c <span style="color: \
grey">(433573)</span></li>
<li>/team/group/dns/main/dns_naptr.c <span style="color: grey">(433573)</span></li>
<li>/team/group/dns/main/dns_core.c <span style="color: grey">(433573)</span></li>
<li>/team/group/dns/include/asterisk/dns_internal.h <span style="color: \
grey">(433573)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/4542/diff/" style="margin-left: \
3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic