[network-manager-applet: 5/7] src: use NM_PRAGMA_WARNING_DISABLE() macro and add assertion for non-static format string
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet: 5/7] src: use NM_PRAGMA_WARNING_DISABLE() macro and add assertion for non-static format string
- Date: Mon, 6 Jun 2016 12:54:45 +0000 (UTC)
commit bd904be8e1686c551ad7049b2415718fabea0be5
Author: Thomas Haller <thaller redhat com>
Date: Mon Jun 6 14:15:05 2016 +0200
src: use NM_PRAGMA_WARNING_DISABLE() macro and add assertion for non-static format string
src/applet-dialogs.c | 1 -
src/connection-editor/ce-page.c | 5 ++---
src/connection-editor/page-dcb.c | 30 +++++++++++++++++++++++-------
3 files changed, 25 insertions(+), 11 deletions(-)
---
diff --git a/src/applet-dialogs.c b/src/applet-dialogs.c
index 55d97bc..10b56c0 100644
--- a/src/applet-dialogs.c
+++ b/src/applet-dialogs.c
@@ -27,7 +27,6 @@
#include <arpa/inet.h>
#include <NetworkManager.h>
-#include <glib/gi18n.h>
#include "applet-dialogs.h"
#include "utils.h"
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index f113eba..6b7678a 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -509,10 +509,9 @@ ce_page_get_next_available_name (const GPtrArray *connections, const char *forma
char *temp;
gboolean found = FALSE;
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ NM_PRAGMA_WARNING_DISABLE("-Wformat-nonliteral")
temp = g_strdup_printf (format, i);
-#pragma GCC diagnostic pop
+ NM_PRAGMA_WARNING_REENABLE
for (iter = names; iter; iter = g_slist_next (iter)) {
if (!strcmp (iter->data, temp)) {
found = TRUE;
diff --git a/src/connection-editor/page-dcb.c b/src/connection-editor/page-dcb.c
index e7d64bd..4d995d3 100644
--- a/src/connection-editor/page-dcb.c
+++ b/src/connection-editor/page-dcb.c
@@ -47,6 +47,25 @@ typedef struct {
/***************************************************************************/
+static char *
+_strdup_printf_uint (const char *format, guint i)
+{
+#if NM_MORE_ASSERTS
+ const char *f = format;
+
+ g_assert (f);
+ f = strchr (f, '%');
+ g_assert (f);
+ f++;
+ g_assert (!strchr (f, '%'));
+ g_assert (f[0] == 'u');
+#endif
+
+ NM_PRAGMA_WARNING_DISABLE("-Wformat-nonliteral")
+ return g_strdup_printf (format, i);
+ NM_PRAGMA_WARNING_REENABLE
+}
+
static void
pfc_dialog_show (CEPageDcb *self)
{
@@ -93,8 +112,6 @@ pfc_dialog_show (CEPageDcb *self)
ce_page_changed (CE_PAGE (self));
}
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
static gboolean
uint_entries_validate (GtkBuilder *builder, const char *fmt, gint max, gboolean sum)
{
@@ -109,7 +126,7 @@ uint_entries_validate (GtkBuilder *builder, const char *fmt, gint max, gboolean
gdk_rgba_parse (&bgcolor, "red3");
for (i = 0; i < 8; i++) {
- tmp = g_strdup_printf (fmt, i);
+ tmp = _strdup_printf_uint (fmt, i);
entry = GTK_ENTRY (gtk_builder_get_object (builder, tmp));
g_free (tmp);
g_assert (entry);
@@ -168,7 +185,7 @@ combos_handle (GtkBuilder *builder,
guint i, num;
for (i = 0; i < 8; i++) {
- tmp = g_strdup_printf (fmt, i);
+ tmp = _strdup_printf_uint (fmt, i);
combo = GTK_COMBO_BOX (gtk_builder_get_object (builder, tmp));
g_free (tmp);
g_assert (combo);
@@ -218,7 +235,7 @@ uint_entries_handle (GtkBuilder *builder,
const char *text;
for (i = 0; i < 8; i++) {
- tmp = g_strdup_printf (fmt, i);
+ tmp = _strdup_printf_uint (fmt, i);
entry = GTK_ENTRY (gtk_builder_get_object (builder, tmp));
g_free (tmp);
g_assert (entry);
@@ -257,7 +274,7 @@ bool_entries_handle (GtkBuilder *builder,
guint i;
for (i = 0; i < 8; i++) {
- tmp = g_strdup_printf (fmt, i);
+ tmp = _strdup_printf_uint (fmt, i);
toggle = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, tmp));
g_free (tmp);
g_assert (toggle);
@@ -270,7 +287,6 @@ bool_entries_handle (GtkBuilder *builder,
g_assert_not_reached ();
}
}
-#pragma GCC diagnostic pop
static void
pg_dialog_show (CEPageDcb *self)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]