From: Alan T. DeKok Date: Fri, 3 Jun 2022 22:29:49 +0000 (-0400) Subject: simply omit optional arguments, rather than making them FR_TYPE_NULL X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a79d03e23a4a651bf83c3e39fbfbd03e16621b97;p=thirdparty%2Ffreeradius-server.git simply omit optional arguments, rather than making them FR_TYPE_NULL We want FR_TYPE_NULL to mean something else, and we don't want to use it as a normal result. --- diff --git a/src/lib/unlang/xlat_builtin.c b/src/lib/unlang/xlat_builtin.c index a8ef02f6b71..0dac2b39fb0 100644 --- a/src/lib/unlang/xlat_builtin.c +++ b/src/lib/unlang/xlat_builtin.c @@ -1668,7 +1668,7 @@ static xlat_action_t xlat_func_lpad(UNUSED TALLOC_CTX *ctx, fr_dcursor_t *out, /* * Fill is optional */ - if (fill->type != FR_TYPE_NULL) { + if (fill) { fill_str = fill->vb_strvalue; fill_len = talloc_array_length(fill_str) - 1; } @@ -1756,7 +1756,7 @@ static xlat_action_t xlat_func_rpad(UNUSED TALLOC_CTX *ctx, fr_dcursor_t *out, /* * Fill is optional */ - if (fill->type != FR_TYPE_NULL) { + if (fill) { fill_str = fill->vb_strvalue; fill_len = talloc_array_length(fill_str) - 1; } diff --git a/src/lib/unlang/xlat_eval.c b/src/lib/unlang/xlat_eval.c index ab0029864a8..dbb4a162b7e 100644 --- a/src/lib/unlang/xlat_eval.c +++ b/src/lib/unlang/xlat_eval.c @@ -415,10 +415,9 @@ xlat_action_t xlat_process_args(TALLOC_CTX *ctx, fr_value_box_list_t *list, requ } /* - * Add a placeholder 'null' box + * The argument isn't required. Just omit it. xlat_func_args() enforces + * that optional arguments are at the end of the argument list. */ - MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_NULL, NULL, false)); - fr_dlist_insert_tail(list, vb); return XLAT_ACTION_DONE; }