Repository: thrift Updated Branches: refs/heads/master 7ed94ef8e -> 71f2d8a71
THRIFT-3067 C++ cppcheck performance related warnings Patch: Arijit Chattopadhyay <[email protected]> This closes #444 Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/71f2d8a7 Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/71f2d8a7 Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/71f2d8a7 Branch: refs/heads/master Commit: 71f2d8a7140329f0f2fc339d84e50d9b27bf478c Parents: 7ed94ef Author: Roger Meier <[email protected]> Authored: Sun Apr 26 17:00:04 2015 +0200 Committer: Roger Meier <[email protected]> Committed: Sun Apr 26 17:00:04 2015 +0200 ---------------------------------------------------------------------- .travis.yml | 1 + compiler/cpp/src/parse/t_enum.h | 4 ++-- compiler/cpp/src/parse/t_service.h | 2 +- contrib/fb303/TClientInfo.cpp | 3 +-- contrib/fb303/cpp/FacebookBase.cpp | 2 +- contrib/fb303/cpp/ServiceTracker.cpp | 2 +- lib/cpp/src/thrift/concurrency/ThreadManager.cpp | 4 ++-- lib/cpp/src/thrift/concurrency/TimerManager.cpp | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/71f2d8a7/.travis.yml ---------------------------------------------------------------------- diff --git a/.travis.yml b/.travis.yml index b49c0a3..ce9ec9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,7 @@ compiler: - gcc before_install: + add sudo - sh build/travis/installCXXDependencies.sh - if [ "$ALL_DEPS" != "no" ] ; then sh build/travis/installDependencies.sh 1> /dev/null ; fi - if [ "$ALL_DEPS" != "no" ] ; then export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/1.20/bin:$PATH ; fi http://git-wip-us.apache.org/repos/asf/thrift/blob/71f2d8a7/compiler/cpp/src/parse/t_enum.h ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/parse/t_enum.h b/compiler/cpp/src/parse/t_enum.h index 59941e3..12b4ad8 100644 --- a/compiler/cpp/src/parse/t_enum.h +++ b/compiler/cpp/src/parse/t_enum.h @@ -31,13 +31,13 @@ class t_enum : public t_type { public: t_enum(t_program* program) : t_type(program) {} - void set_name(const std::string& name) { name_ = name; } + void set_name(const std::string &name) { name_ = name; } void append(t_enum_value* constant) { constants_.push_back(constant); } const std::vector<t_enum_value*>& get_constants() { return constants_; } - t_enum_value* get_constant_by_name(const std::string name) { + t_enum_value* get_constant_by_name(const std::string& name) { const std::vector<t_enum_value*>& enum_values = get_constants(); std::vector<t_enum_value*>::const_iterator c_iter; for (c_iter = enum_values.begin(); c_iter != enum_values.end(); ++c_iter) { http://git-wip-us.apache.org/repos/asf/thrift/blob/71f2d8a7/compiler/cpp/src/parse/t_service.h ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/parse/t_service.h b/compiler/cpp/src/parse/t_service.h index 091403d..1f49972 100644 --- a/compiler/cpp/src/parse/t_service.h +++ b/compiler/cpp/src/parse/t_service.h @@ -39,7 +39,7 @@ public: void add_function(t_function* func) { std::vector<t_function*>::const_iterator iter; - for (iter = functions_.begin(); iter != functions_.end(); iter++) { + for (iter = functions_.begin(); iter != functions_.end(); ++iter) { if (func->get_name() == (*iter)->get_name()) { throw "Function " + func->get_name() + " is already defined"; } http://git-wip-us.apache.org/repos/asf/thrift/blob/71f2d8a7/contrib/fb303/TClientInfo.cpp ---------------------------------------------------------------------- diff --git a/contrib/fb303/TClientInfo.cpp b/contrib/fb303/TClientInfo.cpp index 5959fb1..1fc6612 100644 --- a/contrib/fb303/TClientInfo.cpp +++ b/contrib/fb303/TClientInfo.cpp @@ -154,9 +154,8 @@ void TClientInfoServerHandler::getStatsStrings(vector<string>& result) { } timespec start; - double secs = 0.0; info->getTime(&start); - secs = (double)(now.tv_sec - start.tv_sec) + (now.tv_nsec - start.tv_nsec)*0.000000001; + double secs = (double)(now.tv_sec - start.tv_sec) + (now.tv_nsec - start.tv_nsec)*0.000000001; char buf[256]; snprintf(buf, sizeof buf, "%d %s %s %.3f %llu", i, addrStr, callStr, secs, http://git-wip-us.apache.org/repos/asf/thrift/blob/71f2d8a7/contrib/fb303/cpp/FacebookBase.cpp ---------------------------------------------------------------------- diff --git a/contrib/fb303/cpp/FacebookBase.cpp b/contrib/fb303/cpp/FacebookBase.cpp index 8003340..3c56975 100644 --- a/contrib/fb303/cpp/FacebookBase.cpp +++ b/contrib/fb303/cpp/FacebookBase.cpp @@ -98,7 +98,7 @@ void FacebookBase::getCounters(std::map<std::string, int64_t>& _return) { // want our read/write structure to go over the wire counters_.acquireRead(); for(ReadWriteCounterMap::iterator it = counters_.begin(); - it != counters_.end(); it++) + it != counters_.end(); ++it) { _return[it->first] = it->second.value; } http://git-wip-us.apache.org/repos/asf/thrift/blob/71f2d8a7/contrib/fb303/cpp/ServiceTracker.cpp ---------------------------------------------------------------------- diff --git a/contrib/fb303/cpp/ServiceTracker.cpp b/contrib/fb303/cpp/ServiceTracker.cpp index 2914ff6..7a61b21 100644 --- a/contrib/fb303/cpp/ServiceTracker.cpp +++ b/contrib/fb303/cpp/ServiceTracker.cpp @@ -251,7 +251,7 @@ ServiceTracker::reportCheckpoint() uint64_t count; for (iter = checkpointServiceDuration_.begin(); iter != checkpointServiceDuration_.end(); - iter++) { + ++iter) { count = iter->second.first; handler_->setCounter(string("checkpoint_count_") + iter->first, count); if (count == 0) { http://git-wip-us.apache.org/repos/asf/thrift/blob/71f2d8a7/lib/cpp/src/thrift/concurrency/ThreadManager.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/ThreadManager.cpp b/lib/cpp/src/thrift/concurrency/ThreadManager.cpp index 255d237..0e7ccd8 100644 --- a/lib/cpp/src/thrift/concurrency/ThreadManager.cpp +++ b/lib/cpp/src/thrift/concurrency/ThreadManager.cpp @@ -332,7 +332,7 @@ void ThreadManager::Impl::addWorker(size_t value) { } for (std::set<shared_ptr<Thread> >::iterator ix = newThreads.begin(); ix != newThreads.end(); - ix++) { + ++ix) { shared_ptr<ThreadManager::Worker> worker = dynamic_pointer_cast<ThreadManager::Worker, Runnable>((*ix)->runnable()); worker->state_ = ThreadManager::Worker::STARTING; @@ -427,7 +427,7 @@ void ThreadManager::Impl::removeWorker(size_t value) { for (std::set<shared_ptr<Thread> >::iterator ix = deadWorkers_.begin(); ix != deadWorkers_.end(); - ix++) { + ++ix) { idMap_.erase((*ix)->getId()); workers_.erase(*ix); } http://git-wip-us.apache.org/repos/asf/thrift/blob/71f2d8a7/lib/cpp/src/thrift/concurrency/TimerManager.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/concurrency/TimerManager.cpp b/lib/cpp/src/thrift/concurrency/TimerManager.cpp index 60b8c85..122d26e 100644 --- a/lib/cpp/src/thrift/concurrency/TimerManager.cpp +++ b/lib/cpp/src/thrift/concurrency/TimerManager.cpp @@ -117,7 +117,7 @@ public: for (std::set<shared_ptr<Task> >::iterator ix = expiredTasks.begin(); ix != expiredTasks.end(); - ix++) { + ++ix) { (*ix)->run(); }
