overlay: Negative modulus

Don't use a negative index into the array if the desired element is
negative, just wrap around properly into the ring for the chart.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2014-12-21 13:49:25 +00:00
parent c537cdb08e
commit 7f9d14aa51

View File

@ -143,7 +143,11 @@ static double value_at(struct chart *chart, int n)
else if (n >= chart->current_sample)
n = chart->current_sample - 1;
return chart->samples[n % chart->num_samples];
n %= chart->num_samples;
if (n < 0)
n += chart->num_samples;
return chart->samples[n];
}
static double gradient_at(struct chart *chart, int n)