* stat-common.c (__stp_stat_add): Fix calculations
for linear histogram buckets.
* stat.c (_stp_stat_init): Check for interval too
small.
+2007-07-06 Martin Hunt <hunt@redhat.com>
+
+ * stat-common.c (__stp_stat_add): Fix calculations
+ for linear histogram buckets.
+
+ * stat.c (_stp_stat_init): Check for interval too
+ small.
+
2007-07-05 Eugene Teo <eteo@redhat.com>
* regs.c (_stp_print_regs): #ifdef CONFIG_CPU_CP15 instead.
sd->histogram[n]++;
break;
case HIST_LINEAR:
- if (val < st->start)
- val = st->start;
- else
- val -= st->start;
+ val -= st->start;
+ if (val < 0)
+ val = 0;
do_div (val, st->interval);
if (val >= st->buckets)
val = st->buckets - 1;
start = va_arg(ap, int);
stop = va_arg(ap, int);
interval = va_arg(ap, int);
- /* FIXME. check interval != 0 and not too large */
+ if (interval == 0) {
+ _stp_warn("histogram: interval cannot be zero.\n");
+ return NULL;
+ }
buckets = (stop - start) / interval;
if ((stop - start) % interval) buckets++;
+ if (buckets > 128) {
+ _stp_warn("histogram: Interval is too small. Maximum buckets is 128.\n");
+ return NULL;
+ }
}
va_end (ap);
}