Fix debug format strings for non-LP64 platforms

Unfortunately the format string for a size_t, `%zu`, is not portable
to all Windows compilers, and the appropriate format string for the
fundamental type that implements size_t varies between platforms
(typically `%u` on 32-bit platforms, `%lu` on 64-bit Linux or
`%llu` on 64-bit Windows).

In gtk-demo, cast the number of search results to long, to avoid
breaking up a translatable string.

Elsewhere, use GLib's abstraction for this.

Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
Simon McVittie 2024-07-27 15:20:23 +01:00
parent e2a7dc5427
commit 15a09c79f9
6 changed files with 8 additions and 8 deletions

View File

@ -936,7 +936,7 @@ search_results_update (GObject *filter_model,
char *text;
if (n_items > 0)
text = g_strdup_printf (ngettext ("%ld search result", "%ld search results", n_items), n_items);
text = g_strdup_printf (ngettext ("%ld search result", "%ld search results", (long) n_items), (long) n_items);
else
text = g_strdup (_("No search results"));

View File

@ -1167,7 +1167,7 @@ gdk_vulkan_save_pipeline_cache (GdkDisplay *display)
file = gdk_vulkan_get_pipeline_cache_file (display);
GDK_DEBUG (VULKAN, "Saving pipeline cache of size %lu to %s", size, g_file_peek_path (file));
GDK_DEBUG (VULKAN, "Saving pipeline cache of size %" G_GSIZE_FORMAT " to %s", size, g_file_peek_path (file));
if (!g_file_replace_contents (file,
data,
@ -1261,7 +1261,7 @@ gdk_display_create_pipeline_cache (GdkDisplay *display)
}
else
{
GDK_DEBUG (VULKAN, "Loading pipeline cache (%lu bytes)", display->vk_pipeline_cache_size);
GDK_DEBUG (VULKAN, "Loading pipeline cache (%" G_GSIZE_FORMAT " bytes)", display->vk_pipeline_cache_size);
}
}

View File

@ -51,7 +51,7 @@ update_dmabuf_formats (DmabufFormatsInfo *info)
DmabufFormats *formats = info->dmabuf_formats;
GDK_DISPLAY_DEBUG (info->display, MISC,
"dmabuf format table (%lu entries)", info->n_dmabuf_formats);
"dmabuf format table (%" G_GSIZE_FORMAT " entries)", info->n_dmabuf_formats);
GDK_DISPLAY_DEBUG (info->display, MISC,
"dmabuf main device: %u %u",
major (formats->main_device),
@ -67,7 +67,7 @@ update_dmabuf_formats (DmabufFormatsInfo *info)
minor (tranche->target_device));
GDK_DISPLAY_DEBUG (info->display, MISC,
"dmabuf%s tranche (%lu entries):",
"dmabuf%s tranche (%" G_GSIZE_FORMAT " entries):",
tranche->flags & ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT ? " scanout" : "",
tranche->n_formats);

View File

@ -304,7 +304,7 @@ handle_cache_method (GDBusConnection *connection,
self->in_get_items = FALSE;
GTK_DEBUG (A11Y, "Returning %lu items", g_variant_n_children (items));
GTK_DEBUG (A11Y, "Returning %" G_GSIZE_FORMAT " items", g_variant_n_children (items));
g_dbus_method_invocation_return_value (invocation, items);
}

View File

@ -242,7 +242,7 @@ gtk_css_parser_finalize (GtkCssParser *self)
g_clear_object (&self->file);
g_clear_object (&self->directory);
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
g_critical ("Finalizing CSS parser with %lu remaining blocks", gtk_css_parser_blocks_get_size (&self->blocks));
g_critical ("Finalizing CSS parser with %" G_GSIZE_FORMAT " remaining blocks", gtk_css_parser_blocks_get_size (&self->blocks));
gtk_css_parser_blocks_clear (&self->blocks);
g_free (self);

View File

@ -105,7 +105,7 @@ image_distance (const guchar *data,
if (g_test_verbose() &&
dist > 0)
{
g_print ("worst pixel %lu %lu: %f %f %f %f vs %f %f %f %f\n",
g_print ("worst pixel %" G_GSIZE_FORMAT " %" G_GSIZE_FORMAT ": %f %f %f %f vs %f %f %f %f\n",
imax, jmax, r1, g1, b1, a1, r2, g2, b2, a2);
}