[DTrace-devel] [PATCH v2 05/13] Handle steps==0 error for llquantize

Kris Van Hees kris.van.hees at oracle.com
Tue Dec 8 10:22:52 PST 2020


On Tue, Dec 08, 2020 at 12:19:23PM -0500, eugene.loh at oracle.com wrote:
> 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");
> +

I should have added one extra comment...  You can get rid of the preceding
test for arg4 being an integer constant because that is covered in this new
one alreasy.
>  
>  	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
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list