projects
/
liboping.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a673944
)
src/oping.c: Make sure the reported percentile value doesn't exceed the maximum.
author
Florian Forster
<ff@octo.it>
Sun, 12 Oct 2014 15:32:06 +0000
(17:32 +0200)
committer
Florian Forster
<ff@octo.it>
Sun, 12 Oct 2014 15:32:06 +0000
(17:32 +0200)
src/oping.c
patch
|
blob
|
history
diff --git
a/src/oping.c
b/src/oping.c
index
6496331
..
5e63392
100644
(file)
--- a/
src/oping.c
+++ b/
src/oping.c
@@
-278,6
+278,7
@@
static double context_get_percentile (ping_context_t *ctx, /* {{{ */
double threshold = percentile / 100.0;
double index_to_ms_factor;
size_t i;
double threshold = percentile / 100.0;
double index_to_ms_factor;
size_t i;
+ double ret;
if (ctx->histogram_ratio == NULL)
return (NAN);
if (ctx->histogram_ratio == NULL)
return (NAN);
@@
-295,7
+296,13
@@
static double context_get_percentile (ping_context_t *ctx, /* {{{ */
/* Multiply with i+1, because we're interested in the _upper_ bound of
* each bucket. */
/* Multiply with i+1, because we're interested in the _upper_ bound of
* each bucket. */
- return (index_to_ms_factor * ((double) (i + 1)));
+ ret = (index_to_ms_factor * ((double) (i + 1)));
+
+ /* Avoid reporting a higher latency than latency_max. */
+ if (ret > ctx->latency_max)
+ ret = ctx->latency_max;
+
+ return (ret);
} /* }}} double context_get_percentile */
static double context_get_stddev (ping_context_t *ctx) /* {{{ */
} /* }}} double context_get_percentile */
static double context_get_stddev (ping_context_t *ctx) /* {{{ */