You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "JosiahWI (via GitHub)" <gi...@apache.org> on 2024/08/12 14:22:48 UTC
[PR] Fix a bunch of COPY_INSTEAD_OF_MOVE Coverity CIDs [trafficserver]
JosiahWI opened a new pull request, #11668:
URL: https://github.com/apache/trafficserver/pull/11668
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix a bunch of COPY_INSTEAD_OF_MOVE Coverity CIDs [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI merged PR #11668:
URL: https://github.com/apache/trafficserver/pull/11668
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix a bunch of COPY_INSTEAD_OF_MOVE Coverity CIDs [trafficserver]
Posted by "brbzull0 (via GitHub)" <gi...@apache.org>.
brbzull0 commented on PR #11668:
URL: https://github.com/apache/trafficserver/pull/11668#issuecomment-2284145786
when you say, "a bunch" you mean it! :rofl:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix a bunch of COPY_INSTEAD_OF_MOVE Coverity CIDs [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on code in PR #11668:
URL: https://github.com/apache/trafficserver/pull/11668#discussion_r1716961065
##########
plugins/statichit/statichit.cc:
##########
@@ -71,7 +73,7 @@ struct StaticHitConfig {
base_path = std::filesystem::weakly_canonical(base_path);
if (std::filesystem::is_directory(base_path)) {
- dirPath = base_path;
+ dirPath = std::move(base_path);
Review Comment:
Weirdly, Coverity does not have a CID for it. Maybe it has to do with the difference in types: `std::filesystem::path` vs `std::string` (but I don't know why that would matter here). I changed it anyway for consistency.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix a bunch of COPY_INSTEAD_OF_MOVE Coverity CIDs [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on code in PR #11668:
URL: https://github.com/apache/trafficserver/pull/11668#discussion_r1716961065
##########
plugins/statichit/statichit.cc:
##########
@@ -71,7 +73,7 @@ struct StaticHitConfig {
base_path = std::filesystem::weakly_canonical(base_path);
if (std::filesystem::is_directory(base_path)) {
- dirPath = base_path;
+ dirPath = std::move(base_path);
Review Comment:
Weirdly, Coverity does not have a CID for it. Maybe it has to do with the difference in types: `std::filesystem::path` vs `std::string`. I changed it anyway for consistency.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix a bunch of COPY_INSTEAD_OF_MOVE Coverity CIDs [trafficserver]
Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on code in PR #11668:
URL: https://github.com/apache/trafficserver/pull/11668#discussion_r1716152988
##########
plugins/experimental/stek_share/log_store.cc:
##########
@@ -90,7 +91,7 @@ STEKShareLogStore::write_at(uint64_t index, nuraft::ptr<nuraft::log_entry> &entr
while (itr != logs_.end()) {
itr = logs_.erase(itr);
}
- logs_[index] = clone;
+ logs_[index] = std::move(clone);
Review Comment:
This can be `logs_.emplace(index, make_clone(entry))` to get `std::forward`
##########
src/iocore/net/SSLSessionCache.cc:
##########
@@ -353,7 +354,7 @@ SSLOriginSessionCache::insert_session(const std::string &lookup_key, SSL_SESSION
// Create the shared pointer to the session, with the custom deleter
std::shared_ptr<SSL_SESSION> shared_sess(sess_ptr, SSLSessDeleter);
ssl_curve_id curve = (ssl == nullptr) ? 0 : SSLGetCurveNID(ssl);
- std::unique_ptr<SSLOriginSession> ssl_orig_session(new SSLOriginSession(lookup_key, curve, shared_sess));
+ std::unique_ptr<SSLOriginSession> ssl_orig_session(new SSLOriginSession(lookup_key, curve, std::move(shared_sess)));
Review Comment:
You can avoid the temp and move if you move the construction to the argument:
```
std::unique_ptr<SSLOriginSession> ssl_orig_session(new SSLOriginSession(lookup_key, curve, std::shared_ptr<SSL_SESSION>(sess_ptr, SSLSessDeleter)));
```
##########
src/traffic_layout/engine.cc:
##########
@@ -362,7 +363,7 @@ LayoutEngine::remove_runroot()
return;
}
- std::string clean_root = path;
+ std::string clean_root = std::move(path);
Review Comment:
Not sure what the intent here was. Does this code want a copy of path? If so, your std::move is counter to that goal. If not, then this is an unnecessary temp.
##########
plugins/statichit/statichit.cc:
##########
@@ -71,7 +73,7 @@ struct StaticHitConfig {
base_path = std::filesystem::weakly_canonical(base_path);
if (std::filesystem::is_directory(base_path)) {
- dirPath = base_path;
+ dirPath = std::move(base_path);
Review Comment:
does coverity not have a problem with the assignment to `filePath` below?
##########
src/traffic_layout/engine.cc:
##########
@@ -276,7 +277,7 @@ LayoutEngine::create_runroot()
std::string value = it.second.as<std::string>();
auto iter = new_map.find(key);
if (iter != new_map.end()) {
- iter->second = value;
+ iter->second = std::move(value);
Review Comment:
You can just remove the `value` variable as its only temp
##########
src/iocore/net/SSLUtils.cc:
##########
@@ -1677,7 +1679,8 @@ SSLMultiCertConfigLoader::_store_ssl_ctx(SSLCertLookup *lookup, const shared_SSL
std::vector<SSLLoadingContext> ctxs = this->init_server_ssl_ctx(data, sslMultCertSettings.get());
for (const auto &loadingctx : ctxs) {
shared_SSL_CTX ctx(loadingctx.ctx, SSL_CTX_free);
- if (!sslMultCertSettings || !this->_store_single_ssl_ctx(lookup, sslMultCertSettings, ctx, loadingctx.ctx_type, common_names)) {
+ if (!sslMultCertSettings ||
+ !this->_store_single_ssl_ctx(lookup, sslMultCertSettings, std::move(ctx), loadingctx.ctx_type, common_names)) {
Review Comment:
Could move the construction to the arglist here as well. This will also avoid an unused tmp if the disjunction shorts
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix a bunch of COPY_INSTEAD_OF_MOVE Coverity CIDs [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on code in PR #11668:
URL: https://github.com/apache/trafficserver/pull/11668#discussion_r1716793252
##########
src/traffic_layout/engine.cc:
##########
@@ -362,7 +363,7 @@ LayoutEngine::remove_runroot()
return;
}
- std::string clean_root = path;
+ std::string clean_root = std::move(path);
Review Comment:
I think the intent was to distinguish whether the string has been sanitized or not, even though it's the same string object being modified. I think `clean_root` should be a reference - there's no need to copy or move.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix a bunch of COPY_INSTEAD_OF_MOVE Coverity CIDs [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on code in PR #11668:
URL: https://github.com/apache/trafficserver/pull/11668#discussion_r1716793252
##########
src/traffic_layout/engine.cc:
##########
@@ -362,7 +363,7 @@ LayoutEngine::remove_runroot()
return;
}
- std::string clean_root = path;
+ std::string clean_root = std::move(path);
Review Comment:
I think the intent was to describe the data contained in the string, even though it's the same string object being modified. I think `clean_root` should be a reference - there's no need to copy or move.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix a bunch of COPY_INSTEAD_OF_MOVE Coverity CIDs [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on code in PR #11668:
URL: https://github.com/apache/trafficserver/pull/11668#discussion_r1716793252
##########
src/traffic_layout/engine.cc:
##########
@@ -362,7 +363,7 @@ LayoutEngine::remove_runroot()
return;
}
- std::string clean_root = path;
+ std::string clean_root = std::move(path);
Review Comment:
I think the intent was to distinguish whether the string has been sanitized or not, even though it's the same string being worked on. I think `clean_root` should be a reference - there's no need to copy or move.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix a bunch of COPY_INSTEAD_OF_MOVE Coverity CIDs [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on code in PR #11668:
URL: https://github.com/apache/trafficserver/pull/11668#discussion_r1716776382
##########
plugins/statichit/statichit.cc:
##########
@@ -71,7 +73,7 @@ struct StaticHitConfig {
base_path = std::filesystem::weakly_canonical(base_path);
if (std::filesystem::is_directory(base_path)) {
- dirPath = base_path;
+ dirPath = std::move(base_path);
Review Comment:
I'm sure it does. I'll figure out which CID it's for and fix it, too.
##########
plugins/statichit/statichit.cc:
##########
@@ -71,7 +73,7 @@ struct StaticHitConfig {
base_path = std::filesystem::weakly_canonical(base_path);
if (std::filesystem::is_directory(base_path)) {
- dirPath = base_path;
+ dirPath = std::move(base_path);
Review Comment:
I'm sure it does. I'll figure out which CID is for it and fix it, too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix a bunch of COPY_INSTEAD_OF_MOVE Coverity CIDs [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on code in PR #11668:
URL: https://github.com/apache/trafficserver/pull/11668#discussion_r1716774126
##########
plugins/experimental/stek_share/log_store.cc:
##########
@@ -90,7 +91,7 @@ STEKShareLogStore::write_at(uint64_t index, nuraft::ptr<nuraft::log_entry> &entr
while (itr != logs_.end()) {
itr = logs_.erase(itr);
}
- logs_[index] = clone;
+ logs_[index] = std::move(clone);
Review Comment:
The reason this uses a temporary is to reduce the amount of work done while holding the logs lock. Thoughts?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix a bunch of COPY_INSTEAD_OF_MOVE Coverity CIDs [trafficserver]
Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on code in PR #11668:
URL: https://github.com/apache/trafficserver/pull/11668#discussion_r1716931700
##########
plugins/experimental/stek_share/log_store.cc:
##########
@@ -90,7 +91,7 @@ STEKShareLogStore::write_at(uint64_t index, nuraft::ptr<nuraft::log_entry> &entr
while (itr != logs_.end()) {
itr = logs_.erase(itr);
}
- logs_[index] = clone;
+ logs_[index] = std::move(clone);
Review Comment:
oh ok, sounds good then
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix a bunch of COPY_INSTEAD_OF_MOVE Coverity CIDs [trafficserver]
Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on code in PR #11668:
URL: https://github.com/apache/trafficserver/pull/11668#discussion_r1717089569
##########
plugins/experimental/stek_share/log_store.cc:
##########
@@ -83,6 +83,7 @@ STEKShareLogStore::append(nuraft::ptr<nuraft::log_entry> &entry)
void
STEKShareLogStore::write_at(uint64_t index, nuraft::ptr<nuraft::log_entry> &entry)
{
+ // We prepare what we can taking the logs lock to minimize time holding it.
Review Comment:
Missing the word `before` perhaps?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org