Date: Mon, 2 Feb 2015 20:48:31 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278114 - head/cddl/contrib/opensolaris/lib/libdtrace/common Message-ID: <201502022048.t12KmVYr080012@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Mon Feb 2 20:48:31 2015 New Revision: 278114 URL: https://svnweb.freebsd.org/changeset/base/278114 Log: 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 Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c Mon Feb 2 20:36:16 2015 (r278113) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c Mon Feb 2 20:48:31 2015 (r278114) @@ -382,6 +382,9 @@ dt_stddev(uint64_t *data, uint64_t norma 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502022048.t12KmVYr080012>