[asterisk-dev] [Code Review]: avoid cppcheck warnings

junky reviewboard at asterisk.org
Tue Jan 17 20:40:02 CST 2012



> On Jan. 17, 2012, 2:11 p.m., wdoekes wrote:
> > trunk/addons/chan_mobile.c, line 3029
> > <https://reviewboard.asterisk.org/r/1651/diff/7/?file=23132#file23132line3029>
> >
> >     The manual says 0 and -1. Suggest doing < 0 instead.

changed.


> On Jan. 17, 2012, 2:11 p.m., wdoekes wrote:
> > trunk/apps/app_chanspy.c, line 617
> > <https://reviewboard.asterisk.org/r/1651/diff/7/?file=23135#file23135line617>
> >
> >     Unnecessary parens around ast_waitfor.

removed.


> On Jan. 17, 2012, 2:11 p.m., wdoekes wrote:
> > trunk/apps/app_queue.c, line 4882
> > <https://reviewboard.asterisk.org/r/1651/diff/7/?file=23139#file23139line4882>
> >
> >     Adding spaces here was unnecessary. It looked fine as it was.

removed.


> On Jan. 17, 2012, 2:11 p.m., wdoekes wrote:
> > trunk/apps/app_queue.c, line 4866
> > <https://reviewboard.asterisk.org/r/1651/diff/7/?file=23139#file23139line4866>
> >
> >     Unnecessary parens around 2nd pbx_builting_getvar_helper.

removed.


> On Jan. 17, 2012, 2:11 p.m., wdoekes wrote:
> > trunk/apps/app_voicemail.c, line 1952
> > <https://reviewboard.asterisk.org/r/1651/diff/7/?file=23140#file23140line1952>
> >
> >     Space between ( and init_ shall go.

gone!


> On Jan. 17, 2012, 2:11 p.m., wdoekes wrote:
> > trunk/funcs/func_env.c, lines 691-694
> > <https://reviewboard.asterisk.org/r/1651/diff/7/?file=23147#file23147line691>
> >
> >     Should probably have kept the readlen= and did fbuf + readlen instead of fbuf + sizeof(fbuf) and this has more implications.
> >     
> >     But I see this is already handled differently in other areas...
> >     
> >                             if (fread(fbuf, 1, sizeof(fbuf), ff) && !feof(ff)) {  <-- that's a different bug, on line 639.. looks like we're missing a "< sizeof(fbuf)"
> >                                     ast_log(LOG_ERROR, "Short read?!!\n");
> >                                     fclose(ff);
> >                                     return -1;
> >                             }
> >     
> >     I think aborting is the right way. fread shouldn't do short reads according to the manual.

I didnt used the readlen, since it's not needed.
I now abort as at line 639.
I also fix the bug at this line to do the < sizeof(fbuf).


> On Jan. 17, 2012, 2:11 p.m., wdoekes wrote:
> > trunk/main/ast_expr2f.c, line 2596
> > <https://reviewboard.asterisk.org/r/1651/diff/7/?file=23152#file23152line2596>
> >
> >     Spaces:
> >     
> >     for (i = 0; i < (int)...

spaces added.


- junky


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


On Jan. 12, 2012, 8:08 p.m., junky wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1651/
> -----------------------------------------------------------
> 
> (Updated Jan. 12, 2012, 8:08 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> By running cppcheck 1.52, i realized there was many errors/warnings.
> 
> This patch fixes many of those.
> 
> 
> Diffs
> -----
> 
>   trunk/addons/chan_mobile.c 349670 
>   trunk/addons/chan_ooh323.c 349670 
>   trunk/apps/app_alarmreceiver.c 349670 
>   trunk/apps/app_chanspy.c 349670 
>   trunk/apps/app_disa.c 349670 
>   trunk/apps/app_minivm.c 349670 
>   trunk/apps/app_osplookup.c 349670 
>   trunk/apps/app_queue.c 349670 
>   trunk/apps/app_voicemail.c 349670 
>   trunk/channels/chan_dahdi.c 349670 
>   trunk/channels/chan_iax2.c 349670 
>   trunk/channels/chan_misdn.c 349670 
>   trunk/channels/chan_skinny.c 349670 
>   trunk/channels/chan_usbradio.c 349670 
>   trunk/formats/format_h263.c 349670 
>   trunk/funcs/func_env.c 349670 
>   trunk/funcs/func_odbc.c 349670 
>   trunk/funcs/func_strings.c 349670 
>   trunk/main/acl.c 349670 
>   trunk/main/ast_expr2.c 349670 
>   trunk/main/ast_expr2f.c 349670 
>   trunk/main/pbx.c 349670 
>   trunk/main/udptl.c 349670 
>   trunk/res/res_phoneprov.c 349670 
>   trunk/utils/astman.c 349670 
> 
> Diff: https://reviewboard.asterisk.org/r/1651/diff
> 
> 
> Testing
> -------
> 
> still compile fine.
> Shouldn't have any impact on the code execution.
> 
> 
> Thanks,
> 
> junky
> 
>

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


More information about the asterisk-dev mailing list