Add -Wformat-nonliteral -Wformat-security

And fix the resulting compile failures.

I'm sorry about the patch necessary to gstclockoverlay.h but after
talking to Tim we decided we can live with it.
This commit is contained in:
Benjamin Otte 2010-03-17 10:53:21 +01:00
parent 20c9b8eae3
commit 1471df894a
3 changed files with 28 additions and 6 deletions

View file

@ -308,10 +308,11 @@ dnl set location of plugin directory
AG_GST_SET_PLUGINDIR
dnl define an ERROR_CFLAGS Makefile variable
AG_GST_SET_ERROR_CFLAGS($GST_GIT, [-Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wundef -Wwrite-strings])
dnl -Wformat-nonliteral - see ext/pango/gstclockoverlay.c and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39438
AG_GST_SET_ERROR_CFLAGS($GST_GIT, [-Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wformat-nonliteral -Wformat-security])
dnl define an ERROR_CXXFLAGS Makefile variable
AG_GST_SET_ERROR_CXXFLAGS($GST_GIT, [-Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wundef -Wwrite-strings])
AG_GST_SET_ERROR_CXXFLAGS($GST_GIT, [-Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wformat-nonliteral -Wformat-security])
dnl define correct level for debugging messages
AG_GST_SET_LEVEL_DEFAULT($GST_GIT)

View file

@ -56,6 +56,24 @@ struct _GstClockOverlayClass {
GType gst_clock_overlay_get_type (void);
/* This is a hack hat allows us to use nonliterals for strftime without
* triggering a warning from -Wformat-nonliteral. We need to allow this
* because we export the format string as a property of the element.
* For the inspiration of this and a discussion of why this is necessary,
* see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39438
*/
#ifdef __GNUC__
#pragma GCC system_header
static size_t my_strftime(char *s, size_t max, const char *format,
const struct tm *tm)
{
return strftime (s, max, format, tm);
}
#define strftime my_strftime
#endif
G_END_DECLS
#endif /* __GST_CLOCK_OVERLAY_H__ */

View file

@ -56,9 +56,9 @@ mpl2_parse_line (ParserState * state, const gchar * line, guint line_num)
markup = g_string_new (NULL);
while (1) {
const gchar *format_string;
const gchar *sep;
gchar *line_chunk_escaped;
gboolean italics;
/* skip leading white spaces */
while (*line == ' ' || *line == '\t')
@ -66,10 +66,11 @@ mpl2_parse_line (ParserState * state, const gchar * line, guint line_num)
/* a '/' at the beginning indicates italics */
if (*line == '/') {
format_string = "<i>%s</i>";
italics = TRUE;
g_string_append (markup, "<i>");
++line;
} else {
format_string = "%s";
italics = FALSE;
}
if ((sep = strchr (line, '|')))
@ -78,10 +79,12 @@ mpl2_parse_line (ParserState * state, const gchar * line, guint line_num)
line_chunk_escaped = g_markup_escape_text (line, -1);
GST_LOG ("escaped line: %s", line_chunk_escaped);
g_string_append_printf (markup, format_string, line_chunk_escaped);
g_string_append (markup, line_chunk_escaped);
g_free (line_chunk_escaped);
if (italics)
g_string_append (markup, "</i>");
if (sep == NULL)
break;