[glib] Fix the -Werror=format-nonliteral fixes for older GCCs
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Fix the -Werror=format-nonliteral fixes for older GCCs
- Date: Sun, 29 Sep 2013 18:35:16 +0000 (UTC)
commit ab5aa2aa3a43cbd94aa6d7f3d683f9875df7249a
Author: John Ralls <jralls ceridwen us>
Date: Sun Sep 29 11:33:30 2013 -0700
Fix the -Werror=format-nonliteral fixes for older GCCs
They don't allow that pragma inside functions.
gio/gcontenttype.c | 6 +++---
gio/gthreadedresolver.c | 8 +++++---
glib/gfileutils.c | 10 +++++-----
glib/gmarkup.c | 8 +++++---
glib/gstrfuncs.c | 7 ++++---
glib/gutils.c | 8 +++++---
6 files changed, 27 insertions(+), 20 deletions(-)
---
diff --git a/gio/gcontenttype.c b/gio/gcontenttype.c
index da9aa21..8dc5896 100644
--- a/gio/gcontenttype.c
+++ b/gio/gcontenttype.c
@@ -393,6 +393,8 @@ g_content_type_get_mime_type (const char *type)
return g_strdup (type);
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
static GIcon *
g_content_type_get_icon_internal (const gchar *type,
@@ -423,8 +425,6 @@ g_content_type_get_icon_internal (const gchar *type,
G_LOCK (gio_xdgmime);
xdg_icon = xdg_mime_get_icon (type);
G_UNLOCK (gio_xdgmime);
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
if (xdg_icon != NULL)
xdg_mimetype_icon = g_strdup_printf (file_template, xdg_icon);
@@ -440,7 +440,6 @@ g_content_type_get_icon_internal (const gchar *type,
xdg_mimetype_generic_icon = g_content_type_get_generic_icon_name (type);
if (xdg_mimetype_generic_icon)
generic_mimetype_icon = g_strdup_printf (file_template, xdg_mimetype_generic_icon);
-#pragma GCC diagnostic pop
if (generic_mimetype_icon)
icon_names[n++] = generic_mimetype_icon;
@@ -453,6 +452,7 @@ g_content_type_get_icon_internal (const gchar *type,
return themed_icon;
}
+#pragma GCC diagnostic pop
/**
* g_content_type_get_icon:
diff --git a/gio/gthreadedresolver.c b/gio/gthreadedresolver.c
index 23caddd..1ffaf15 100644
--- a/gio/gthreadedresolver.c
+++ b/gio/gthreadedresolver.c
@@ -505,6 +505,9 @@ g_resolver_record_type_to_rrtype (GResolverRecordType type)
g_return_val_if_reached (-1);
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static GList *
g_resolver_records_from_res_query (const gchar *rrname,
gint rrtype,
@@ -543,10 +546,7 @@ g_resolver_records_from_res_query (const gchar *rrname,
format = _("Error resolving '%s'");
}
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
g_set_error (error, G_RESOLVER_ERROR, errnum, format, rrname);
-#pragma GCC diagnostic pop
return NULL;
}
@@ -622,6 +622,8 @@ g_resolver_records_from_res_query (const gchar *rrname,
return records;
}
+#pragma GCC diagnostic pop
+
#elif defined(G_OS_WIN32)
static GVariant *
diff --git a/glib/gfileutils.c b/glib/gfileutils.c
index 51a3464..eb5baea 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -1008,6 +1008,9 @@ static char *
format_error_message (const gchar *filename,
const gchar *format_string) G_GNUC_FORMAT(2);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
static char *
format_error_message (const gchar *filename,
const gchar *format_string)
@@ -1016,18 +1019,15 @@ format_error_message (const gchar *filename,
gchar *display_name;
gchar *msg;
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
-
display_name = g_filename_display_name (filename);
msg = g_strdup_printf (format_string, display_name, g_strerror (saved_errno));
g_free (display_name);
-#pragma GCC diagnostic pop
-
return msg;
}
+#pragma GCC diagnostic pop
+
/* format string must have two '%s':
*
* - the place for the filename
diff --git a/glib/gmarkup.c b/glib/gmarkup.c
index a948f40..fb02a42 100644
--- a/glib/gmarkup.c
+++ b/glib/gmarkup.c
@@ -2366,6 +2366,9 @@ find_conversion (const char *format,
*
* Since: 2.4
*/
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
gchar *
g_markup_vprintf_escaped (const gchar *format,
va_list args)
@@ -2428,8 +2431,6 @@ g_markup_vprintf_escaped (const gchar *format,
/* Use them to format the arguments
*/
G_VA_COPY (args2, args);
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
output1 = g_strdup_vprintf (format1->str, args);
@@ -2443,7 +2444,6 @@ g_markup_vprintf_escaped (const gchar *format,
va_end (args2);
if (!output2)
goto cleanup;
-#pragma GCC diagnostic pop
result = g_string_new (NULL);
/* Iterate through the original format string again,
@@ -2495,6 +2495,8 @@ g_markup_vprintf_escaped (const gchar *format,
return NULL;
}
+#pragma GCC diagnostic pop
+
/**
* g_markup_printf_escaped:
* @format: printf() style format string
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index ae926a9..4fcd91c 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -881,6 +881,9 @@ g_ascii_dtostr (gchar *buffer,
return g_ascii_formatd (buffer, buf_len, "%.17g", d);
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
/**
* g_ascii_formatd:
* @buffer: A buffer to place the resulting string in
@@ -909,10 +912,7 @@ g_ascii_formatd (gchar *buffer,
locale_t old_locale;
old_locale = uselocale (get_C_locale ());
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
_g_snprintf (buffer, buf_len, format, d);
-#pragma GCC diagnostic pop
uselocale (old_locale);
return buffer;
@@ -991,6 +991,7 @@ g_ascii_formatd (gchar *buffer,
return buffer;
#endif
}
+#pragma GCC diagnostic pop
#define ISSPACE(c) ((c) == ' ' || (c) == '\f' || (c) == '\n' || \
(c) == '\r' || (c) == '\t' || (c) == '\v')
diff --git a/glib/gutils.c b/glib/gutils.c
index a59072d..2620cb6 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -2148,6 +2148,9 @@ g_format_size (guint64 size)
* Flags to modify the format of the string returned by g_format_size_full().
*/
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
/**
* g_format_size_full:
* @size: a size in bytes
@@ -2273,10 +2276,7 @@ g_format_size_full (guint64 size,
#endif
g_string_append (string, " (");
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
g_string_append_printf (string, translated_format, formatted_number);
-#pragma GCC diagnostic pop
g_free (formatted_number);
g_string_append (string, ")");
}
@@ -2284,6 +2284,8 @@ g_format_size_full (guint64 size,
return g_string_free (string, FALSE);
}
+#pragma GCC diagnostic pop
+
/**
* g_format_size_for_display:
* @size: a size in bytes
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]