summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2014-01-08 06:38:49 -0800
committerPatrick Ohly <patrick.ohly@intel.com>2014-01-17 16:15:16 +0100
commitb1668bce816286ddd445f67acac59f6ffab7475e (patch)
treea5b875e431be9c445f3ec1f779a013016f00ea2a
parent1d6f88cbbe0ed547260e88a66b4a40f74eaee5c8 (diff)
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.
-rw-r--r--src/backends/evolution/EvolutionContactSource.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/backends/evolution/EvolutionContactSource.cpp b/src/backends/evolution/EvolutionContactSource.cpp
index 590ff9b1..60ff94c5 100644
--- a/src/backends/evolution/EvolutionContactSource.cpp
+++ b/src/backends/evolution/EvolutionContactSource.cpp
@@ -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: