]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix talloc developer's debug output
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 17 Mar 2021 16:53:05 +0000 (16:53 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 17 Mar 2021 16:53:05 +0000 (16:53 +0000)
src/lib/unlang/xlat_eval.c
src/lib/unlang/xlat_tokenize.c
src/lib/util/value.c

index 6c0eb55d89e67f26206e061c4a1c76eeb02f704b..b28dab0bad2be7bcc7f0fd26de585f983a148b5e 100644 (file)
@@ -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);
                        /*
index 0ad36bcbfcb09589f28df688e9d52e21b4c232e6..409a1bec21886360e85eb525690f001382f57c41 100644 (file)
@@ -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;
index 073fc858e8a7ad5f9492bf0966c41fa36e8c2647..2375d038f030e8bead185a0d1bf0db2bf12704fb 100644 (file)
@@ -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);
 }