[DTrace-devel] [PATCH 10/22] Simplify dtrace_stmt_create() attr init

Kris Van Hees kris.van.hees at oracle.com
Sat Sep 14 16:25:57 UTC 2024


On Thu, Aug 29, 2024 at 01:22:07AM -0400, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> Even though dtrace_stmt_create() initializes dtsd_descattr and
> dtsd_stmtattr, there is no point to doing so.  Its only caller
> is dt_stmt_create(), which itself sets these members.

No, it is the other way around...  It should be done in dtrace_stmt_create()
and thus it is no longer needed in dt_stmt_create().  As dtrace_stmt_create()
is a libdtrace API function, it can be called from other code, and since it
is the function that actual creates the statement and initializes some of its
members, it is the logical place to retain setting the attr fields.

So, instead remove the assignments from dt_stmt_create().

> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
>  libdtrace/dt_program.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/libdtrace/dt_program.c b/libdtrace/dt_program.c
> index a4b052fc..bdb434e0 100644
> --- a/libdtrace/dt_program.c
> +++ b/libdtrace/dt_program.c
> @@ -240,8 +240,6 @@ dtrace_stmt_create(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp)
>  
>  	dt_ecbdesc_hold(edp);
>  	sdp->dtsd_ecbdesc = edp;
> -	sdp->dtsd_descattr = _dtrace_defattr;
> -	sdp->dtsd_stmtattr = _dtrace_defattr;
>  
>  	return sdp;
>  }
> -- 
> 2.43.5
> 



More information about the DTrace-devel mailing list