From fceb4f8e842da86643b65f8afcd5f5e5c0777bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Jan=C3=ADk?= Date: Fri, 27 May 2016 06:57:44 +0200 Subject: [PATCH 1/2] Do not shadow variables --- include/univalue.h | 26 +++++++++++++------------- lib/univalue.cpp | 20 ++++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/univalue.h b/include/univalue.h index 8428b1c683ac38..e48b905bfb8571 100644 --- a/include/univalue.h +++ b/include/univalue.h @@ -56,7 +56,7 @@ class UniValue { bool setNumStr(const std::string& val); bool setInt(uint64_t val); bool setInt(int64_t val); - bool setInt(int val) { return setInt((int64_t)val); } + bool setInt(int val_) { return setInt((int64_t)val_); } bool setFloat(double val); bool setStr(const std::string& val); bool setArray(); @@ -95,28 +95,28 @@ class UniValue { bool push_backV(const std::vector& vec); bool pushKV(const std::string& key, const UniValue& val); - bool pushKV(const std::string& key, const std::string& val) { - UniValue tmpVal(VSTR, val); + bool pushKV(const std::string& key, const std::string& val_) { + UniValue tmpVal(VSTR, val_); return pushKV(key, tmpVal); } bool pushKV(const std::string& key, const char *val_) { - std::string val(val_); - return pushKV(key, val); + std::string _val(val_); + return pushKV(key, _val); } - bool pushKV(const std::string& key, int64_t val) { - UniValue tmpVal(val); + bool pushKV(const std::string& key, int64_t val_) { + UniValue tmpVal(val_); return pushKV(key, tmpVal); } - bool pushKV(const std::string& key, uint64_t val) { - UniValue tmpVal(val); + bool pushKV(const std::string& key, uint64_t val_) { + UniValue tmpVal(val_); return pushKV(key, tmpVal); } - bool pushKV(const std::string& key, int val) { - UniValue tmpVal((int64_t)val); + bool pushKV(const std::string& key, int val_) { + UniValue tmpVal((int64_t)val_); return pushKV(key, tmpVal); } - bool pushKV(const std::string& key, double val) { - UniValue tmpVal(val); + bool pushKV(const std::string& key, double val_) { + UniValue tmpVal(val_); return pushKV(key, tmpVal); } bool pushKVs(const UniValue& obj); diff --git a/lib/univalue.cpp b/lib/univalue.cpp index 0076d6678ec798..70cac304a720be 100644 --- a/lib/univalue.cpp +++ b/lib/univalue.cpp @@ -119,32 +119,32 @@ bool UniValue::setNumStr(const string& val_) return true; } -bool UniValue::setInt(uint64_t val) +bool UniValue::setInt(uint64_t val_) { string s; ostringstream oss; - oss << val; + oss << val_; return setNumStr(oss.str()); } -bool UniValue::setInt(int64_t val) +bool UniValue::setInt(int64_t val_) { string s; ostringstream oss; - oss << val; + oss << val_; return setNumStr(oss.str()); } -bool UniValue::setFloat(double val) +bool UniValue::setFloat(double val_) { string s; ostringstream oss; - oss << std::setprecision(16) << val; + oss << std::setprecision(16) << val_; bool ret = setNumStr(oss.str()); typ = VNUM; @@ -173,12 +173,12 @@ bool UniValue::setObject() return true; } -bool UniValue::push_back(const UniValue& val) +bool UniValue::push_back(const UniValue& val_) { if (typ != VARR) return false; - values.push_back(val); + values.push_back(val_); return true; } @@ -192,13 +192,13 @@ bool UniValue::push_backV(const std::vector& vec) return true; } -bool UniValue::pushKV(const std::string& key, const UniValue& val) +bool UniValue::pushKV(const std::string& key, const UniValue& val_) { if (typ != VOBJ) return false; keys.push_back(key); - values.push_back(val); + values.push_back(val_); return true; } From faf260f2f86efd3c10b4605af2915d26bd956e33 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 25 Aug 2016 09:57:00 +0200 Subject: [PATCH 2/2] Rem unused vars and prefer prefix operator for non-primitive type --- lib/univalue.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/univalue.cpp b/lib/univalue.cpp index 70cac304a720be..1f8cee6d298393 100644 --- a/lib/univalue.cpp +++ b/lib/univalue.cpp @@ -121,7 +121,6 @@ bool UniValue::setNumStr(const string& val_) bool UniValue::setInt(uint64_t val_) { - string s; ostringstream oss; oss << val_; @@ -131,7 +130,6 @@ bool UniValue::setInt(uint64_t val_) bool UniValue::setInt(int64_t val_) { - string s; ostringstream oss; oss << val_; @@ -141,7 +139,6 @@ bool UniValue::setInt(int64_t val_) bool UniValue::setFloat(double val_) { - string s; ostringstream oss; oss << std::setprecision(16) << val_; @@ -228,7 +225,7 @@ int UniValue::findKey(const std::string& key) const bool UniValue::checkObject(const std::map& t) { for (std::map::const_iterator it = t.begin(); - it != t.end(); it++) { + it != t.end(); ++it) { int idx = findKey(it->first); if (idx < 0) return false;