Warnings and Errors and Other Things#60986
Conversation
8655cb6 to
eae028f
Compare
src/common/ceph_argparse.cc
Outdated
| char tmp[strlen(first)+1]; | ||
| dashes_to_underscores(first, tmp); | ||
| first = tmp; | ||
| std::vector<char> tmp(strlen(first) + 1); |
There was a problem hiding this comment.
if this PR isa about memory safety, maybe change to strnlen?
There was a problem hiding this comment.
I'm not sure what the limit should be since they're null terminated strings on the command line. ARG_MAX?
There was a problem hiding this comment.
(I guess _POSIX_ARG_MAX might be more portable, since ARG_MAX isn't defined everywhere. I could potentially call sysconf, too.)
|
|
||
| private: | ||
| #if defined(__cpp_lib_atomic_shared_ptr) | ||
| std::atomic<std::shared_ptr<neorados::IOContext>> data_io_context; |
There was a problem hiding this comment.
The commit is titled "librbd: Fix atomic shared pointer situation", but there is no description. Can you explain what is being fixed? Given that atomic_*(&data_io_context) usage that was deprecated in C++20 remains, I'm not sure I see the point of this change.
There was a problem hiding this comment.
My understanding is that the atomic_store specialization on shared_ptr per se was deprecated. (https://en.cppreference.com/w/cpp/memory/shared_ptr/atomic), with the recommendation to replace it with atomic<shared_ptr>.
We can use std::atomic_store on any std::atomic<T>* (https://en.cppreference.com/w/cpp/atomic/atomic_store), essentially equivalent to the store member function.
GCC11 doesn't have the atomic<shared_ptr> specialization so we have to keep the regular shared_ptr for now until we can be rid of it, but we can use the new one in new compilers. (And based on the implementation note in CPPreference, the usual implementation of atomic_store<shared_ptr> sounds terrible and we probably want to not use it whenever possible.)
I'll put an explanation in the commit message.
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
@adamemerson - thanks for cleaning up all this! |
There was a problem hiding this comment.
Thanks for doing all of this work! I think the changes are really big improvements! Please double-check for situations with vector<T *> that things are getting destroyed in the way you expect, and consider std::string for cases where a character buffer is intended rather than some kind of binary-flavor data. (Alternatively, you can use a unique_ptr<> with a deleter, example included in notes.)
NOTE: please check to be sure they aren't just moving pointers around-- I may not have checked carefully enough (for which I apologize!), if they don't make copies please disregard.
Since we have an obscenely wide supported version spread, we have to support the deprecated location, too. Signed-off-by: Adam Emerson <aemerson@redhat.com>
The `lruset` and `not_before_queue` tests require the error category from `buffer.cc`. Optimization removes any actual use of the category, so the link error only shows up when compiling `-O0`. Signed-off-by: Adam Emerson <aemerson@redhat.com>
To fix compile error on jammy Signed-off-by: Adam Emerson <aemerson@redhat.com>
Otherwise we hit a linker error when compiling with `-O0` due to the use of `buffer::error_category` not being optimized out. Signed-off-by: Adam Emerson <aemerson@redhat.com>
libstdc++ uses TBB to implement the execution library if it is available. If it's not present, we get a serial backend. Currently, we aren't getting link errors in most cases because the reference is optimized out, but when compiling with `-O0`, we hit a missing symbol. If we use more of the execution library, we'll reference TBB in ways that don't optimize out. As such, test if TBB is available. If so, link against it. Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
Signed-off-by: Adam Emerson <aemerson@redhat.com>
In the first branch of the if statement `remainingBytes` may be more than the size of the `uint64_t`. Signed-off-by: Adam Emerson <aemerson@redhat.com>
9c7a1af to
1d8aaf3
Compare
chardan
left a comment
There was a problem hiding this comment.
+1! This is a big improvement, I think! I had a few comments about things you COULD do, but if this is passing Teuthology it's looking good to me, thank you for the hard work on it!
| list(APPEND EXTRALIBS gcov) | ||
| endif(${ENABLE_COVERAGE}) | ||
|
|
||
| # libstdc++ uses TBB to implement <execution> if it is available, |
| char buf[len]; | ||
| hex2str(secret.c_str(), secret.length(), buf, len); | ||
| s = buf; | ||
| // Since we have to copy the result into the string anyway, we may |
| s.resize(len); | ||
| } | ||
| len = hex2str(secret.c_str(), secret.length(), s.data(), len); | ||
| s.resize(len); |
There was a problem hiding this comment.
Consider making line 601 always happen? (Then, this and the if-statement can go away.)
| #define _CEPH_CLIENT_ID "ceph.client_id" | ||
| #endif | ||
|
|
||
| static constexpr std::size_t sv_reserve = 1'024; |
There was a problem hiding this comment.
+1 for snazzy decimal literal
| char secret[seed.length()]; | ||
| char *psecret = secret; | ||
| std::vector<char> secret(seed.length()); | ||
| char *psecret = secret.data(); |
There was a problem hiding this comment.
On line 295 there's a possibility of free() being called on this. Can the psecret pointer go away?
There was a problem hiding this comment.
Oh... So... IF need_free gets set, psecret is re-assigned (line 282) and then free()ed.
|
|
||
| std::string key{HTTP_}; | ||
| key.reserve(name.size() + HTTP_.size()); | ||
| std::transform(name.cbegin(), name.cend(), |
There was a problem hiding this comment.
Is this what that dash-to-underscore function we saw earlier does? Maybe replace the implementation with this..? Or make this a Named Function? It's also ok as-written-- +1 map... er... transform().
| std::string buf; | ||
| buf.reserve(orig.size()); | ||
|
|
||
| std::transform(orig.begin(), orig.cend(), |
There was a problem hiding this comment.
Hm. Same thing, but tolower() instead of toupper(). I think this is still an improvement, but it does start my head-scratching!
| return string(buf); | ||
| std::string buf; | ||
| buf.reserve(orig.size()); | ||
| std::transform(orig.cbegin(), orig.cend(), |
There was a problem hiding this comment.
Consider also boost::string::to_lower().
| mod.reserve(orig.size()); | ||
| std::transform(orig.cbegin(), orig.cend(), | ||
| std::back_inserter(mod), | ||
| [](char c) { return char(toupper(underscise(c))); }); |
There was a problem hiding this comment.
Nice! (Maybe apply to the other similar cases.)
| std::string_view src(tok, len); | ||
| std::string key; | ||
| key.reserve(len); | ||
| std::transform(src.cbegin(), src.cend(), |
There was a problem hiding this comment.
Yeah, this pattern is definitely common enough that (I know you're probably tired of tinkering with this!) it would be good to see some kind of up/low-er_underscise() to have it in one place (strictly IMO though).
| char buf[size]; | ||
| char tmp_dest[size + 4]; /* so that there's space for the extra '=' characters, and some */ | ||
| std::vector<char> buf(size); | ||
| std::vector<char> tmp_dest(size + 4); /* so that there's space for the extra '=' characters, and some */ |
There was a problem hiding this comment.
It seems odd that the dest-ptr would give us a size that we're going to ignore, though..?
| } | ||
| tmp_dest[ret] = '\0'; | ||
| memcpy(dest, tmp_dest, size); | ||
| memcpy(dest, tmp_dest.data(), size); |
There was a problem hiding this comment.
It looks like it's ok if this truncates, then..?
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
Note: commit 7e3f243 should be backported to Squid, to handle https://tracker.ceph.com/issues/69659 |
|
Breaking these out into separate PRs so they can get approved/tested/merged individually |
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
|
This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution! |
A cleanup
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard cephadmjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume toxjenkins test windowsjenkins test rook e2e