[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Static code analysis (cppcheck)

From: Julian Foad <julian.foad_at_wandisco.com>
Date: Wed, 29 Jun 2011 16:26:05 +0100

Philipp Kloke wrote:
> [SVN\subversion\bindings\javahl\native\JNIUtil.h:40] ->
> [SVN\subversion\include\svn_types.h:132]: (style) Struct 'svn_error_t'
> forward declaration unnecessary, already declared
[...]
> [SVN\subversion\include\private\svn_temp_serializer.h:42] ->
> [SVN\subversion\include\svn_string.h:120]: (style) Struct 'svn_stringbuf_t'
> forward declaration unnecessary, already declared

Those two warnings are bogus: they apply only in the context of a
particular translation unit (C file).

> [SVN\subversion\libsvn_auth_kwallet\kwallet.cpp:203]: (style) Variable 'app'
> is assigned a value that is never used
> [SVN\subversion\libsvn_auth_kwallet\kwallet.cpp:273]: (style) Variable 'app'
> is assigned a value that is never used

I don't really understand the code there. It was added in r875811 with
the log message "Fix segmentation fault with KDE 4.2. [...] Create a
QCoreApplication instance if it doesn't exist." It looks like it's
creating an object that has to exist for at least the duration of this
function's body, and thus this variable 'app' is 'used' in the sense
that it forces this object to exist; but I don't know if that's entirely
correct.

It also makes me wonder whether this app object should be kept in a
'static' variable so that it continues to exist for the lifetime of the
'svn' program execution rather than being created and destroyed each
time this function is executed.

> [SVN\subversion\libsvn_diff\diff.c:71]: (style) Variable 'diff' is not
> assigned a value
> [SVN\subversion\libsvn_diff\token.c:158]: (style) Variable 'start_position'
> is not assigned a value

Bogus warnings: they are assigned a value indirectly through a pointer.

- Julian
Received on 2011-06-29 17:26:42 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.