[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: Thu, 30 Jun 2011 10:35:40 +0100

On Wed, 2011-06-29 at 17:39 +0100, Philip Martin wrote:
> Julian Foad <julian.foad_at_wandisco.com> writes:
> >> [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.
> qApp is a Qt global variable that refers to the unique QApplication
> instance within the program. The code allocates a QApplication object,
> of type QCoreApplication, to run a Qt event loop if this is not a Qt GUI
> program. The object is only created if the event loop is not running, I
> don't think the object is ever explicitly destroyed (I suppose code
> outside Subversion could delete it vi qApp).
> To remove the warning I suppose we could drop the app variable, i.e.
> new QCoreApplication(...)
> instead of
> app = new QCoreApplication(...)
> but that might prompt other warnings.

The existing code creates the object and (though it never uses its
address) never destroys it. With your change, the object would be
created and then immediately destroyed. That doesn't seem likely to be
what's needed, though I'm not sure exactly what is needed here.

- Julian
Received on 2011-06-30 11:36:43 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.