[asterisk-dev] [Code Review] 4529: clang compiler warning: -Wno-sometimes-uninitialized
Diederik de Groot
reviewboard at asterisk.org
Fri Mar 27 12:15:36 CDT 2015
> On March 27, 2015, 2:23 p.m., Matt Jordan wrote:
> > /branches/13/pbx/pbx_config.c, lines 960-961
> > <https://reviewboard.asterisk.org/r/4529/diff/2/?file=72981#file72981line960>
> >
> > Well, this won't quite work, as appdata can be NULL. strlen isn't NULL safe.
> >
> > As such, you'll need to do something like:
> >
> > int escaped_len = (!ast_strlen_zero(appdata) ? 2 * strlen(appdata) : 0) + 1;
> >
> >
>
> Diederik de Groot wrote:
> Thanks for the pointer ! No need to count the string length twice, just a null pointer check should suffice. Also need to set the escaped_len to 1 if appdata==NULL, so that it will be able to contain '\0'.
>
> rmudgett wrote:
> ast_strlen_zero() is a boolean test. It does not actually do a strlen. It is just: (!str || (*str == '\0')).
Ahh ok i didn't know that. It does have the same effect to my version though (in this particular case: even if appdata[0]='\0' it would still result in escaped_len=1). If you guys prefer the ast_strlen_zero test instead, i will update it though.
- Diederik
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4529/#review14894
-----------------------------------------------------------
On March 27, 2015, 5:32 p.m., Diederik de Groot wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4529/
> -----------------------------------------------------------
>
> (Updated March 27, 2015, 5:32 p.m.)
>
>
> Review request for Asterisk Developers.
>
>
> Bugs: ASTERISK-24917
> https://issues.asterisk.org/jira/browse/ASTERISK-24917
>
>
> Repository: Asterisk
>
>
> Description
> -------
>
> clang's static analyzer will throw quite a number warnings / errors during compilation, some of which can be very helpfull in finding corner-case bugs\nclang compiler warning:-Wno-sometimes-uninitialized
>
>
> Diffs
> -----
>
> /branches/13/pbx/pbx_config.c 433444
>
> Diff: https://reviewboard.asterisk.org/r/4529/diff/
>
>
> Testing
> -------
>
>
> Thanks,
>
> Diederik de Groot
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20150327/8db477ec/attachment.html>
More information about the asterisk-dev
mailing list