make sure that if we go beyond the max ratio, we just mark it as one
int index = 0;
ratio = latency / PING_DEF_TTL;
+ if (ratio > 1) {
+ ratio = 1;
+ }
if (ratio > 2/3.0) {
color = OPING_RED_HIST;
}
/* HOST_PRINTF ("%%r%f-ia%d-", ratio, index); */
index = index % (BARS_LEN-1);
/* HOST_PRINTF ("im%d-", index); */
- if (index < 0 || index >= BARS_LEN) {
+ if (index < 0) {
index = 0; /* safety check */
}
+ if (index >= BARS_LEN) {
+ index = BARS_LEN -1; /* safety check */
+ }
wattron (ctx->window, COLOR_PAIR(color));
mvwprintw (ctx->window,
/* y = */ 3,