From 7d291bee3622b18c16d53a359a230306b67203f9 Mon Sep 17 00:00:00 2001 From: hunt Date: Fri, 6 Jul 2007 18:42:00 +0000 Subject: 2007-07-06 Martin Hunt * stat-common.c (__stp_stat_add): Fix calculations for linear histogram buckets. * stat.c (_stp_stat_init): Check for interval too small. --- runtime/stat.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'runtime/stat.c') diff --git a/runtime/stat.c b/runtime/stat.c index cf224e5e..f4e205aa 100644 --- a/runtime/stat.c +++ b/runtime/stat.c @@ -90,9 +90,16 @@ Stat _stp_stat_init (int type, ...) 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); } -- cgit