cppcheck analysis

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I found some "issues" while using cppcheck (1.64) on pjproject 2.2.1. Here
are a few of the more "easy," straight-forward findings:

1)
pjnath\src\pjturn-srv\allocation.c#1285:
pj_assert(sizeof(p2->channel==2));
I think should be either:
pj_assert(sizeof(p2->channel)==2);
or:
pj_assert(p2->channel==2);
?

2)
There are several places where unsigned struct members/variables are either
checked for values < 0 (never true) or >=0 (always true):
pjlib-util\src\pjlib-util\resolver.c#819 - The unsigned variable 'ref_cnt'
will never be negative so it is either pointless or an error to check if it
is.
pjlib-util\src\pjlib-util\resolver.c#835 - The unsigned variable 'ref_cnt'
will never be negative so it is either pointless or an error to check if it
is.
pjmedia\src\pjmedia\codec.c#297 - Unsigned variable 'pt' can't be negative
so it is unnecessary to test it.
pjmedia\src\pjmedia-audiodev\alsa_dev.c#386 - Unsigned variable 'index'
can't be negative so it is unnecessary to test it.
pjmedia\src\pjmedia-audiodev\alsa_dev.c#402 - Unsigned variable 'index'
can't be negative so it is unnecessary to test it.
pjnath\src\pjnath\ice_strans.c#1043 - Unsigned variable 'default_cand'
can't be negative so it is unnecessary to test it.

3)
Unused variables:
pjsip\src\pjsip\sip_msg.c#910 - Variable 'endbuf' is assigned a value that
is never used.
pjsip\src\pjsip\sip_msg.c#919 - Unused variable: printed
pjsip\src\pjsip\sip_uri.c#112 - Unused variable: printed
pjsip\src\pjsip\sip_uri.c#119 - Variable 'endbuf' is assigned a value that
is never used.
pjsip\src\pjsip\sip_uri.c#681 - Variable 'endbuf' is assigned a value that
is never used.


There are many other results, but it depends on how strict you want to be
about things like making sure variables aren't immediately re-assigned
(e.g. `int i = 0; i = 4;`), null pointer checks, etc...


- Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20140320/8c2a43bd/attachment-0001.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux