Suspicous code in kdelibs-3.5.2
Christoph Bartoschek
bartoschek at gmx.de
Wed Apr 5 19:32:05 BST 2006
> > - kio/kio/kdirlister.cpp:947
> > - kio/kio/kdirlister.cpp:1524
> I don't quite understand... what's wrong with this:
>
> bool delayedMimeTypes = true;
> for ( KDirLister *kdl = listers->first(); kdl; kdl =
listers->next() )
> delayedMimeTypes &= kdl->d->delayedMimeTypes;
>
> kdl->d->delayedMimeTypes is a bool as well. Any ideas?
The tool marks each usage of a bool in an arithmetic context as a
possible mistake. The & operator is an arithmetic operator and
the tool checks that both operands are arithmetic types. A bool
has first to be converted to 1 or 0 and then can be used for &.
However the C++ language lacks &&= and ||= such that the usage
of &= and |= for boolean chaining became an idiom.
When one has to decide whether & or && is the better choice one
has to take into account that & has no short circuit evaluation.
I will omit such messages if I am able to do another report.
--
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
More information about the kde-core-devel
mailing list