aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/support/histogram.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-07-05 21:08:33 -0700
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-07-05 21:08:33 -0700
commit27166a6f65581a9ee820882e5d7506d6bd07ade6 (patch)
tree0e89c5e09a955b2a074a8b34e0f3fe0a4135f346 /src/core/support/histogram.c
parent4efb6966bdfb62c725c6614b0d85ea374250bb51 (diff)
parentd1dd3a68a2d4af56f1409327c197590dac6968cb (diff)
Merge github.com:grpc/grpc into flow-like-lava-to-a-barnyard
Conflicts: src/core/surface/call.c src/core/transport/chttp2_transport.c src/core/transport/transport.h
Diffstat (limited to 'src/core/support/histogram.c')
-rw-r--r--src/core/support/histogram.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/core/support/histogram.c b/src/core/support/histogram.c
index 673affde71..9029703891 100644
--- a/src/core/support/histogram.c
+++ b/src/core/support/histogram.c
@@ -164,7 +164,9 @@ static double threshold_for_count_below(gpr_histogram *h, double count_below) {
size_t lower_idx;
size_t upper_idx;
- GPR_ASSERT(h->count >= 1);
+ if (h->count == 0) {
+ return 0.0;
+ }
if (count_below <= 0) {
return h->min_seen;
@@ -189,12 +191,12 @@ static double threshold_for_count_below(gpr_histogram *h, double count_below) {
break;
}
}
- return (bucket_start(h, lower_idx) + bucket_start(h, upper_idx)) / 2.0;
+ return (bucket_start(h, (double)lower_idx) + bucket_start(h, (double)upper_idx)) / 2.0;
} else {
/* treat values as uniform throughout the bucket, and find where this value
should lie */
- lower_bound = bucket_start(h, lower_idx);
- upper_bound = bucket_start(h, lower_idx + 1);
+ lower_bound = bucket_start(h, (double)lower_idx);
+ upper_bound = bucket_start(h, (double)(lower_idx + 1));
return GPR_CLAMP(upper_bound - (upper_bound - lower_bound) *
(count_so_far - count_below) /
h->buckets[lower_idx],