[DTrace-devel] [PATCH v2 05/13] Handle steps==0 error for llquantize
eugene.loh at oracle.com
eugene.loh at oracle.com
Tue Dec 8 09:19:23 PST 2020
From: Eugene Loh <eugene.loh at oracle.com>
Specifying steps==0 was giving divide-by-zero failures.
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
libdtrace/dt_cg.c | 5 +++++
.../err.D_LLQUANT_STEPTYPE.llqstepszero.d | 20 +++++++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 test/unittest/aggs/err.D_LLQUANT_STEPTYPE.llqstepszero.d
diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index 8fcfeeb0..93aa1754 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -3208,6 +3208,11 @@ dt_cg_agg_llquantize(dt_pcb_t *pcb, dt_ident_t *aid, dt_node_t *dnp,
dnerror(arg4, D_LLQUANT_STEPTYPE, "llquantize( ) argument #4 "
"must be an integer constant\n");
+ if (!dt_node_is_posconst(arg4))
+ dnerror(arg4, D_LLQUANT_STEPTYPE, "llquantize( ) "
+ "argument #4 must be a non-zero positive "
+ "integer constant\n");
+
steps = (uint64_t)arg4->dn_value;
if (steps > UINT16_MAX)
diff --git a/test/unittest/aggs/err.D_LLQUANT_STEPTYPE.llqstepszero.d b/test/unittest/aggs/err.D_LLQUANT_STEPTYPE.llqstepszero.d
new file mode 100644
index 00000000..f2b0f442
--- /dev/null
+++ b/test/unittest/aggs/err.D_LLQUANT_STEPTYPE.llqstepszero.d
@@ -0,0 +1,20 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Licensed under the Universal Permissive License v 1.0 as shown at
+ * http://oss.oracle.com/licenses/upl.
+ */
+
+/*
+ * ASSERTION:
+ * llquantize() steps must be nonzero.
+ *
+ * SECTION: Aggregations/Aggregations
+ *
+ */
+
+
+BEGIN
+{
+ @ = llquantize(timestamp, 10, 0, 6, 0);
+}
--
2.18.4
More information about the DTrace-devel
mailing list