Skip to content

Commit e3c716f

Browse files
committed
fix(storage): fix clang-tidy static method and align with styleguide
1 parent 3f78415 commit e3c716f

3 files changed

Lines changed: 127 additions & 113 deletions

File tree

‎google/cloud/storage/internal/async/connection_impl.cc‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#include <opentelemetry/metrics/provider.h>
6666
#include <algorithm>
6767
#include <chrono>
68+
#include <cstddef>
6869
#include <cstdint>
6970
#include <memory>
7071
#include <mutex>
@@ -246,7 +247,7 @@ class HedgedOpenOperation
246247
retry_policy_(std::move(retry_policy)),
247248
hedge_delay_(
248249
(std::max)(std::chrono::milliseconds::zero(), hedge_delay)),
249-
max_hedges_(max_hedges),
250+
max_hedges_((std::max)(0, max_hedges)),
250251
limiter_(std::move(limiter)),
251252
metrics_(std::move(metrics)),
252253
call_context_(std::move(options)) {
@@ -256,12 +257,13 @@ class HedgedOpenOperation
256257
future<StatusOr<OpenStreamResult>> Start() {
257258
std::weak_ptr<HedgedOpenOperation> weak = shared_from_this();
258259
result_promise_ = promise<StatusOr<OpenStreamResult>>([weak] {
259-
if (auto self = weak.lock()) {
260+
if (std::shared_ptr<HedgedOpenOperation> self = weak.lock()) {
260261
google::cloud::internal::ScopedCallContext scope(self->call_context_);
261262
self->OnCallerCancel();
262263
}
263264
});
264-
auto result_future = result_promise_.get_future();
265+
future<StatusOr<OpenStreamResult>> result_future =
266+
result_promise_.get_future();
265267

266268
std::uint64_t attempt_id = 0;
267269
std::uint64_t timer_gen = 0;
@@ -321,7 +323,7 @@ class HedgedOpenOperation
321323
limiter_.get(), [l = limiter_](void*) { l->ReleaseHedgeSlot(); });
322324
}
323325
google::cloud::internal::ScopedCallContext scope(call_context_);
324-
auto self = shared_from_this();
326+
std::shared_ptr<HedgedOpenOperation> self = shared_from_this();
325327
return factory_(initial_request_)
326328
.then([self = std::move(self), slot_guard = std::move(slot_guard),
327329
attempt_id,
@@ -345,10 +347,11 @@ class HedgedOpenOperation
345347
}
346348

347349
void RemoveAttemptLocked(std::uint64_t attempt_id) {
348-
auto it = std::find_if(
349-
attempts_.begin(), attempts_.end(),
350-
[attempt_id](AttemptEntry const& e) { return e.id == attempt_id; });
351-
if (it != attempts_.end()) attempts_.erase(it);
350+
attempts_.erase(std::remove_if(attempts_.begin(), attempts_.end(),
351+
[attempt_id](AttemptEntry const& e) {
352+
return e.id == attempt_id;
353+
}),
354+
attempts_.end());
352355
}
353356

354357
void ArmTimer(std::uint64_t timer_gen, std::chrono::milliseconds delay) {
@@ -362,7 +365,7 @@ class HedgedOpenOperation
362365
future<void> timer = cq_.MakeRelativeTimer(delay).then(
363366
[weak,
364367
timer_gen](future<StatusOr<std::chrono::system_clock::time_point>> f) {
365-
if (auto self = weak.lock()) {
368+
if (std::shared_ptr<HedgedOpenOperation> self = weak.lock()) {
366369
self->OnTimer(timer_gen, f.get().ok());
367370
}
368371
});

0 commit comments

Comments
 (0)