Hi - I am new to cppchecker. It seems like a good idea. Thanks for creating it.
I am trying to create a configuration file that will catch the failure to release a lock.
The tool seems to believe that a 'resource' function call must have a return parameter.
However, I am dealing with simply getReadLock() and getWriteLock() and unLock() , all returning void.
This C++ objects afterall...
[q.c:7]: (style) Variable 'a' is assigned a value that is never used. [q.c:7]: (error) Array 'a[10]' accessed at index 10, which is out of bounds. [q.c:9]: (error) Return value of allocation function getReadLock is not used. [q.c:11]: (error) Return value of allocation function getWriteLock is not used.
Hi - I am new to cppchecker. It seems like a good idea. Thanks for creating it.
I am trying to create a configuration file that will catch the failure to release a lock.
The tool seems to believe that a 'resource' function call must have a return parameter.
However, I am dealing with simply getReadLock() and getWriteLock() and unLock() , all returning void.
This C++ objects afterall...
My simply code test case is this:
int foo()
{
char a[10] ;
a[10] = 0 ;
getReadLock() ;
unLock() ;
getWriteLock() ;
unLock() ;
return 0 ;
}
int main()
{
return foo() ;
}
-- end code
My output from the tool ( 1.72 ) is this:
[q.c:7]: (style) Variable 'a' is assigned a value that is never used.
[q.c:7]: (error) Array 'a[10]' accessed at index 10, which is out of bounds.
[q.c:9]: (error) Return value of allocation function getReadLock is not used.
[q.c:11]: (error) Return value of allocation function getWriteLock is not used.
My cfg file is this:
<def>
<function name="dostuff">
<leak-ignore>
<arg nr="1">
<arg nr="2">
</arg></arg></leak-ignore></function>
<resource>
<alloc>getReadLock</alloc>
<dealloc>releaseLock</dealloc>
<dealloc>unLock</dealloc>
</resource>
<resource>
<alloc>getWriteLock</alloc>
<dealloc>releaseLock</dealloc>
<dealloc>unLock</dealloc>
</resource>
</def>
My command line is this:
/u/reich/dsc/cppcheck --enable=all --platform=unix64 --std=c99 \
--std=posix --std=c++03 \
--library=/u/reich/dsc/cfg/posix.cfg \
--library=/u/reich/dsc/cfg/std.cfg \
--library=/u/reich/dsc/dsc.cfg \
--language=c++ \
-I/u/reich/dsc/other_include \
-I/usr/include \
-D_REENTRANT -Dx86_64 -D__x86_64__ \
--verbose \
-D__cplusplus -Dlinux -DLINUX -D__GNUC__ -D__STDC__ -U_ADCSIM_ $1 2> $1.xml
( sorry, I did not see a way to attach a tarball of these items )
I'm looking for the tool to
a) not report this error
b) report a 'resource leak' when I forget to provide the unlock() in the code.
Please advise. Thanks
hmm... the 'attach' button seems to appear on replies to posts, so here is the tarball...