diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-09-20 15:41:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-20 15:41:44 +0800 |
commit | d6bc0a0631897f893c06dcc9382bf29f23db6b26 (patch) | |
tree | bd4fba85b391e7005d2c69e88b7a25b5ab37c700 | |
parent | 137b214be471dd690aeadaf0e02b9ad0915d9e84 (diff) | |
parent | f958463416e88a769d0904ca3da48dac8a9c1c5a (diff) | |
download | dexon-solidity-d6bc0a0631897f893c06dcc9382bf29f23db6b26.tar.gz dexon-solidity-d6bc0a0631897f893c06dcc9382bf29f23db6b26.tar.zst dexon-solidity-d6bc0a0631897f893c06dcc9382bf29f23db6b26.zip |
Merge pull request #2929 from ethereum/cppcheck
Another set of improvements found by cppcheck
-rw-r--r-- | libdevcore/SHA3.cpp | 5 | ||||
-rw-r--r-- | libdevcore/SwarmHash.h | 4 | ||||
-rw-r--r-- | libevmasm/ConstantOptimiser.h | 2 | ||||
-rw-r--r-- | libevmasm/GasMeter.cpp | 4 | ||||
-rw-r--r-- | libsolidity/analysis/DocStringAnalyser.cpp | 16 | ||||
-rw-r--r-- | libsolidity/analysis/NameAndTypeResolver.h | 2 | ||||
-rw-r--r-- | libsolidity/analysis/PostTypeChecker.h | 4 | ||||
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.cpp | 4 | ||||
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.h | 20 | ||||
-rw-r--r-- | libsolidity/codegen/ContractCompiler.h | 4 | ||||
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 2 | ||||
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.h | 2 | ||||
-rw-r--r-- | libsolidity/formal/SMTLib2Interface.h | 2 | ||||
-rw-r--r-- | libsolidity/interface/ErrorReporter.h | 2 | ||||
-rw-r--r-- | test/ExecutionFramework.h | 2 | ||||
-rw-r--r-- | test/RPCSession.h | 6 | ||||
-rw-r--r-- | test/libdevcore/Whiskers.cpp (renamed from test/libdevcore/MiniMoustache.cpp) | 0 | ||||
-rw-r--r-- | test/libsolidity/AnalysisFramework.h | 4 |
18 files changed, 42 insertions, 43 deletions
diff --git a/libdevcore/SHA3.cpp b/libdevcore/SHA3.cpp index 4d82ec85..b0e40ccb 100644 --- a/libdevcore/SHA3.cpp +++ b/libdevcore/SHA3.cpp @@ -97,10 +97,9 @@ static const uint64_t RC[24] = \ static inline void keccakf(void* state) { uint64_t* a = (uint64_t*)state; uint64_t b[5] = {0}; - uint64_t t = 0; - uint8_t x, y; for (int i = 0; i < 24; i++) { + uint8_t x, y; // Theta FOR5(x, 1, b[x] = 0; @@ -110,7 +109,7 @@ static inline void keccakf(void* state) { FOR5(y, 5, a[y + x] ^= b[(x + 4) % 5] ^ rol(b[(x + 1) % 5], 1); )) // Rho and pi - t = a[1]; + uint64_t t = a[1]; x = 0; REPEAT24(b[0] = a[pi[x]]; a[pi[x]] = rol(t, rho[x]); diff --git a/libdevcore/SwarmHash.h b/libdevcore/SwarmHash.h index a5da96f5..a06f7bda 100644 --- a/libdevcore/SwarmHash.h +++ b/libdevcore/SwarmHash.h @@ -26,7 +26,7 @@ namespace dev { -/// Compute the "swarm hash" of @a _data -h256 swarmHash(std::string const& _data); +/// Compute the "swarm hash" of @a _input +h256 swarmHash(std::string const& _input); } diff --git a/libevmasm/ConstantOptimiser.h b/libevmasm/ConstantOptimiser.h index 82982e25..c450b0b4 100644 --- a/libevmasm/ConstantOptimiser.h +++ b/libevmasm/ConstantOptimiser.h @@ -91,7 +91,7 @@ protected: } /// Replaces all constants i by the code given in @a _replacement[i]. - static void replaceConstants(AssemblyItems& _items, std::map<u256, AssemblyItems> const& _replacement); + static void replaceConstants(AssemblyItems& _items, std::map<u256, AssemblyItems> const& _replacements); Params m_params; u256 const& m_value; diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index 6a7c80e0..dad952bc 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -189,9 +189,9 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _ return gas; } -GasMeter::GasConsumption GasMeter::wordGas(u256 const& _multiplier, ExpressionClasses::Id _position) +GasMeter::GasConsumption GasMeter::wordGas(u256 const& _multiplier, ExpressionClasses::Id _value) { - u256 const* value = m_state->expressionClasses().knownConstant(_position); + u256 const* value = m_state->expressionClasses().knownConstant(_value); if (!value) return GasConsumption::infinite(); return GasConsumption(_multiplier * ((*value + 31) / 32)); diff --git a/libsolidity/analysis/DocStringAnalyser.cpp b/libsolidity/analysis/DocStringAnalyser.cpp index d08c4eb5..b3fb5258 100644 --- a/libsolidity/analysis/DocStringAnalyser.cpp +++ b/libsolidity/analysis/DocStringAnalyser.cpp @@ -38,30 +38,30 @@ bool DocStringAnalyser::analyseDocStrings(SourceUnit const& _sourceUnit) return !m_errorOccured; } -bool DocStringAnalyser::visit(ContractDefinition const& _node) +bool DocStringAnalyser::visit(ContractDefinition const& _contract) { static const set<string> validTags = set<string>{"author", "title", "dev", "notice"}; - parseDocStrings(_node, _node.annotation(), validTags, "contracts"); + parseDocStrings(_contract, _contract.annotation(), validTags, "contracts"); return true; } -bool DocStringAnalyser::visit(FunctionDefinition const& _node) +bool DocStringAnalyser::visit(FunctionDefinition const& _function) { - handleCallable(_node, _node, _node.annotation()); + handleCallable(_function, _function, _function.annotation()); return true; } -bool DocStringAnalyser::visit(ModifierDefinition const& _node) +bool DocStringAnalyser::visit(ModifierDefinition const& _modifier) { - handleCallable(_node, _node, _node.annotation()); + handleCallable(_modifier, _modifier, _modifier.annotation()); return true; } -bool DocStringAnalyser::visit(EventDefinition const& _node) +bool DocStringAnalyser::visit(EventDefinition const& _event) { - handleCallable(_node, _node, _node.annotation()); + handleCallable(_event, _event, _event.annotation()); return true; } diff --git a/libsolidity/analysis/NameAndTypeResolver.h b/libsolidity/analysis/NameAndTypeResolver.h index 59bd3b1f..d83697cd 100644 --- a/libsolidity/analysis/NameAndTypeResolver.h +++ b/libsolidity/analysis/NameAndTypeResolver.h @@ -148,7 +148,7 @@ public: private: bool visit(SourceUnit& _sourceUnit) override; void endVisit(SourceUnit& _sourceUnit) override; - bool visit(ImportDirective& _declaration) override; + bool visit(ImportDirective& _import) override; bool visit(ContractDefinition& _contract) override; void endVisit(ContractDefinition& _contract) override; bool visit(StructDefinition& _struct) override; diff --git a/libsolidity/analysis/PostTypeChecker.h b/libsolidity/analysis/PostTypeChecker.h index dbdf50e0..91d2b0b9 100644 --- a/libsolidity/analysis/PostTypeChecker.h +++ b/libsolidity/analysis/PostTypeChecker.h @@ -50,8 +50,8 @@ private: virtual bool visit(ContractDefinition const& _contract) override; virtual void endVisit(ContractDefinition const& _contract) override; - virtual bool visit(VariableDeclaration const& _declaration) override; - virtual void endVisit(VariableDeclaration const& _declaration) override; + virtual bool visit(VariableDeclaration const& _variable) override; + virtual void endVisit(VariableDeclaration const& _variable) override; virtual bool visit(Identifier const& _identifier) override; diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 6811d3e4..51249f20 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -129,7 +129,7 @@ string ASTJsonConverter::sourceLocationToString(SourceLocation const& _location) return std::to_string(_location.start) + ":" + std::to_string(length) + ":" + std::to_string(sourceIndex); } -string ASTJsonConverter::namePathToString(std::vector<ASTString> const& _namePath) const +string ASTJsonConverter::namePathToString(std::vector<ASTString> const& _namePath) { return boost::algorithm::join(_namePath, "."); } @@ -171,7 +171,7 @@ void ASTJsonConverter::appendExpressionAttributes( _attributes += exprAttributes; } -Json::Value ASTJsonConverter::inlineAssemblyIdentifierToJson(pair<assembly::Identifier const* ,InlineAssemblyAnnotation::ExternalIdentifierInfo> _info) +Json::Value ASTJsonConverter::inlineAssemblyIdentifierToJson(pair<assembly::Identifier const* ,InlineAssemblyAnnotation::ExternalIdentifierInfo> _info) const { Json::Value tuple(Json::objectValue); tuple["src"] = sourceLocationToString(_info.first->location); diff --git a/libsolidity/ast/ASTJsonConverter.h b/libsolidity/ast/ASTJsonConverter.h index 60c660c1..9a886220 100644 --- a/libsolidity/ast/ASTJsonConverter.h +++ b/libsolidity/ast/ASTJsonConverter.h @@ -120,7 +120,7 @@ private: std::vector<std::pair<std::string, Json::Value>>&& _attributes ); std::string sourceLocationToString(SourceLocation const& _location) const; - std::string namePathToString(std::vector<ASTString> const& _namePath) const; + static std::string namePathToString(std::vector<ASTString> const& _namePath); static Json::Value idOrNull(ASTNode const* _pt) { return _pt ? Json::Value(nodeId(*_pt)) : Json::nullValue; @@ -129,13 +129,13 @@ private: { return _node ? toJson(*_node) : Json::nullValue; } - Json::Value inlineAssemblyIdentifierToJson(std::pair<assembly::Identifier const* , InlineAssemblyAnnotation::ExternalIdentifierInfo> _info); - std::string location(VariableDeclaration::Location _location); - std::string contractKind(ContractDefinition::ContractKind _kind); - std::string functionCallKind(FunctionCallKind _kind); - std::string literalTokenKind(Token::Value _token); - std::string type(Expression const& _expression); - std::string type(VariableDeclaration const& _varDecl); + Json::Value inlineAssemblyIdentifierToJson(std::pair<assembly::Identifier const* , InlineAssemblyAnnotation::ExternalIdentifierInfo> _info) const; + static std::string location(VariableDeclaration::Location _location); + static std::string contractKind(ContractDefinition::ContractKind _kind); + static std::string functionCallKind(FunctionCallKind _kind); + static std::string literalTokenKind(Token::Value _token); + static std::string type(Expression const& _expression); + static std::string type(VariableDeclaration const& _varDecl); static int nodeId(ASTNode const& _node) { return _node.id(); @@ -151,8 +151,8 @@ private: } return tmp; } - Json::Value typePointerToJson(TypePointer _tp); - Json::Value typePointerToJson(std::shared_ptr<std::vector<TypePointer>> _tps); + static Json::Value typePointerToJson(TypePointer _tp); + static Json::Value typePointerToJson(std::shared_ptr<std::vector<TypePointer>> _tps); void appendExpressionAttributes( std::vector<std::pair<std::string, Json::Value>> &_attributes, ExpressionAnnotation const& _annotation diff --git a/libsolidity/codegen/ContractCompiler.h b/libsolidity/codegen/ContractCompiler.h index 38c1e045..7c5ee59f 100644 --- a/libsolidity/codegen/ContractCompiler.h +++ b/libsolidity/codegen/ContractCompiler.h @@ -96,8 +96,8 @@ private: virtual bool visit(IfStatement const& _ifStatement) override; virtual bool visit(WhileStatement const& _whileStatement) override; virtual bool visit(ForStatement const& _forStatement) override; - virtual bool visit(Continue const& _continue) override; - virtual bool visit(Break const& _break) override; + virtual bool visit(Continue const& _continueStatement) override; + virtual bool visit(Break const& _breakStatement) override; virtual bool visit(Return const& _return) override; virtual bool visit(Throw const& _throw) override; virtual bool visit(VariableDeclarationStatement const& _variableDeclarationStatement) override; diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 631a25ff..c94baa10 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1819,7 +1819,7 @@ void ExpressionCompiler::setLValueToStorageItem(Expression const& _expression) setLValue<StorageItem>(_expression, *_expression.annotation().type); } -bool ExpressionCompiler::cleanupNeededForOp(Type::Category _type, Token::Value _op) const +bool ExpressionCompiler::cleanupNeededForOp(Type::Category _type, Token::Value _op) { if (Token::isCompareOp(_op) || Token::isShiftOp(_op)) return true; diff --git a/libsolidity/codegen/ExpressionCompiler.h b/libsolidity/codegen/ExpressionCompiler.h index 5f6c3d64..cdfa096e 100644 --- a/libsolidity/codegen/ExpressionCompiler.h +++ b/libsolidity/codegen/ExpressionCompiler.h @@ -119,7 +119,7 @@ private: /// @returns true if the operator applied to the given type requires a cleanup prior to the /// operation. - bool cleanupNeededForOp(Type::Category _type, Token::Value _op) const; + static bool cleanupNeededForOp(Type::Category _type, Token::Value _op); /// @returns the CompilerUtils object containing the current context. CompilerUtils utils(); diff --git a/libsolidity/formal/SMTLib2Interface.h b/libsolidity/formal/SMTLib2Interface.h index b8dac366..63188acd 100644 --- a/libsolidity/formal/SMTLib2Interface.h +++ b/libsolidity/formal/SMTLib2Interface.h @@ -41,7 +41,7 @@ namespace smt class SMTLib2Interface: public SolverInterface, public boost::noncopyable { public: - SMTLib2Interface(ReadCallback::Callback const& _queryCallback); + explicit SMTLib2Interface(ReadCallback::Callback const& _queryCallback); void reset() override; diff --git a/libsolidity/interface/ErrorReporter.h b/libsolidity/interface/ErrorReporter.h index 6f7ef51d..a87db21d 100644 --- a/libsolidity/interface/ErrorReporter.h +++ b/libsolidity/interface/ErrorReporter.h @@ -86,7 +86,7 @@ public: void fatalTypeError(SourceLocation const& _location, std::string const& _description); - void docstringParsingError(std::string const& _location); + void docstringParsingError(std::string const& _description); ErrorList const& errors() const; diff --git a/test/ExecutionFramework.h b/test/ExecutionFramework.h index ba385dee..e8d8d111 100644 --- a/test/ExecutionFramework.h +++ b/test/ExecutionFramework.h @@ -262,7 +262,7 @@ protected: void sendMessage(bytes const& _data, bool _isCreation, u256 const& _value = 0); void sendEther(Address const& _to, u256 const& _value); size_t currentTimestamp(); - size_t blockTimestamp(u256 number); + size_t blockTimestamp(u256 _number); /// @returns the (potentially newly created) _ith address. Address account(size_t _i); diff --git a/test/RPCSession.h b/test/RPCSession.h index 558cb99f..eae6a09c 100644 --- a/test/RPCSession.h +++ b/test/RPCSession.h @@ -40,7 +40,7 @@ class IPCSocket : public boost::noncopyable { public: - IPCSocket(std::string const& _path); + explicit IPCSocket(std::string const& _path); std::string sendRequest(std::string const& _req); ~IPCSocket() { CloseHandle(m_socket); } @@ -55,7 +55,7 @@ private: class IPCSocket: public boost::noncopyable { public: - IPCSocket(std::string const& _path); + explicit IPCSocket(std::string const& _path); std::string sendRequest(std::string const& _req); ~IPCSocket() { close(m_socket); } @@ -107,7 +107,7 @@ public: Json::Value eth_getBlockByNumber(std::string const& _blockNumber, bool _fullObjects); std::string eth_call(TransactionData const& _td, std::string const& _blockNumber); TransactionReceipt eth_getTransactionReceipt(std::string const& _transactionHash); - std::string eth_sendTransaction(TransactionData const& _transactionData); + std::string eth_sendTransaction(TransactionData const& _td); std::string eth_sendTransaction(std::string const& _transaction); std::string eth_getBalance(std::string const& _address, std::string const& _blockNumber); std::string eth_getStorageRoot(std::string const& _address, std::string const& _blockNumber); diff --git a/test/libdevcore/MiniMoustache.cpp b/test/libdevcore/Whiskers.cpp index 84149173..84149173 100644 --- a/test/libdevcore/MiniMoustache.cpp +++ b/test/libdevcore/Whiskers.cpp diff --git a/test/libsolidity/AnalysisFramework.h b/test/libsolidity/AnalysisFramework.h index f73f06c2..172ae01b 100644 --- a/test/libsolidity/AnalysisFramework.h +++ b/test/libsolidity/AnalysisFramework.h @@ -59,8 +59,8 @@ protected: void printErrors(); - ContractDefinition const* retrieveContractByName(SourceUnit const& _source, std::string const& _name); - FunctionTypePointer retrieveFunctionBySignature( + static ContractDefinition const* retrieveContractByName(SourceUnit const& _source, std::string const& _name); + static FunctionTypePointer retrieveFunctionBySignature( ContractDefinition const& _contract, std::string const& _signature ); |