From: Arran Cudbard-Bell Date: Wed, 17 Mar 2021 16:53:05 +0000 (+0000) Subject: Fix talloc developer's debug output X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=006f5cc2ebc6cc591336175a45ba76375be5341b;p=thirdparty%2Ffreeradius-server.git Fix talloc developer's debug output --- diff --git a/src/lib/unlang/xlat_eval.c b/src/lib/unlang/xlat_eval.c index 6c0eb55d89e..b28dab0bad2 100644 --- a/src/lib/unlang/xlat_eval.c +++ b/src/lib/unlang/xlat_eval.c @@ -1039,9 +1039,11 @@ xlat_action_t xlat_frame_eval_repeat(TALLOC_CTX *ctx, fr_dcursor_t *out, thread_inst = xlat_thread_instance_find(node); - XLAT_DEBUG("** [%i] %s(func-async) - %%{%s:%pM}", + XLAT_DEBUG("** [%i] %s(func-async) - %%%c%s:%pM%c", unlang_interpret_stack_depth(request), __FUNCTION__, - node->fmt, result); + (node->call.func->input_type == XLAT_INPUT_ARGS) ? '(' : '{', + node->fmt, result, + (node->call.func->input_type == XLAT_INPUT_ARGS) ? ')' : '}'); VALUE_BOX_LIST_VERIFY(result); /* diff --git a/src/lib/unlang/xlat_tokenize.c b/src/lib/unlang/xlat_tokenize.c index 0ad36bcbfcb..409a1bec218 100644 --- a/src/lib/unlang/xlat_tokenize.c +++ b/src/lib/unlang/xlat_tokenize.c @@ -571,7 +571,7 @@ static int xlat_resolve_virtual_attribute(xlat_exp_t *node, tmpl_t *vpt) xlat_exp_set_name_buffer_shallow(node, vpt->name); XLAT_DEBUG("VIRTUAL <-- %pV", - fr_box_strvalue_len(fr_sbuff_current(in), fr_sbuff_remaining(in))); + fr_box_strvalue_len(vpt->name, vpt->len)); node->call.func = func; node->attr = vpt; /* Store for context */ node->flags.needs_async = func->needs_async; diff --git a/src/lib/util/value.c b/src/lib/util/value.c index 073fc858e8a..2375d038f03 100644 --- a/src/lib/util/value.c +++ b/src/lib/util/value.c @@ -3255,7 +3255,7 @@ int fr_value_box_copy(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t case FR_TYPE_GROUP: { - fr_value_box_t *child; + fr_value_box_t *child = NULL; fr_value_box_copy_meta(dst, src); /* Initialises group child dlist */ @@ -4859,17 +4859,19 @@ ssize_t fr_value_box_print(fr_sbuff_t *out, fr_value_box_t const *data, fr_sbuff case FR_TYPE_GROUP: { - fr_value_box_t vb; + fr_value_box_t *child = NULL; ssize_t slen; - /* - * Be lazy by just converting it to a string, and then printing the string. - */ - if (fr_value_box_cast_to_strvalue(NULL, &vb, FR_TYPE_STRING, NULL, data) < 0) return 0; + FR_SBUFF_IN_CHAR_RETURN(&our_out, '{'); + + while ((child = fr_dlist_next(&data->vb_group, child))) { + slen = fr_value_box_print(&our_out, child, e_rules); + if (slen < 0) return slen; - slen = fr_value_box_print(&our_out, &vb, e_rules); - fr_value_box_clear(&vb); - if (slen < 0) return slen; + if (fr_dlist_next(&data->vb_group, child)) FR_SBUFF_IN_STRCPY_LITERAL_RETURN(&our_out, ", "); + } + + FR_SBUFF_IN_CHAR_RETURN(&our_out, '}'); } break; @@ -5235,12 +5237,13 @@ bool fr_value_box_list_tainted(fr_value_box_list_t const *head) /** Validation function to check that a fr_value_box_t is correctly initialised * - * @note Do not add talloc checks here. fr_value_box_t may be allocated on the stack. */ -void value_box_verify(char const *file, int line, fr_value_box_t const *vb) +void value_box_verify(char const *file, int line, fr_value_box_t const *vb, bool talloced) { fr_fatal_assert_msg(vb, "CONSISTENCY CHECK FAILED %s[%i]: fr_value_box_t pointer was NULL", file, line); + if (talloced) talloc_get_type_abort_const(vb, fr_value_box_t); + switch (vb->type) { case FR_TYPE_STRING: fr_fatal_assert_msg(vb->vb_strvalue, "CONSISTENCY CHECK FAILED %s[%i]: fr_value_box_t strvalue field " @@ -5261,7 +5264,7 @@ void value_box_verify(char const *file, int line, fr_value_box_t const *vb) break; case FR_TYPE_GROUP: - value_box_list_verify(file, line, &vb->vb_group); + value_box_list_verify(file, line, &vb->vb_group, talloced); break; default: @@ -5269,11 +5272,9 @@ void value_box_verify(char const *file, int line, fr_value_box_t const *vb) } } -void value_box_list_verify(char const *file, int line, fr_value_box_list_t const *list) +void value_box_list_verify(char const *file, int line, fr_value_box_list_t const *list, bool talloced) { fr_value_box_t const *vb = NULL; - FR_DLIST_VERIFY(list); - - while ((vb = fr_dlist_next(list, vb))) value_box_verify(file, line, vb); + while ((vb = fr_dlist_next(list, vb))) value_box_verify(file, line, vb, talloced); }