diff options
author | markj <markj@FreeBSD.org> | 2015-02-02 20:48:31 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2015-02-02 20:48:31 +0000 |
commit | 8b7f81c74b06dd92865d64bd7f5887738b3d447e (patch) | |
tree | 2e4bcfee47df06ba8662139a7ad342320138d586 /cddl/contrib/opensolaris/lib/libdtrace/common | |
parent | 03db0c9a45d83e232c6954379473d2f1456f9b3a (diff) | |
download | FreeBSD-src-8b7f81c74b06dd92865d64bd7f5887738b3d447e.zip FreeBSD-src-8b7f81c74b06dd92865d64bd7f5887738b3d447e.tar.gz |
Let the standard deviation of the empty set be 0. This is consistent with
the behaviour for averages, and fixes a crash that can occur when attempting
to print a stddev aggregation containing no elements:
dtrace:::BEGIN { @ = stddev(0); clear(@); printa("%@d", @); }
PR: 197260
MFC after: 2 week
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libdtrace/common')
-rw-r--r-- | cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c index 7eae398..da804ee 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c @@ -382,6 +382,9 @@ dt_stddev(uint64_t *data, uint64_t normal) int64_t norm_avg; uint64_t diff[2]; + if (data[0] == 0) + return (0); + /* * The standard approximation for standard deviation is * sqrt(average(x**2) - average(x)**2), i.e. the square root |