We're going to want to call "pr_wrap_cstr" in a subsequent patch, for wrapping format strings. "pr_wrap_cstr" only handles a single C string literal, but we may generate a format string that actually consists of multiple string literals. We "exit" and "reenter" string literals only for the various PRI* macros. We can get away with this if we remove the space characters surrounding the PRI* macros; that way, "pr_wrap_cstr" will not be tempted to wrap there -- that is, wrap at a space *outside* of a string literal.
Some examples of the effect this patch has [lib/api.c]: > @@ -332,7 +332,7 @@ nbd_set_private_data (struct nbd_handle > /* This function must not call set_error. */ > if_debug (h) { > debug_direct (h, "nbd_set_private_data", > - "enter: private_data=%" PRIuPTR "", private_data); > + "enter: private_data=%"PRIuPTR"", private_data); > } > > ret = nbd_unlocked_set_private_data (h, private_data); > @@ -2613,7 +2613,7 @@ nbd_connect_vsock (struct nbd_handle *h, > pthread_mutex_lock (&h->lock); > if_debug (h) { > debug (h, > - "enter: cid=%" PRIu32 " port=%" PRIu32 "", cid, port); > + "enter: cid=%"PRIu32" port=%"PRIu32"", cid, port); > } > > if (unlikely (!connect_vsock_in_permitted_state (h))) { > @@ -3716,7 +3716,7 @@ nbd_pread (struct nbd_handle *h, void *b > pthread_mutex_lock (&h->lock); > if_debug (h) { > debug (h, > - "enter: buf=<buf> count=%zu offset=%" PRIu64 " flags=0x%x", > count, offset, flags); > + "enter: buf=<buf> count=%zu offset=%"PRIu64" flags=0x%x", count, > offset, flags); > } > > if (h->pread_initialize) Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172516 Signed-off-by: Laszlo Ersek <ler...@redhat.com> --- generator/C.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generator/C.ml b/generator/C.ml index b4118bf41b3a..43601625bcb0 100644 --- a/generator/C.ml +++ b/generator/C.ml @@ -757,16 +757,16 @@ let | Enum (n, _) -> pr " %s=%%d" n | Flags (n, _) -> pr " %s=0x%%x" n | Fd n | Int n -> pr " %s=%%d" n - | Int64 n -> pr " %s=%%\" PRIi64 \"" n + | Int64 n -> pr " %s=%%\"PRIi64\"" n | SizeT n -> pr " %s=%%zu" n | SockAddrAndLen (n, len) -> pr " %s=<sockaddr> %s=%%d" n len | Path n | String n -> pr " %s=%%s" n | StringList n -> pr " %s=%%s" n | UInt n -> pr " %s=%%u" n - | UInt32 n -> pr " %s=%%\" PRIu32 \"" n - | UInt64 n -> pr " %s=%%\" PRIu64 \"" n - | UIntPtr n -> pr " %s=%%\" PRIuPTR \"" n + | UInt32 n -> pr " %s=%%\"PRIu32\"" n + | UInt64 n -> pr " %s=%%\"PRIu64\"" n + | UIntPtr n -> pr " %s=%%\"PRIuPTR\"" n ) args; List.iter ( function _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://listman.redhat.com/mailman/listinfo/libguestfs