mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-21 05:26:23 +00:00
validate: Don't use sprintf + glib format modifiers
We do not have a way to know the format modifiers to use with string functions provided by the system. `G_GUINT64_FORMAT` and other string modifiers only work for glib string formatting functions. We cannot use them for string functions provided by the stdlib. See: https://developer.gnome.org/glib/stable/glib-Basic-Types.html#glib-Basic-Types.description ``` ../validate/plugins/flow/formatting.c: In function 'format_number': ../validate/plugins/flow/formatting.c:68:22: error: unknown conversion type character 'l' in format [-Werror=format=] sprintf (dest_str, "%" G_GUINT64_FORMAT, number); ^~~ In file included from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/include/glib-2.0/glib/gtypes.h:32, from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/include/glib-2.0/glib/galloca.h:32, from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/include/glib-2.0/glib.h:30, from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/include/gstreamer-1.0/gst/gst.h:27, from ../validate/plugins/flow/formatting.h:26, from ../validate/plugins/flow/formatting.c:30: /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/lib/glib-2.0/include/glibconfig.h:69:28: note: format string is defined here #define G_GUINT64_FORMAT "llu" ^ ../validate/plugins/flow/formatting.c:68:22: error: too many arguments for format [-Werror=format-extra-args] sprintf (dest_str, "%" G_GUINT64_FORMAT, number); ^~~ ../validate/plugins/flow/formatting.c:68:22: error: unknown conversion type character 'l' in format [-Werror=format=] In file included from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/include/glib-2.0/glib/gtypes.h:32, from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/include/glib-2.0/glib/galloca.h:32, from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/include/glib-2.0/glib.h:30, from /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/include/gstreamer-1.0/gst/gst.h:27, from ../validate/plugins/flow/formatting.h:26, from ../validate/plugins/flow/formatting.c:30: /builds/nirbheek/cerbero/cerbero-build/dist/windows_x86_64/lib/glib-2.0/include/glibconfig.h:69:28: note: format string is defined here #define G_GUINT64_FORMAT "llu" ^ ../validate/plugins/flow/formatting.c:68:22: error: too many arguments for format [-Werror=format-extra-args] sprintf (dest_str, "%" G_GUINT64_FORMAT, number); ^~~ ``` Needed for https://gitlab.freedesktop.org/gstreamer/cerbero/merge_requests/419
This commit is contained in:
parent
77b6bf2050
commit
d0e6c8a78c
1 changed files with 3 additions and 2 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <gst/gst.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <glib/gprintf.h>
|
||||
|
||||
#include "../../gst/validate/gst-validate-utils.h"
|
||||
|
||||
|
@ -56,7 +57,7 @@ void
|
|||
format_time (gchar * dest_str, guint64 time)
|
||||
{
|
||||
if (GST_CLOCK_TIME_IS_VALID (time)) {
|
||||
sprintf (dest_str, "%" GST_TIME_FORMAT, GST_TIME_ARGS (time));
|
||||
g_sprintf (dest_str, "%" GST_TIME_FORMAT, GST_TIME_ARGS (time));
|
||||
} else {
|
||||
strcpy (dest_str, "none");
|
||||
}
|
||||
|
@ -65,7 +66,7 @@ format_time (gchar * dest_str, guint64 time)
|
|||
static void
|
||||
format_number (gchar * dest_str, guint64 number)
|
||||
{
|
||||
sprintf (dest_str, "%" G_GUINT64_FORMAT, number);
|
||||
g_sprintf (dest_str, "%" G_GUINT64_FORMAT, number);
|
||||
}
|
||||
|
||||
gchar *
|
||||
|
|
Loading…
Reference in a new issue