In "print_trace_enter", for a

  Closure { "cbname" }

arg, we create the format string

  cbname=<fun>

and (accordingly) we don't create a value to print.

This is a problem for a subsequent patch. When we iterate over the values
to format, it's only the Closure pattern that does not invoke "pr"; all
other patterns result in a "pr" call.

In order to handle a Closure arg uniformly with the other types, reuse the
logic seen with the OClosure optarg pattern. Namely, create the format
string

  cbname=%s

and create the value

  "<fun>".

Two examples [lib/api.c]:

> @@ -1925,7 +1925,7 @@ nbd_opt_list_meta_context (struct nbd_ha
>    pthread_mutex_lock (&h->lock);
>    if_debug (h) {
>      debug (h,
> -           "enter: context=<fun>");
> +           "enter: context=%s", "<fun>");
>    }
>
>    if (unlikely (!opt_list_meta_context_in_permitted_state (h))) {
> @@ -1983,7 +1983,7 @@ nbd_opt_list_meta_context_queries (struc
>      char *queries_printable =
>          nbd_internal_printable_string_list (queries);
>      debug (h,
> -           "enter: queries=%s context=<fun>", queries_printable ? 
> queries_printable : "");
> +           "enter: queries=%s context=%s", queries_printable ? 
> queries_printable : "", "<fun>");
>      free (queries_printable);
>    }
>

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172516
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 generator/C.ml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/generator/C.ml b/generator/C.ml
index 6d880fb953e0..38b7580b39af 100644
--- a/generator/C.ml
+++ b/generator/C.ml
@@ -753,7 +753,7 @@ let
       | BytesIn (n, count)
       | BytesPersistIn (n, count) ->
          pr " %s=\\\"%%s\\\" %s=%%zu" n count
-      | Closure { cbname } -> pr " %s=<fun>" cbname
+      | Closure { cbname } -> pr " %s=%%s" cbname
       | Enum (n, _) -> pr " %s=%%d" n
       | Flags (n, _) -> pr " %s=0x%%x" n
       | Fd n | Int n -> pr " %s=%%d" n
@@ -783,7 +783,7 @@ let
          | BytesIn (n, count)
          | BytesPersistIn (n, count) ->
             pr ", %s_printable ? %s_printable : \"\", %s" n n count
-         | Closure { cbname } -> ()
+         | Closure _ -> pr ", \"<fun>\""
          | Enum (n, _) -> pr ", %s" n
          | Flags (n, _) -> pr ", %s" n
          | Fd n | Int n | Int64 n | SizeT n -> pr ", %s" n

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to