[CI] Upgraded clang to 19 for sanity tests (#38070)

This change upgrades the sanity test to use Clang 19, including clang-format and clang-tidy. (It's a partial implementation of the changes proposed in #38038)

Key updates:
- Docker images now utilize Clang 19.
- Code has been reformatted using the updated clang-format.
- Resolved `readability-math-missing-parentheses` warnings raised by clang-tidy.

Note that the other part of the clang-19 upgrade, "using clang-19 for C++ test" will be done once opentelemetry-cpp fixes the clang-19 build error.

Closes #38070

PiperOrigin-RevId: 693833548
pull/37782/merge
Esun Kim 3 weeks ago committed by Copybara-Service
parent 6a0377ea4c
commit 6a0c483bea
  1. 6
      .clang-tidy
  2. 2
      src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc
  3. 4
      src/core/ext/filters/http/message_compress/compression_filter.cc
  4. 9
      src/core/ext/transport/chaotic_good/chaotic_good_transport.h
  5. 2
      src/core/ext/transport/chaotic_good/server_transport.cc
  6. 9
      src/core/ext/transport/chaotic_good_legacy/chaotic_good_transport.h
  7. 2
      src/core/ext/transport/chaotic_good_legacy/server_transport.cc
  8. 5
      src/core/ext/transport/chttp2/transport/bin_decoder.cc
  9. 6
      src/core/ext/transport/chttp2/transport/bin_encoder.cc
  10. 4
      src/core/ext/transport/chttp2/transport/decode_huff.h
  11. 2
      src/core/ext/transport/chttp2/transport/flow_control.cc
  12. 2
      src/core/ext/transport/chttp2/transport/hpack_parser.cc
  13. 2
      src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
  14. 2
      src/core/lib/event_engine/posix_engine/timer_heap.cc
  15. 4
      src/core/lib/iomgr/closure.h
  16. 2
      src/core/lib/iomgr/timer_heap.cc
  17. 2
      src/core/lib/promise/map.h
  18. 5
      src/core/lib/promise/match_promise.h
  19. 6
      src/core/lib/resource_quota/memory_quota.cc
  20. 2
      src/core/lib/surface/filter_stack_call.h
  21. 2
      src/core/lib/transport/bdp_estimator.cc
  22. 8
      src/core/lib/transport/call_filters.h
  23. 2
      src/core/lib/transport/interception_chain.h
  24. 8
      src/core/lib/transport/timeout_encoding.cc
  25. 2
      src/core/load_balancing/outlier_detection/outlier_detection.cc
  26. 6
      src/core/telemetry/histogram_view.cc
  27. 8
      src/core/util/gpr_time.cc
  28. 8
      src/core/util/json/json_object_loader.h
  29. 4
      src/core/util/string.cc
  30. 8
      src/core/util/time.cc
  31. 4
      src/core/util/time.h
  32. 4
      src/cpp/server/load_reporter/load_reporter_async_service_impl.cc
  33. 2
      src/ruby/ext/grpc/rb_grpc.h
  34. 2
      templates/tools/dockerfile/grpc_clang_format/Dockerfile.template
  35. 2
      templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template
  36. 2
      templates/tools/dockerfile/test/sanity/Dockerfile.template
  37. 8
      test/core/channelz/channelz_test.cc
  38. 2
      test/core/event_engine/posix/timer_heap_test.cc
  39. 2
      test/core/ext/filters/event_engine_client_channel_resolver/resolver_fuzzer.cc
  40. 4
      test/core/http/parser_test.cc
  41. 2
      test/core/iomgr/endpoint_tests.cc
  42. 3
      test/core/iomgr/tcp_posix_test.cc
  43. 4
      test/core/iomgr/timer_heap_test.cc
  44. 3
      test/core/network_benchmarks/low_level_ping_pong.cc
  45. 4
      test/core/promise/inter_activity_pipe_test.cc
  46. 2
      test/core/promise/sleep_test.cc
  47. 2
      test/core/resolver/fake_resolver_test.cc
  48. 2
      test/core/resource_quota/memory_quota_test.cc
  49. 8
      test/core/test_util/histogram.cc
  50. 2
      test/core/test_util/stack_tracer.cc
  51. 2
      test/core/tsi/alts/crypt/gsec_test_util.cc
  52. 4
      test/core/util/validation_errors_test.cc
  53. 6
      test/cpp/end2end/xds/xds_cluster_end2end_test.cc
  54. 4
      test/cpp/microbenchmarks/callback_unary_ping_pong.h
  55. 2
      test/cpp/microbenchmarks/fullstack_context_mutators.h
  56. 4
      test/cpp/microbenchmarks/fullstack_unary_ping_pong.h
  57. 4
      test/cpp/qps/driver.cc
  58. 2
      test/cpp/qps/qps_json_driver.cc
  59. 4
      test/cpp/qps/usage_timer.cc
  60. 2
      test/cpp/util/cli_credentials.cc
  61. 2
      tools/bazelify_tests/dockerimage_current_versions.bzl
  62. 2
      tools/dockerfile/grpc_clang_format/Dockerfile
  63. 2
      tools/dockerfile/grpc_clang_tidy/Dockerfile
  64. 2
      tools/dockerfile/test/sanity.current_version
  65. 2
      tools/dockerfile/test/sanity/Dockerfile

@ -70,6 +70,7 @@ Checks: '-*,
-bugprone-assignment-in-if-condition,
-bugprone-branch-clone,
-bugprone-casting-through-void,
-bugprone-crtp-constructor-accessibility,
-bugprone-easily-swappable-parameters,
-bugprone-empty-catch,
-bugprone-exception-escape,
@ -80,8 +81,10 @@ Checks: '-*,
-bugprone-narrowing-conversions,
-bugprone-not-null-terminated-result,
-bugprone-reserved-identifier,
-bugprone-return-const-ref-from-parameter,
-bugprone-signed-char-misuse,
-bugprone-sizeof-expression,
-bugprone-suspicious-stringview-data-usage,
-bugprone-switch-missing-default-case,
-bugprone-too-small-loop-variable,
-bugprone-unchecked-optional-access,
@ -92,6 +95,7 @@ Checks: '-*,
performance-*,
-performance-avoid-endl,
-performance-enum-size,
-performance-inefficient-vector-operation,
-performance-no-automatic-move,
-performance-no-int-to-ptr,
-performance-noexcept-swap,
@ -140,7 +144,7 @@ Checks: '-*,
readability-duplicate-include,
readability-function-size,
readability-inconsistent-declaration-parameter-name,
readability-math-missing-parentheses,
-readability-math-missing-parentheses,
readability-misleading-indentation,
readability-misplaced-array-index,
readability-redundant-access-specifiers,

@ -220,7 +220,7 @@ ArenaPromise<ServerMetadataHandle> LegacyChannelIdleFilter::MakeCallPromise(
return ArenaPromise<ServerMetadataHandle>(
[decrementer = Decrementer(this),
next = next_promise_factory(std::move(call_args))]() mutable
-> Poll<ServerMetadataHandle> { return next(); });
-> Poll<ServerMetadataHandle> { return next(); });
}
bool LegacyChannelIdleFilter::StartTransportOp(grpc_transport_op* op) {

@ -136,8 +136,8 @@ MessageHandle ChannelCompression::CompressMessage(
const char* algo_name;
const size_t before_size = payload->Length();
const size_t after_size = tmp.Length();
const float savings_ratio = 1.0f - static_cast<float>(after_size) /
static_cast<float>(before_size);
const float savings_ratio = 1.0f - (static_cast<float>(after_size) /
static_cast<float>(before_size));
CHECK(grpc_compression_algorithm_name(algorithm, &algo_name));
LOG(INFO) << absl::StrFormat(
"Compressed[%s] %" PRIuPTR " bytes vs. %" PRIuPTR

@ -108,10 +108,11 @@ class ChaoticGoodTransport : public RefCounted<ChaoticGoodTransport> {
});
},
[&frame_header]() {
return [status = frame_header.status()]() mutable
-> absl::StatusOr<std::tuple<FrameHeader, BufferPair>> {
return std::move(status);
};
return
[status = frame_header.status()]() mutable
-> absl::StatusOr<std::tuple<FrameHeader, BufferPair>> {
return std::move(status);
};
});
});
}

@ -176,7 +176,7 @@ auto ChaoticGoodServerTransport::SendCallBody(
const uint32_t padding =
message_length % aligned_bytes == 0
? 0
: aligned_bytes - message_length % aligned_bytes;
: aligned_bytes - (message_length % aligned_bytes);
CHECK_EQ((message_length + padding) % aligned_bytes, 0u);
frame.message =
FragmentMessage(std::move(message), padding, message_length);

@ -108,10 +108,11 @@ class ChaoticGoodTransport : public RefCounted<ChaoticGoodTransport> {
});
},
[&frame_header]() {
return [status = frame_header.status()]() mutable
-> absl::StatusOr<std::tuple<FrameHeader, BufferPair>> {
return std::move(status);
};
return
[status = frame_header.status()]() mutable
-> absl::StatusOr<std::tuple<FrameHeader, BufferPair>> {
return std::move(status);
};
});
});
}

@ -176,7 +176,7 @@ auto ChaoticGoodServerTransport::SendCallBody(
const uint32_t padding =
message_length % aligned_bytes == 0
? 0
: aligned_bytes - message_length % aligned_bytes;
: aligned_bytes - (message_length % aligned_bytes);
CHECK_EQ((message_length + padding) % aligned_bytes, 0u);
frame.message =
FragmentMessage(std::move(message), padding, message_length);

@ -96,7 +96,7 @@ size_t grpc_chttp2_base64_infer_length_after_decode(const grpc_slice& slice) {
<< " (without padding), which is invalid.\n";
return 0;
}
return tuples * 3 + tail_xtra[tail_case];
return (tuples * 3) + tail_xtra[tail_case];
}
bool grpc_base64_decode_partial(struct grpc_base64_decode_context* ctx) {
@ -215,7 +215,8 @@ grpc_slice grpc_chttp2_base64_decode_with_length(const grpc_slice& input,
input_length / 4 * 3 + tail_xtra[input_length % 4])) {
LOG(ERROR) << "Base64 decoding failed, output_length " << output_length
<< " is longer than the max possible output length "
<< (input_length / 4 * 3 + tail_xtra[input_length % 4]) << ".\n";
<< ((input_length / 4 * 3) + tail_xtra[input_length % 4])
<< ".\n";
grpc_core::CSliceUnref(output);
return grpc_empty_slice();
}

@ -51,7 +51,7 @@ grpc_slice grpc_chttp2_base64_encode(const grpc_slice& input) {
size_t input_length = GRPC_SLICE_LENGTH(input);
size_t input_triplets = input_length / 3;
size_t tail_case = input_length % 3;
size_t output_length = input_triplets * 4 + tail_xtra[tail_case];
size_t output_length = (input_triplets * 4) + tail_xtra[tail_case];
grpc_slice output = GRPC_SLICE_MALLOC(output_length);
const uint8_t* in = GRPC_SLICE_START_PTR(input);
char* out = reinterpret_cast<char*> GRPC_SLICE_START_PTR(output);
@ -171,9 +171,9 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(
size_t input_length = GRPC_SLICE_LENGTH(input);
size_t input_triplets = input_length / 3;
size_t tail_case = input_length % 3;
size_t output_syms = input_triplets * 4 + tail_xtra[tail_case];
size_t output_syms = (input_triplets * 4) + tail_xtra[tail_case];
size_t max_output_bits = 11 * output_syms;
size_t max_output_length = max_output_bits / 8 + (max_output_bits % 8 != 0);
size_t max_output_length = (max_output_bits / 8) + (max_output_bits % 8 != 0);
grpc_slice output = GRPC_SLICE_MALLOC(max_output_length);
const uint8_t* in = GRPC_SLICE_START_PTR(input);
uint8_t* start_out = GRPC_SLICE_START_PTR(output);

@ -87,7 +87,7 @@ class HuffDecoderCommon {
return table1_emit_[i >> 6][emit];
}
static inline uint64_t GetOp13(size_t i) {
return table13_0_inner_[(i < 3 ? (i) : ((i - 3) / 12 + 3))];
return table13_0_inner_[(i < 3 ? (i) : (((i - 3) / 12) + 3))];
}
static inline uint64_t GetEmit13(size_t, size_t emit) {
return (emit < 1 ? (((void)emit, 92)) : ((emit - 1) ? 208 : 195));
@ -189,7 +189,7 @@ class HuffDecoderCommon {
}
static inline uint64_t GetEmit37(size_t, size_t emit) { return emit + 236; }
static inline uint64_t GetOp36(size_t i) {
return table36_0_inner_[(i < 3 ? (i / 2 + 0) : ((i - 3) + 1))];
return table36_0_inner_[(i < 3 ? ((i / 2) + 0) : ((i - 3) + 1))];
}
static inline uint64_t GetEmit36(size_t, size_t emit) {
return table36_0_emit_[emit];

@ -182,7 +182,7 @@ TransportFlowControl::TargetInitialWindowSizeBasedOnMemoryPressureAndBdp()
// and a value t such that t_min <= t <= t_max, return the value on the line
// segment at t.
auto lerp = [](double t, double t_min, double t_max, double a, double b) {
return a + (b - a) * (t - t_min) / (t_max - t_min);
return a + ((b - a) * (t - t_min) / (t_max - t_min));
};
// We split memory pressure into three broad regions:
// 1. Low memory pressure, the "anything goes" case - we assume no memory

@ -403,7 +403,7 @@ absl::optional<std::vector<uint8_t>> HPackParser::String::Unbase64Loop(
}
std::vector<uint8_t> out;
out.reserve(3 * (end - cur) / 4 + 3);
out.reserve((3 * (end - cur) / 4) + 3);
// Decode 4 bytes at a time while we can
while (end - cur >= 4) {

@ -356,7 +356,7 @@ Epoll1Poller::Epoll1Poller(Scheduler* scheduler)
CHECK_GE(g_epoll_set_.epfd, 0);
GRPC_TRACE_LOG(event_engine_poller, INFO)
<< "grpc epoll fd: " << g_epoll_set_.epfd;
struct epoll_event ev {};
struct epoll_event ev{};
ev.events = static_cast<uint32_t>(EPOLLIN | EPOLLET);
ev.data.ptr = wakeup_fd_.get();
CHECK(epoll_ctl(g_epoll_set_.epfd, EPOLL_CTL_ADD, wakeup_fd_->ReadFd(),

@ -50,7 +50,7 @@ void TimerHeap::AdjustUpwards(size_t i, Timer* t) {
// position.
void TimerHeap::AdjustDownwards(size_t i, Timer* t) {
for (;;) {
size_t left_child = 1 + 2 * i;
size_t left_child = 1 + (2 * i);
if (left_child >= timers_.size()) break;
size_t right_child = left_child + 1;
size_t next_i =

@ -212,7 +212,9 @@ inline grpc_closure* grpc_closure_create(grpc_iomgr_cb_func cb, void* cb_arg) {
#endif
#define GRPC_CLOSURE_LIST_INIT \
{ nullptr, nullptr }
{ \
nullptr, nullptr \
}
inline void grpc_closure_list_init(grpc_closure_list* closure_list) {
closure_list->head = closure_list->tail = nullptr;

@ -48,7 +48,7 @@ static void adjust_upwards(grpc_timer** first, uint32_t i, grpc_timer* t) {
static void adjust_downwards(grpc_timer** first, uint32_t i, uint32_t length,
grpc_timer* t) {
for (;;) {
uint32_t left_child = 1u + 2u * i;
uint32_t left_child = 1u + (2u * i);
if (left_child >= length) break;
uint32_t right_child = left_child + 1;
uint32_t next_i = right_child < length && first[left_child]->deadline >

@ -79,7 +79,7 @@ template <typename Promise>
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION inline auto CheckDelayed(Promise promise) {
using P = promise_detail::PromiseLike<Promise>;
return [delayed = false, promise = P(std::move(promise))]() mutable
-> Poll<std::tuple<typename P::Result, bool>> {
-> Poll<std::tuple<typename P::Result, bool>> {
auto r = promise();
if (r.pending()) {
delayed = true;

@ -50,9 +50,8 @@ struct ConstructPromiseVariantVisitor {
// the result into a variant type that covers ALL of the possible return types
// given the input types listed in Ts...
template <typename T>
auto operator()(T x)
-> absl::variant<promise_detail::PromiseLike<
decltype(CallConstructorThenFactory(std::declval<Ts>()))>...> {
auto operator()(T x) -> absl::variant<promise_detail::PromiseLike<
decltype(CallConstructorThenFactory(std::declval<Ts>()))>...> {
return CallConstructorThenFactory(x);
}
};

@ -346,7 +346,7 @@ void GrpcMemoryAllocatorImpl::MaybeDonateBack() {
size_t ret = 0;
if (!IsUnconstrainedMaxQuotaBufferSizeEnabled() &&
free > kMaxQuotaBufferSize / 2) {
ret = std::max(ret, free - kMaxQuotaBufferSize / 2);
ret = std::max(ret, free - (kMaxQuotaBufferSize / 2));
}
ret = std::max(ret, free > 8192 ? free / 2 : free);
const size_t new_free = free - ret;
@ -719,8 +719,8 @@ double PressureController::Update(double error) {
// (If we want a control value that's higher than the last one we snap
// immediately because it's likely that memory pressure is growing unchecked).
if (new_control < last_control_) {
new_control =
std::max(new_control, last_control_ - max_reduction_per_tick_ / 1000.0);
new_control = std::max(new_control,
last_control_ - (max_reduction_per_tick_ / 1000.0));
}
last_control_ = new_control;
return new_control;

@ -131,7 +131,7 @@ class FilterStackCall final : public Call {
static size_t InitialSizeEstimate() {
return sizeof(FilterStackCall) +
sizeof(BatchControl) * kMaxConcurrentBatches;
(sizeof(BatchControl) * kMaxConcurrentBatches);
}
char* GetPeer() final;

@ -43,7 +43,7 @@ Timestamp BdpEstimator::CompletePing() {
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec dt_ts = gpr_time_sub(now, ping_start_time_);
double dt = static_cast<double>(dt_ts.tv_sec) +
1e-9 * static_cast<double>(dt_ts.tv_nsec);
(1e-9 * static_cast<double>(dt_ts.tv_nsec));
double bw = dt > 0 ? (static_cast<double>(accumulator_) / dt) : 0;
Duration start_inter_ping_delay = inter_ping_delay_;
GRPC_TRACE_LOG(bdp_estimator, INFO)

@ -1585,8 +1585,8 @@ class CallFilters {
private:
template <typename Output, typename Input,
Input(CallFilters::*input_location),
filters_detail::Layout<Input>(filters_detail::StackData::*layout),
Input(CallFilters::* input_location),
filters_detail::Layout<Input>(filters_detail::StackData::* layout),
void (CallState::*on_done)(), typename StackIterator>
class MetadataExecutor {
public:
@ -1639,9 +1639,9 @@ class CallFilters {
filters_detail::OperationExecutor<Input> executor_;
};
template <MessageHandle(CallFilters::*input_location),
template <MessageHandle(CallFilters::* input_location),
filters_detail::Layout<MessageHandle>(
filters_detail::StackData::*layout),
filters_detail::StackData::* layout),
void (CallState::*on_done)(), typename StackIterator>
class MessageExecutor {
public:

@ -106,7 +106,7 @@ class Interceptor : public UnstartedCallDestination {
return Map(call_handler.PullClientInitialMetadata(),
[call_handler, destination = wrapped_destination_](
ValueOrFailure<ClientMetadataHandle> metadata) mutable
-> ValueOrFailure<HijackedCall> {
-> ValueOrFailure<HijackedCall> {
if (!metadata.ok()) return Failure{};
return HijackedCall(std::move(metadata.value()),
std::move(destination),

@ -258,12 +258,12 @@ absl::optional<Duration> ParseTimeout(const Slice& text) {
Duration timeout;
switch (*p) {
case 'n':
timeout =
Duration::Milliseconds(x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0));
timeout = Duration::Milliseconds((x / GPR_NS_PER_MS) +
(x % GPR_NS_PER_MS != 0));
break;
case 'u':
timeout =
Duration::Milliseconds(x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0));
timeout = Duration::Milliseconds((x / GPR_US_PER_MS) +
(x % GPR_US_PER_MS != 0));
break;
case 'm':
timeout = Duration::Milliseconds(x);

@ -924,7 +924,7 @@ void OutlierDetectionLb::EjectionTimer::OnTimerLocked() {
double stdev = std::sqrt(variance);
const double success_rate_stdev_factor =
static_cast<double>(config.success_rate_ejection->stdev_factor) / 1000;
double ejection_threshold = mean - stdev * success_rate_stdev_factor;
double ejection_threshold = mean - (stdev * success_rate_stdev_factor);
GRPC_TRACE_LOG(outlier_detection_lb, INFO)
<< "[outlier_detection_lb " << parent_.get() << "] stdev=" << stdev
<< ", ejection_threshold=" << ejection_threshold;

@ -54,9 +54,9 @@ double HistogramView::ThresholdForCountBelow(double count_below) const {
// should lie
lower_bound = bucket_boundaries[lower_idx];
upper_bound = bucket_boundaries[lower_idx + 1];
return upper_bound - (upper_bound - lower_bound) *
(count_so_far - count_below) /
static_cast<double>(buckets[lower_idx]);
return upper_bound -
((upper_bound - lower_bound) * (count_so_far - count_below) /
static_cast<double>(buckets[lower_idx]));
}
}

@ -224,7 +224,7 @@ int gpr_time_similar(gpr_timespec a, gpr_timespec b, gpr_timespec threshold) {
int32_t gpr_time_to_millis(gpr_timespec t) {
if (t.tv_sec >= 2147483) {
if (t.tv_sec == 2147483 && t.tv_nsec < 648 * GPR_NS_PER_MS) {
return 2147483 * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS;
return (2147483 * GPR_MS_PER_SEC) + (t.tv_nsec / GPR_NS_PER_MS);
}
return 2147483647;
} else if (t.tv_sec <= -2147483) {
@ -232,13 +232,13 @@ int32_t gpr_time_to_millis(gpr_timespec t) {
// care?)
return -2147483647;
} else {
return static_cast<int32_t>(t.tv_sec * GPR_MS_PER_SEC +
t.tv_nsec / GPR_NS_PER_MS);
return static_cast<int32_t>((t.tv_sec * GPR_MS_PER_SEC) +
(t.tv_nsec / GPR_NS_PER_MS));
}
}
double gpr_timespec_to_micros(gpr_timespec t) {
return static_cast<double>(t.tv_sec) * GPR_US_PER_SEC + t.tv_nsec * 1e-3;
return (static_cast<double>(t.tv_sec) * GPR_US_PER_SEC) + (t.tv_nsec * 1e-3);
}
gpr_timespec gpr_convert_clock_type(gpr_timespec t, gpr_clock_type clock_type) {

@ -457,7 +457,7 @@ const LoaderInterface* LoaderForType() {
struct Element {
Element() = default;
template <typename A, typename B>
Element(const char* name, bool optional, B A::*p,
Element(const char* name, bool optional, B A::* p,
const LoaderInterface* loader, const char* enable_key)
: loader(loader),
member_offset(static_cast<uint16_t>(
@ -564,13 +564,13 @@ class JsonObjectLoader final {
template <typename U>
JsonObjectLoader<T, kElemCount + 1> Field(
const char* name, U T::*p, const char* enable_key = nullptr) const {
const char* name, U T::* p, const char* enable_key = nullptr) const {
return Field(name, false, p, enable_key);
}
template <typename U>
JsonObjectLoader<T, kElemCount + 1> OptionalField(
const char* name, U T::*p, const char* enable_key = nullptr) const {
const char* name, U T::* p, const char* enable_key = nullptr) const {
return Field(name, true, p, enable_key);
}
@ -581,7 +581,7 @@ class JsonObjectLoader final {
private:
template <typename U>
JsonObjectLoader<T, kElemCount + 1> Field(const char* name, bool optional,
U T::*p,
U T::* p,
const char* enable_key) const {
return JsonObjectLoader<T, kElemCount + 1>(
elements_, Element(name, optional, p, LoaderForType<U>(), enable_key));

@ -183,7 +183,7 @@ int gpr_ltoa(long value, char* output) {
sign = value < 0 ? -1 : 1;
while (value) {
output[i++] = static_cast<char>('0' + sign * (value % 10));
output[i++] = static_cast<char>('0' + (sign * (value % 10)));
value /= 10;
}
if (sign < 0) output[i++] = '-';
@ -204,7 +204,7 @@ int int64_ttoa(int64_t value, char* output) {
sign = value < 0 ? -1 : 1;
while (value) {
output[i++] = static_cast<char>('0' + sign * (value % 10));
output[i++] = static_cast<char>('0' + (sign * (value % 10)));
value /= 10;
}
if (sign < 0) output[i++] = '-';

@ -120,9 +120,9 @@ gpr_timespec MillisecondsAsTimespec(int64_t millis, gpr_clock_type clock_type) {
int64_t TimespanToMillisRoundUp(gpr_timespec ts) {
CHECK(ts.clock_type == GPR_TIMESPAN);
double x = GPR_MS_PER_SEC * static_cast<double>(ts.tv_sec) +
static_cast<double>(ts.tv_nsec) / GPR_NS_PER_MS +
static_cast<double>(GPR_NS_PER_SEC - 1) /
static_cast<double>(GPR_NS_PER_SEC);
(static_cast<double>(ts.tv_nsec) / GPR_NS_PER_MS) +
(static_cast<double>(GPR_NS_PER_SEC - 1) /
static_cast<double>(GPR_NS_PER_SEC));
if (x <= static_cast<double>(std::numeric_limits<int64_t>::min())) {
return std::numeric_limits<int64_t>::min();
}
@ -135,7 +135,7 @@ int64_t TimespanToMillisRoundUp(gpr_timespec ts) {
int64_t TimespanToMillisRoundDown(gpr_timespec ts) {
CHECK(ts.clock_type == GPR_TIMESPAN);
double x = GPR_MS_PER_SEC * static_cast<double>(ts.tv_sec) +
static_cast<double>(ts.tv_nsec) / GPR_NS_PER_MS;
(static_cast<double>(ts.tv_nsec) / GPR_NS_PER_MS);
if (x <= static_cast<double>(std::numeric_limits<int64_t>::min())) {
return std::numeric_limits<int64_t>::min();
}

@ -227,11 +227,11 @@ class Duration {
}
static constexpr Duration MicrosecondsRoundUp(int64_t micros) {
return Duration(micros / GPR_US_PER_MS + (micros % GPR_US_PER_MS != 0));
return Duration((micros / GPR_US_PER_MS) + (micros % GPR_US_PER_MS != 0));
}
static constexpr Duration NanosecondsRoundUp(int64_t nanos) {
return Duration(nanos / GPR_NS_PER_MS + (nanos % GPR_NS_PER_MS != 0));
return Duration((nanos / GPR_NS_PER_MS) + (nanos % GPR_NS_PER_MS != 0));
}
constexpr bool operator==(Duration other) const {

@ -223,8 +223,8 @@ void LoadReporterAsyncServiceImpl::ReportLoadHandler::OnReadDone(
load_key_);
const auto& load_report_interval = initial_request.load_report_interval();
load_report_interval_ms_ =
static_cast<unsigned long>(load_report_interval.seconds() * 1000 +
load_report_interval.nanos() / 1000);
static_cast<unsigned long>((load_report_interval.seconds() * 1000) +
(load_report_interval.nanos() / 1000));
LOG(INFO) << "[LRS " << service_
<< "] Initial request received. Start load reporting (load "
"balanced host: "

@ -53,7 +53,7 @@ extern VALUE sym_metadata;
/* GRPC_RB_MEMSIZE_UNAVAILABLE is used in rb_data_type_t to indicate that the
* number of bytes used by the wrapped struct is not available. */
#define GRPC_RB_MEMSIZE_UNAVAILABLE (size_t(*)(const void*))(NULL)
#define GRPC_RB_MEMSIZE_UNAVAILABLE (size_t (*)(const void*))(NULL)
/* A ruby object alloc func that fails by raising an exception. */
VALUE grpc_rb_cannot_alloc(VALUE cls);

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM silkeh/clang:18-bookworm
FROM silkeh/clang:19-bookworm
ADD clang_format_all_the_things.sh /

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM silkeh/clang:18-bookworm
FROM silkeh/clang:19-bookworm
# Install prerequisites for the clang-tidy script
RUN apt-get update && apt-get install -y python3 jq git && apt-get clean

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM silkeh/clang:18-bookworm
FROM silkeh/clang:19-bookworm
<%include file="../../apt_get_basic.include"/>

@ -472,9 +472,13 @@ TEST_F(ChannelzRegistryBasedTest, GetTopChannelsNoHitUuid) {
TEST_F(ChannelzRegistryBasedTest, GetTopChannelsMoreGaps) {
ExecCtx exec_ctx;
ChannelFixture channel_with_uuid1;
{ ServerFixture channel_with_uuid2; }
{
ServerFixture channel_with_uuid2;
}
ChannelFixture channel_with_uuid3;
{ ServerFixture server_with_uuid4; }
{
ServerFixture server_with_uuid4;
}
ChannelFixture channel_with_uuid5;
// Current state of list: [1, NULL, 3, NULL, 5]
std::string json_str = ChannelzRegistry::GetTopChannels(2);

@ -50,7 +50,7 @@ std::vector<Timer> CreateTestElements(size_t num_elements) {
void CheckValid(TimerHeap* pq) {
const std::vector<Timer*>& timers = pq->TestOnlyGetTimers();
for (size_t i = 0; i < timers.size(); ++i) {
size_t left_child = 1u + 2u * i;
size_t left_child = 1u + (2u * i);
size_t right_child = left_child + 1u;
if (left_child < timers.size()) {
EXPECT_LE(timers[i]->deadline, timers[left_child]->deadline);

@ -64,7 +64,7 @@ constexpr char g_grpc_config_prefix[] = "grpc_config=";
absl::Status ErrorToAbslStatus(
const event_engine_client_channel_resolver::Error& error) {
// clamp error.code() in (0, 16]
return absl::Status(static_cast<absl::StatusCode>(error.code() % 16 + 1),
return absl::Status(static_cast<absl::StatusCode>((error.code() % 16) + 1),
error.message());
}

@ -317,8 +317,8 @@ TEST(ParserTest, MainTest) {
char* tmp1 =
static_cast<char*>(gpr_malloc(2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH));
memset(tmp1, 'a', 2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1);
tmp1[2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1] = 0;
memset(tmp1, 'a', (2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH) - 1);
tmp1[(2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH) - 1] = 0;
std::string tmp2 =
absl::StrFormat("HTTP/1.0 200 OK\r\nxyz: %s\r\n\r\n", tmp1);
gpr_free(tmp1);

@ -80,7 +80,7 @@ static void end_test(grpc_endpoint_test_config config) { config.clean_up(); }
static grpc_slice* allocate_blocks(size_t num_bytes, size_t slice_size,
size_t* num_blocks, uint8_t* current_data) {
size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0);
size_t nslices = (num_bytes / slice_size) + (num_bytes % slice_size ? 1 : 0);
grpc_slice* slices =
static_cast<grpc_slice*>(gpr_malloc(sizeof(grpc_slice) * nslices));
size_t num_bytes_left = num_bytes;

@ -316,7 +316,8 @@ struct write_socket_state {
static grpc_slice* allocate_blocks(size_t num_bytes, size_t slice_size,
size_t* num_blocks, uint8_t* current_data) {
size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1u : 0u);
size_t nslices =
(num_bytes / slice_size) + (num_bytes % slice_size ? 1u : 0u);
grpc_slice* slices =
static_cast<grpc_slice*>(gpr_malloc(sizeof(grpc_slice) * nslices));
size_t num_bytes_left = num_bytes;

@ -52,7 +52,7 @@ static int contains(grpc_timer_heap* pq, grpc_timer* el) {
static void check_valid(grpc_timer_heap* pq) {
size_t i;
for (i = 0; i < pq->timer_count; ++i) {
size_t left_child = 1u + 2u * i;
size_t left_child = 1u + (2u * i);
size_t right_child = left_child + 1u;
if (left_child < pq->timer_count) {
ASSERT_LE(pq->timers[i]->deadline, pq->timers[left_child]->deadline);
@ -232,7 +232,7 @@ static void shrink_test(void) {
size_t expected_size;
// A large random number to allow for multiple shrinkages, at least 512.
const size_t num_elements = static_cast<size_t>(rand()) % 2000 + 512;
const size_t num_elements = (static_cast<size_t>(rand()) % 2000) + 512;
grpc_timer_heap_init(&pq);

@ -290,7 +290,8 @@ static void print_histogram(grpc_histogram* histogram) {
static double now(void) {
gpr_timespec tv = gpr_now(GPR_CLOCK_REALTIME);
return 1e9 * static_cast<double>(tv.tv_sec) + static_cast<double>(tv.tv_nsec);
return (1e9 * static_cast<double>(tv.tv_sec)) +
static_cast<double>(tv.tv_nsec);
}
static void client_thread(thread_args* args) {

@ -102,7 +102,9 @@ TEST(InterActivityPipe, CanClose) {
}));
EXPECT_FALSE(done);
// Drop the sender
{ auto x = std::move(pipe.sender); }
{
auto x = std::move(pipe.sender);
}
EXPECT_TRUE(done);
}

@ -179,7 +179,7 @@ TEST(Sleep, StressTest) {
for (size_t i = 0; i < kNumActivities / 2; i++) {
notifications[i]->WaitForNotification();
activities[i].reset();
activities[i + kNumActivities / 2].reset();
activities[i + (kNumActivities / 2)].reset();
exec_ctx.Flush();
}
}

@ -108,7 +108,7 @@ class FakeResolverTest : public ::testing::Test {
EndpointAddressesList addresses;
for (size_t i = 0; i < num_addresses; ++i) {
std::string uri_string = absl::StrFormat(
"ipv4:127.0.0.1:100%" PRIuPTR, test_counter * num_addresses + i);
"ipv4:127.0.0.1:100%" PRIuPTR, (test_counter * num_addresses) + i);
absl::StatusOr<URI> uri = URI::Parse(uri_string);
EXPECT_TRUE(uri.ok());
grpc_resolved_address address;

@ -130,7 +130,7 @@ TEST(MemoryQuotaTest, MakeSlice) {
for (int i = 1; i < 1000; i++) {
ExecCtx exec_ctx;
int min = i;
int max = 10 * i - 9;
int max = (10 * i) - 9;
slices.push_back(memory_allocator.MakeSlice(MemoryRequest(min, max)));
}
ExecCtx exec_ctx;

@ -185,10 +185,10 @@ static double threshold_for_count_below(grpc_histogram* h, double count_below) {
// should lie
lower_bound = bucket_start(h, static_cast<double>(lower_idx));
upper_bound = bucket_start(h, static_cast<double>(lower_idx + 1));
return grpc_core::Clamp(upper_bound - (upper_bound - lower_bound) *
(count_so_far - count_below) /
h->buckets[lower_idx],
h->min_seen, h->max_seen);
return grpc_core::Clamp(
upper_bound - ((upper_bound - lower_bound) *
(count_so_far - count_below) / h->buckets[lower_idx]),
h->min_seen, h->max_seen);
}
}

@ -29,7 +29,7 @@
namespace {
constexpr int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*);
constexpr int kPrintfPointerFieldWidth = 2 + (2 * sizeof(void*));
void DumpPCAndFrameSizeAndSymbol(void (*writerfn)(const char*, void*),
void* writerfn_arg, void* pc,

@ -25,7 +25,7 @@ void gsec_test_random_bytes(uint8_t* bytes, size_t length) {
srand(time(nullptr));
size_t ind;
for (ind = 0; ind < length; ind++) {
bytes[ind] = static_cast<uint8_t>(rand() % 255 + 1);
bytes[ind] = static_cast<uint8_t>((rand() % 255) + 1);
}
}

@ -29,7 +29,9 @@ TEST(ValidationErrors, NoErrors) {
EXPECT_EQ(errors.size(), 0);
{
ValidationErrors::ScopedField field(&errors, "foo");
{ ValidationErrors::ScopedField field(&errors, ".bar"); }
{
ValidationErrors::ScopedField field(&errors, ".bar");
}
}
EXPECT_TRUE(errors.ok());
EXPECT_EQ(errors.size(), 0);

@ -1007,7 +1007,7 @@ TEST_P(EdsTest, Drops) {
const double kDropRateForLb = kDropPerMillionForLb / 1000000.0;
const double kDropRateForThrottle = kDropPerMillionForThrottle / 1000000.0;
const double kDropRateForLbAndThrottle =
kDropRateForLb + (1 - kDropRateForLb) * kDropRateForThrottle;
kDropRateForLb + ((1 - kDropRateForLb) * kDropRateForThrottle);
const double kErrorTolerance = 0.05;
const size_t kNumRpcs =
ComputeIdealNumRpcs(kDropRateForLbAndThrottle, kErrorTolerance);
@ -1079,7 +1079,7 @@ TEST_P(EdsTest, DropConfigUpdate) {
const double kDropRateForLb = kDropPerMillionForLb / 1000000.0;
const double kDropRateForThrottle = kDropPerMillionForThrottle / 1000000.0;
const double kDropRateForLbAndThrottle =
kDropRateForLb + (1 - kDropRateForLb) * kDropRateForThrottle;
kDropRateForLb + ((1 - kDropRateForLb) * kDropRateForThrottle);
const size_t kNumRpcsLbOnly =
ComputeIdealNumRpcs(kDropRateForLb, kErrorTolerance);
const size_t kNumRpcsBoth =
@ -2340,7 +2340,7 @@ TEST_P(ClientLoadReportingTest, DropStats) {
const double kDropRateForLb = kDropPerMillionForLb / 1000000.0;
const double kDropRateForThrottle = kDropPerMillionForThrottle / 1000000.0;
const double kDropRateForLbAndThrottle =
kDropRateForLb + (1 - kDropRateForLb) * kDropRateForThrottle;
kDropRateForLb + ((1 - kDropRateForLb) * kDropRateForThrottle);
const size_t kNumRpcs =
ComputeIdealNumRpcs(kDropRateForLbAndThrottle, kErrorTolerance);
// The ADS response contains two drop categories.

@ -91,8 +91,8 @@ static void BM_CallbackUnaryPingPong(benchmark::State& state) {
cv.wait(l);
}
fixture.reset();
state.SetBytesProcessed(request_msgs_size * state.iterations() +
response_msgs_size * state.iterations());
state.SetBytesProcessed((request_msgs_size * state.iterations()) +
(response_msgs_size * state.iterations()));
}
} // namespace testing

@ -91,7 +91,7 @@ class RandomAsciiMetadata {
std::string s;
s.reserve(length + 1);
for (int i = 0; i < length; i++) {
s += static_cast<char>(rand() % 26 + 'a');
s += static_cast<char>((rand() % 26) + 'a');
}
return s;
}

@ -107,8 +107,8 @@ static void BM_UnaryPingPong(benchmark::State& state) {
fixture.reset();
server_env[0]->~ServerEnv();
server_env[1]->~ServerEnv();
state.SetBytesProcessed(state.range(0) * state.iterations() +
state.range(1) * state.iterations());
state.SetBytesProcessed((state.range(0) * state.iterations()) +
(state.range(1) * state.iterations()));
}
} // namespace testing
} // namespace grpc

@ -178,8 +178,8 @@ static void postprocess_scenario_result(ScenarioResult* result) {
result->mutable_summary()->set_server_cpu_usage(0);
} else {
auto server_cpu_usage =
100 - 100 * average(result->server_stats(), ServerIdleCpuTime) /
average(result->server_stats(), ServerTotalCpuTime);
100 - (100 * average(result->server_stats(), ServerIdleCpuTime) /
average(result->server_stats(), ServerTotalCpuTime));
result->mutable_summary()->set_server_cpu_usage(server_cpu_usage);
}

@ -180,7 +180,7 @@ static double BinarySearch(
const std::map<std::string, std::string>& per_worker_credential_types,
bool* success) {
while (low <= high * (1 - absl::GetFlag(FLAGS_error_tolerance))) {
double mid = low + (high - low) / 2;
double mid = low + ((high - low) / 2);
double current_cpu_load =
GetCpuLoad(scenario, mid, per_worker_credential_types, success);
VLOG(2) << absl::StrFormat("Binary Search: current_offered_load %.0f", mid);

@ -31,7 +31,7 @@
#include <sys/time.h>
static double time_double(struct timeval* tv) {
return tv->tv_sec + 1e-6 * tv->tv_usec;
return tv->tv_sec + (1e-6 * tv->tv_usec);
}
#endif
@ -39,7 +39,7 @@ UsageTimer::UsageTimer() : start_(Sample()) {}
double UsageTimer::Now() {
auto ts = gpr_now(GPR_CLOCK_REALTIME);
return ts.tv_sec + 1e-9 * ts.tv_nsec;
return ts.tv_sec + (1e-9 * ts.tv_nsec);
}
static void get_resource_usage(double* utime, double* stime) {

@ -63,7 +63,7 @@ namespace {
const char ACCESS_TOKEN_PREFIX[] = "access_token=";
constexpr int ACCESS_TOKEN_PREFIX_LEN =
sizeof(ACCESS_TOKEN_PREFIX) / sizeof(*ACCESS_TOKEN_PREFIX) - 1;
(sizeof(ACCESS_TOKEN_PREFIX) / sizeof(*ACCESS_TOKEN_PREFIX)) - 1;
bool IsAccessToken(const std::string& auth) {
return auth.length() > ACCESS_TOKEN_PREFIX_LEN &&

@ -112,5 +112,5 @@ DOCKERIMAGE_CURRENT_VERSIONS = {
"tools/dockerfile/test/rbe_ubuntu2004.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/rbe_ubuntu2004@sha256:b3eb1a17b7b091e3c5648a803076b2c40601242ff91c04d55997af6641305f68",
"tools/dockerfile/test/ruby_debian11_arm64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_debian11_arm64@sha256:d2e79919b2e2d4cc36a29682ecb5170641df4fb506cfb453978ffdeb8a841bd9",
"tools/dockerfile/test/ruby_debian11_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_debian11_x64@sha256:6e8b4696ba0661f11a31ed0992a94d2efcd889a018f57160f0e2fb62963f3593",
"tools/dockerfile/test/sanity.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/sanity@sha256:4fb77e7130e10934e65ec0657e286a8ca5850e9a25441dabe2174b3cb6a56180",
"tools/dockerfile/test/sanity.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/sanity@sha256:7fd5e54075e74ff4aa5eceb6f00dd15fd5151b43c30a85fa4bd5d55f3dcf8287",
}

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM silkeh/clang:18-bookworm
FROM silkeh/clang:19-bookworm
ADD clang_format_all_the_things.sh /

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM silkeh/clang:18-bookworm
FROM silkeh/clang:19-bookworm
# Install prerequisites for the clang-tidy script
RUN apt-get update && apt-get install -y python3 jq git && apt-get clean

@ -1 +1 @@
us-docker.pkg.dev/grpc-testing/testing-images-public/sanity:0006a2ed3aca736f842b3e1bf758cb6ab621922d@sha256:4fb77e7130e10934e65ec0657e286a8ca5850e9a25441dabe2174b3cb6a56180
us-docker.pkg.dev/grpc-testing/testing-images-public/sanity:7b20e380c8ace88e99a1ec934eed62f706aa5bfa@sha256:7fd5e54075e74ff4aa5eceb6f00dd15fd5151b43c30a85fa4bd5d55f3dcf8287

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM silkeh/clang:18-bookworm
FROM silkeh/clang:19-bookworm
#=================
# Basic C core dependencies

Loading…
Cancel
Save