[asterisk-dev] [Code Review]: Allow empty display name if callerid is set to an empty string. Take 2!

jrose reviewboard at asterisk.org
Wed Aug 3 11:02:53 CDT 2011



> On Aug. 3, 2011, 10:40 a.m., rmudgett wrote:
> > Is there going to be a version for 1.8,...?

Right now, I'm thinking not.  It was being categorized as a feature change in the issue comments.


> On Aug. 3, 2011, 10:40 a.m., rmudgett wrote:
> > /trunk/channels/chan_sip.c, lines 11877-11880
> > <https://reviewboard.asterisk.org/r/1341/diff/1/?file=17706#file17706line11877>
> >
> >     Remember that strlen() takes time to execute and you are calling it 4 times here.  Just save the strlen() value before the if and use it in the 4 places.

Well, there are 4 calls, but it will only be called twice in any execution of the function.  Also keep in mind that only the display name can be entered into the from string at this point, so realistically we are talking like 30 characters on a bad day (and 0 characters in the case where we didn't have a caller id name) in a function that takes O(n) time based on length of the string that is going to be ran on a typical sip call once or twice at the beginning... I was thinking about it at the time, but it was at that level uncomfortably low impact that I almost thought it would be worse to have another variable floating around.

That said, I do hate running functions twice in one statement, so I'll go ahead and use temp variables, but I think it would be better to have them before each snprintf statement than before the condition since they shouldn't have function-wide scope.


> On Aug. 3, 2011, 10:40 a.m., rmudgett wrote:
> > /trunk/channels/chan_sip.c, lines 11870-11877
> > <https://reviewboard.asterisk.org/r/1341/diff/1/?file=17706#file17706line11870>
> >
> >     Make code like:
> >     
> >     ourport = ...
> >     if (cid_has_name) {
> >       /* Add a display name */
> >       sprintf...
> >     } else {
> >       from[0] = '\0';
> >     }
> >     if (!sip_stand....
> >     
> >     1) Code is grouped for the purpose of generating the from string.
> >     2) The from[0] initialization is delayed until needed and you don't have to look for it.

Alright, thanks, I was actually dubious over that to start with.


- jrose


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1341/#review3981
-----------------------------------------------------------


On Aug. 3, 2011, 9:57 a.m., jrose wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1341/
> -----------------------------------------------------------
> 
> (Updated Aug. 3, 2011, 9:57 a.m.)
> 
> 
> Review request for Asterisk Developers, David Vossel and rmudgett.
> 
> 
> Summary
> -------
> 
> This is basically what I was trying to do with the user submitted patch from yesterday.  After speaking with Richard, it became somewhat obvious that the approach to the patch had too much extra impact on the SIP messages when all that was really needed was specifically targeting the creation of the display name.
> 
> This approach checks strictly for a caller id name and if it isn't there, we skip the creation of the display name.  I think this should be safer in general than the previous approach.
> 
> 
> This addresses bug ASTERISK-16198.
>     https://issues.asterisk.org/jira/browse/ASTERISK-16198
> 
> 
> Diffs
> -----
> 
>   /trunk/CHANGES 330571 
>   /trunk/channels/chan_sip.c 330571 
> 
> Diff: https://reviewboard.asterisk.org/r/1341/diff
> 
> 
> Testing
> -------
> 
> Testing was similar to last time with focus on comparing the SIP messages between this branch and the normal trunk.  In this case, only the display name gets changed.
> 
> A few SIP tests from the test suite were also ran successfully.  I haven't ran the full test suite yet, but am preparing to do so.
> 
> 
> Thanks,
> 
> jrose
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20110803/f4a631f5/attachment.htm>


More information about the asterisk-dev mailing list