EDS: fix false clang warning

Control flow analysis from clang's own C++ compiler and clang's
scan-tool come to different results: the compiler fails to detect
that the variable will be initialized in all cases and thus requires
a redundant initialization to avoid an "uninitialized memory read"
error with -Wall, while scan-tool complains about the redundant write.

To satisfy both, avoid the initialization when doing static code analysis.
This commit is contained in:
Patrick Ohly 2014-01-08 06:38:49 -08:00
parent 1d6f88cbbe
commit b1668bce81

View file

@ -564,9 +564,17 @@ void EvolutionContactSource::invalidateCachedContact(boost::shared_ptr<ContactCa
bool EvolutionContactSource::getContact(const string &luid, EContact **contact, GErrorCXX &gerror)
{
SE_LOG_DEBUG(getDisplayName(), "reading: getting contact %s", luid.c_str());
ReadAheadOrder order = m_readAheadOrder;
// Use switch and let compiler tell us when we don't cover a case.
ReadAheadOrder order
#ifndef __clang_analyzer__
// scan-build would complain: value stored to 'order' during
// its initialization is never read. But we need to keep it
// otherwise, to avoid: 'order' may be used uninitialized in
// this function [-Werror=maybe-uninitialized]
= m_readAheadOrder
#endif
;
switch (m_accessMode) {
case SYNCHRONOUS:
case DEFAULT: