[epiphany] Reenable and placate -Wformat-nonliteral



commit 33b98b07f23f0840be5869b4521cc811d00f6aef
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sat Nov 7 18:02:24 2015 -0600

    Reenable and placate -Wformat-nonliteral

 configure.ac                 |    2 +-
 embed/ephy-embed-utils.c     |    4 ++++
 embed/ephy-embed.c           |    7 +------
 embed/ephy-web-view.c        |    4 ++++
 lib/ephy-sqlite-connection.c |    4 ++--
 lib/ephy-time-helpers.c      |    4 ++++
 6 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 688513b..c44eb90 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,7 +38,7 @@ AX_COMPILER_FLAGS([WARN_CFLAGS], [WARN_LDFLAGS], [$ax_is_release], [-Wdeclaratio
        dnl TODO: Remove all of these! These warnings should be fixed, not
        dnl silenced. At least, for the most part. -Wswitch-enum really does
        dnl seem pretty dumb.
-       [-Wno-shadow -Wno-format-nonliteral -Wno-deprecated-declarations -Wno-switch-enum -Wno-switch-default 
-Wno-redundant-decls -Wno-discarded-qualifiers -Wno-sign-compare])
+       [-Wno-shadow -Wno-deprecated-declarations -Wno-switch-enum -Wno-switch-default -Wno-redundant-decls 
-Wno-discarded-qualifiers -Wno-sign-compare])
 
 AC_PROG_CC
 
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index e58f3a7..9f2854d 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -242,8 +242,12 @@ ephy_embed_utils_autosearch_address (const char *search_key)
   }
 
   query_param = soup_form_encode ("q", search_key, NULL);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+  /* Format string under control of user input... but gsettings is trusted input. */
   /* + 2 here is getting rid of 'q=' */
   effective_address = g_strdup_printf (url_search, query_param + 2);
+#pragma GCC diagnostic pop
   g_free (query_param);
   g_free (url_search);
 
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index e2dfded..0560984 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -65,7 +65,6 @@ struct _EphyEmbed {
   GtkWidget *floating_bar;
   GtkWidget *progress;
   GtkWidget *fullscreen_message_label;
-  char *fullscreen_string;
 
   char *title;
   WebKitURIRequest *delayed_request;
@@ -416,7 +415,6 @@ ephy_embed_finalize (GObject *object)
   g_slist_free (embed->keys);
   embed->keys = NULL;
 
-  g_free (embed->fullscreen_string);
   g_free (embed->title);
 
   G_OBJECT_CLASS (ephy_embed_parent_class)->finalize (object);
@@ -529,11 +527,8 @@ ephy_embed_set_fullscreen_message (EphyEmbed *embed,
 {
   char *message;
 
-  if (G_UNLIKELY (embed->fullscreen_string == NULL))
-    embed->fullscreen_string = g_strdup (_("Press %s to exit fullscreen"));
-
   /* Translators: 'ESC' and 'F11' are keyboard keys. */
-  message = g_strdup_printf (embed->fullscreen_string, is_html5_fullscreen ? _("ESC") : _("F11"));
+  message = g_strdup_printf (_("Press %s to exit fullscreen"), is_html5_fullscreen ? _("ESC") : _("F11"));
   gtk_label_set_text (GTK_LABEL (embed->fullscreen_message_label),
                       message);
   g_free (message);
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index b02d474..f5fbc64 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -1906,6 +1906,9 @@ ephy_web_view_load_error_page (EphyWebView *view,
   if (load_anyway_js == NULL)
     load_anyway_js = g_strdup_printf ("window.location = '%s';", uri);
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+  /* The HTML file is trusted input. */
   g_string_printf (html,
                    g_bytes_get_data (html_file, NULL),
                    lang, lang,
@@ -1915,6 +1918,7 @@ ephy_web_view_load_error_page (EphyWebView *view,
                    load_anyway_js,
                    custom_class,
                    msg_title, msg, button_label);
+#pragma GCC diagnostic pop
 
   g_bytes_unref (html_file);
   g_free (stylesheet);
diff --git a/lib/ephy-sqlite-connection.c b/lib/ephy-sqlite-connection.c
index 0ea678c..1f64869 100644
--- a/lib/ephy-sqlite-connection.c
+++ b/lib/ephy-sqlite-connection.c
@@ -60,7 +60,7 @@ static void
 set_error_from_string (const char* string, GError **error)
 {
   if (error)
-    *error = g_error_new (get_ephy_sqlite_quark (), 0, string, 0);
+    *error = g_error_new_literal (get_ephy_sqlite_quark (), 0, string);
 }
 
 EphySQLiteConnection *
@@ -102,7 +102,7 @@ void
 ephy_sqlite_connection_get_error (EphySQLiteConnection *self, GError **error)
 {
   if (error)
-    *error = g_error_new (get_ephy_sqlite_quark (), 0, sqlite3_errmsg (self->priv->database), 0);
+    *error = g_error_new_literal (get_ephy_sqlite_quark (), 0, sqlite3_errmsg (self->priv->database));
 }
 
 gboolean
diff --git a/lib/ephy-time-helpers.c b/lib/ephy-time-helpers.c
index 383468d..84a0208 100644
--- a/lib/ephy-time-helpers.c
+++ b/lib/ephy-time-helpers.c
@@ -150,8 +150,12 @@ eel_strdup_strftime (const char *format, struct tm *time_pieces)
                }
                code[i++] = *remainder;
                code[i++] = '\0';
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+                /* Format string under control of caller, since this is a wrapper for strftime. */
                string_length = strftime (buffer, sizeof (buffer),
                                          code, time_pieces);
+#pragma GCC diagnostic pop
                if (string_length == 0) {
                        /* We could put a warning here, but there's no
                         * way to tell a successful conversion to


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]