Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/eosiolib/contracts/eosio/key_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ inline partial_key make_key(T&& t) {
return partial_key(convert_to_key(std::forward<T>(t)));
}
inline partial_key make_key(partial_key&& t) {
return t;
return std::move(t);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as understand, you shouldn't use std::move(t) here. You can check https://stackoverflow.com/questions/14856344/when-should-stdmove-be-used-on-a-function-return-value for explanations about when you should (or should not) use return std::move(...);

Copy link
Copy Markdown
Author

@Max-B1 Max-B1 Jun 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure about the purpose of this function. The old version of it creates a copy of t. So I thought it will make more sense to make it move the content of t.
GCC is complaining about it:

.../key_value.hpp:173:11: warning: local variable 't' will be copied despite being returned by name [-Wreturn-std-move]
   return t;
          ^
.../key_value.hpp:173:11: note: call 'std::move' explicitly to avoid copying
   return t;
          ^
          std::move(t)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe move is appropriate here.

}
inline partial_key make_key(partial_key& t) {
return t;
Expand Down
4 changes: 2 additions & 2 deletions libraries/eosiolib/tester/crt0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
int main(int argc, char** argv);

extern "C" __attribute__((eosio_wasm_entry)) void initialize() {}
extern "C" __attribute__((eosio_wasm_entry)) void start(void (*f)()) {
extern "C" __attribute__((eosio_wasm_entry)) int start(void (*f)()) {
std::vector<std::string> args = eosio::get_args();
char buf[] = "eosio-tester";
std::vector<char*> argv;
argv.push_back(buf);
for(std::string& s : args) {
argv.push_back(const_cast<char*>(s.data()));
}
main(argv.size(), argv.data());
return main(argv.size(), argv.data());
}
4 changes: 2 additions & 2 deletions libraries/eosiolib/tester/tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ void build_history_result(eosio::test_chain::get_history_result& history_result,
history_result.block = std::move(*blocks_result.block);
}
if (!blocks_result.traces.empty()) {
blocks_result.traces.unpack(history_result.traces);
unpack(blocks_result.traces, history_result.traces);
}
if (blocks_result.deltas.empty()) {
blocks_result.deltas.unpack(history_result.deltas);
unpack(blocks_result.deltas, history_result.deltas);
}
}

Expand Down