Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build warnings: local variable 's' will be copied despite being returned by name #2148

Merged
merged 12 commits into from
Mar 10, 2024

Conversation

aleksraiden
Copy link
Contributor

Fix warning at build like:

[ 85%] Building CXX object CMakeFiles/kvrocks_objs.dir/src/cluster/slot_import.cc.o
/Users/runner/work/kvrocks/kvrocks/src/cluster/replication.cc:78:10: warning: local variable 's' will be copied despite being returned by name [-Wreturn-std-move]
  return s;
         ^
/Users/runner/work/kvrocks/kvrocks/src/cluster/replication.cc:78:10: note: call 'std::move' explicitly to avoid copying
  return s;
         ^
         std::move(s)
[ 85%] Building CXX object CMakeFiles/kvrocks_objs.dir/src/cluster/slot_migrate.cc.o
[ 85%] Building CXX object CMakeFiles/kvrocks_objs.dir/src/cluster/sync_migrate_context.cc.o

Fix warning at build like:

```
[ 85%] Building CXX object CMakeFiles/kvrocks_objs.dir/src/cluster/slot_import.cc.o
/Users/runner/work/kvrocks/kvrocks/src/cluster/replication.cc:78:10: warning: local variable 's' will be copied despite being returned by name [-Wreturn-std-move]
  return s;
         ^
/Users/runner/work/kvrocks/kvrocks/src/cluster/replication.cc:78:10: note: call 'std::move' explicitly to avoid copying
  return s;
         ^
         std::move(s)
[ 85%] Building CXX object CMakeFiles/kvrocks_objs.dir/src/cluster/slot_migrate.cc.o
[ 85%] Building CXX object CMakeFiles/kvrocks_objs.dir/src/cluster/sync_migrate_context.cc.o
```
@aleksraiden aleksraiden changed the title Fix build warning: warning: local variable 's' will be copied despite being returned by name Fix build warnings: local variable 's' will be copied despite being returned by name Mar 9, 2024
@aleksraiden aleksraiden marked this pull request as draft March 9, 2024 23:57
@aleksraiden aleksraiden marked this pull request as ready for review March 10, 2024 00:57
@@ -75,7 +75,7 @@ Status FeedSlaveThread::Start() {
conn_ = nullptr; // prevent connection was freed when failed to start the thread
}

return s;
return std::move(s);
Copy link
Member

Choose a reason for hiding this comment

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

Hmm C++17 would applying nrvo for this ? @PragmaTwice

Copy link
Member

@PragmaTwice PragmaTwice Mar 10, 2024

Choose a reason for hiding this comment

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

The type of returned value is not the same as the return type. So no.

Copy link

@git-hulk git-hulk merged commit 030d15e into unstable Mar 10, 2024
59 checks passed
@PragmaTwice PragmaTwice deleted the aleksraiden-fix-warning-build-1 branch March 18, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants