Skip to content

Commit

Permalink
Fix cppcheck warnings in chain/*.cpp
Browse files Browse the repository at this point in the history
[src/chain/block.cpp:82]: (performance) Variable 'result' is reassigned a value before the old one has been used.
[src/chain/input.cpp:84]: (performance) Variable 'result' is reassigned a value before the old one has been used.
[src/chain/operation.cpp:87]: (performance) Variable 'result' is reassigned a value before the old one has been used.
[src/chain/operation.cpp:95]: (style) The scope of the variable 'size' can be reduced.
[src/chain/output.cpp:81]: (performance) Variable 'result' is reassigned a value before the old one has been used.
[src/chain/point.cpp:84]: (performance) Variable 'result' is reassigned a value before the old one has been used.
[src/chain/transaction.cpp:87]: (performance) Variable result is reassigned a value before the old one has been used.
  • Loading branch information
png85 committed Dec 14, 2015
1 parent cfaec07 commit 3099daf
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/chain/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ bool block::from_data(std::istream& stream)

bool block::from_data(reader& source)
{
auto result = true;
reset();
result = header.from_data(source, false);
auto result = header.from_data(source, false);

if (result)
{
Expand Down
3 changes: 1 addition & 2 deletions src/chain/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ bool input::from_data(std::istream& stream)

bool input::from_data(reader& source)
{
auto result = true;
reset();
result = previous_output.from_data(source);
auto result = previous_output.from_data(source);

if (result)
{
Expand Down
5 changes: 2 additions & 3 deletions src/chain/operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,19 @@ bool operation::from_data(std::istream& stream)

bool operation::from_data(reader& source)
{
auto result = true;
reset();
const auto byte = source.read_byte();
result = source;
auto result = static_cast<bool>(source);

auto op_code = static_cast<opcode>(byte);
if (byte == 0 && op_code != opcode::zero)
return false;

code = ((0 < byte && byte <= 75) ? opcode::special : op_code);

uint32_t size;
if (operation::must_read_data(code))
{
uint32_t size;
read_opcode_data_size(size, code, byte, source);
data = source.read_data(size);
result = (source && (data.size() == size));
Expand Down
3 changes: 1 addition & 2 deletions src/chain/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ bool output::from_data(std::istream& stream)

bool output::from_data(reader& source)
{
auto result = true;
reset();
value = source.read_8_bytes_little_endian();
result = source;
auto result = static_cast<bool>(source);

if (result)
result = script.from_data(source, true,
Expand Down
3 changes: 1 addition & 2 deletions src/chain/point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ bool point::from_data(std::istream& stream)

bool point::from_data(reader& source)
{
auto result = true;
reset();
hash = source.read_hash();
index = source.read_4_bytes_little_endian();
result = source;
auto result = static_cast<bool>(source);
if (!result)
reset();

Expand Down
3 changes: 1 addition & 2 deletions src/chain/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ bool transaction::from_data(std::istream& stream)

bool transaction::from_data(reader& source)
{
auto result = true;
reset();
version = source.read_4_bytes_little_endian();
result = source;
auto result = static_cast<bool>(source);

if (result)
{
Expand Down

0 comments on commit 3099daf

Please sign in to comment.