aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-08-22 21:39:50 +0800
committerGitHub <noreply@github.com>2017-08-22 21:39:50 +0800
commit210b4870a805620329793c8ba2177a3ff6e7b477 (patch)
tree65b5afa20b8a2ba5466bb681b5216cc655fd74d6
parentbadb269502643c779ead6e53978175a2e8f43594 (diff)
parentf2d6226718a226ae4764bd7d1379c6e50c7f269a (diff)
downloaddexon-solidity-210b4870a805620329793c8ba2177a3ff6e7b477.tar.gz
dexon-solidity-210b4870a805620329793c8ba2177a3ff6e7b477.tar.zst
dexon-solidity-210b4870a805620329793c8ba2177a3ff6e7b477.zip
Merge pull request #2775 from ethereum/coverity
Fix some issues found by Coverity
-rw-r--r--libdevcore/FixedHash.h2
-rw-r--r--libevmasm/AssemblyItem.cpp12
-rw-r--r--libevmasm/CommonSubexpressionEliminator.cpp1
-rw-r--r--libevmasm/CommonSubexpressionEliminator.h2
-rw-r--r--libsolidity/ast/AST.cpp1
-rw-r--r--libsolidity/ast/Types.cpp8
6 files changed, 14 insertions, 12 deletions
diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h
index 1c37b675..141e9ffd 100644
--- a/libdevcore/FixedHash.h
+++ b/libdevcore/FixedHash.h
@@ -27,6 +27,7 @@
#include <cstdint>
#include <algorithm>
#include <boost/functional/hash.hpp>
+#include <boost/io/ios_state.hpp>
#include "CommonData.h"
namespace dev
@@ -224,6 +225,7 @@ template<> inline size_t FixedHash<32>::hash::operator()(FixedHash<32> const& va
template <unsigned N>
inline std::ostream& operator<<(std::ostream& _out, FixedHash<N> const& _h)
{
+ boost::io::ios_all_saver guard(_out);
_out << std::noshowbase << std::hex << std::setfill('0');
for (unsigned i = 0; i < N; ++i)
_out << std::setw(2) << (int)_h[i];
diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp
index 76104866..419a8c0b 100644
--- a/libevmasm/AssemblyItem.cpp
+++ b/libevmasm/AssemblyItem.cpp
@@ -219,10 +219,10 @@ ostream& dev::eth::operator<<(ostream& _out, AssemblyItem const& _item)
_out << "\t" << _item.getJumpTypeAsString();
break;
case Push:
- _out << " PUSH " << hex << _item.data();
+ _out << " PUSH " << hex << _item.data() << dec;
break;
case PushString:
- _out << " PushString" << hex << (unsigned)_item.data();
+ _out << " PushString" << hex << (unsigned)_item.data() << dec;
break;
case PushTag:
{
@@ -237,19 +237,19 @@ ostream& dev::eth::operator<<(ostream& _out, AssemblyItem const& _item)
_out << " Tag " << _item.data();
break;
case PushData:
- _out << " PushData " << hex << (unsigned)_item.data();
+ _out << " PushData " << hex << (unsigned)_item.data() << dec;
break;
case PushSub:
- _out << " PushSub " << hex << size_t(_item.data());
+ _out << " PushSub " << hex << size_t(_item.data()) << dec;
break;
case PushSubSize:
- _out << " PushSubSize " << hex << size_t(_item.data());
+ _out << " PushSubSize " << hex << size_t(_item.data()) << dec;
break;
case PushProgramSize:
_out << " PushProgramSize";
break;
case PushLibraryAddress:
- _out << " PushLibraryAddress " << hex << h256(_item.data()).abridgedMiddle();
+ _out << " PushLibraryAddress " << hex << h256(_item.data()).abridgedMiddle() << dec;
break;
case UndefinedItem:
_out << " ???";
diff --git a/libevmasm/CommonSubexpressionEliminator.cpp b/libevmasm/CommonSubexpressionEliminator.cpp
index 70324e7f..293cb02c 100644
--- a/libevmasm/CommonSubexpressionEliminator.cpp
+++ b/libevmasm/CommonSubexpressionEliminator.cpp
@@ -220,6 +220,7 @@ void CSECodeGenerator::addDependencies(Id _c)
if (m_neededBy.count(_c))
return; // we already computed the dependencies for _c
ExpressionClasses::Expression expr = m_expressionClasses.representative(_c);
+ assertThrow(expr.item, OptimizerException, "");
if (expr.item->type() == UndefinedItem)
BOOST_THROW_EXCEPTION(
// If this exception happens, we need to find a different way to generate the
diff --git a/libevmasm/CommonSubexpressionEliminator.h b/libevmasm/CommonSubexpressionEliminator.h
index f2473200..0b957a0e 100644
--- a/libevmasm/CommonSubexpressionEliminator.h
+++ b/libevmasm/CommonSubexpressionEliminator.h
@@ -147,7 +147,7 @@ private:
AssemblyItems m_generatedItems;
/// Current height of the stack relative to the start.
- int m_stackHeight;
+ int m_stackHeight = 0;
/// If (b, a) is in m_requests then b is needed to compute a.
std::multimap<Id, Id> m_neededBy;
/// Current content of the stack.
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp
index e173237e..605daf55 100644
--- a/libsolidity/ast/AST.cpp
+++ b/libsolidity/ast/AST.cpp
@@ -188,7 +188,6 @@ vector<pair<FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::inter
{
if (!m_interfaceFunctionList)
{
- set<string> functionsSeen;
set<string> signaturesSeen;
m_interfaceFunctionList.reset(new vector<pair<FixedHash<4>, FunctionTypePointer>>());
for (ContractDefinition const* contract: annotation().linearizedBaseContracts)
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index adf41229..5e61cdee 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -739,18 +739,18 @@ bool RationalNumberType::isImplicitlyConvertibleTo(Type const& _convertTo) const
{
if (_convertTo.category() == Category::Integer)
{
- auto targetType = dynamic_cast<IntegerType const*>(&_convertTo);
if (m_value == rational(0))
return true;
if (isFractional())
return false;
- int forSignBit = (targetType->isSigned() ? 1 : 0);
+ IntegerType const& targetType = dynamic_cast<IntegerType const&>(_convertTo);
+ int forSignBit = (targetType.isSigned() ? 1 : 0);
if (m_value > rational(0))
{
- if (m_value.numerator() <= (u256(-1) >> (256 - targetType->numBits() + forSignBit)))
+ if (m_value.numerator() <= (u256(-1) >> (256 - targetType.numBits() + forSignBit)))
return true;
}
- else if (targetType->isSigned() && -m_value.numerator() <= (u256(1) << (targetType->numBits() - forSignBit)))
+ else if (targetType.isSigned() && -m_value.numerator() <= (u256(1) << (targetType.numBits() - forSignBit)))
return true;
return false;
}