[network-manager-applet: 4/7] c-e: avoid format string warning for nm_connection_editor_error()



commit d50787b3cb25449f859e1c611dddc882b6a0c7ab
Author: Thomas Haller <thaller redhat com>
Date:   Mon Jun 6 13:47:09 2016 +0200

    c-e: avoid format string warning for nm_connection_editor_error()

 src/connection-editor/nm-connection-editor.c |   14 +++++++-------
 src/connection-editor/nm-connection-editor.h |    4 ++--
 src/connection-editor/nm-connection-list.c   |   15 +++++++--------
 3 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index 430ce8f..ee68236 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -1093,10 +1093,9 @@ nm_connection_editor_set_busy (NMConnectionEditor *editor, gboolean busy)
 
 static void
 nm_connection_editor_dialog (GtkWindow *parent, GtkMessageType type, const char *heading,
-                             const char *format, va_list args)
+                             const char *message)
 {
        GtkWidget *dialog;
-       char *message;
 
        dialog = gtk_message_dialog_new (parent,
                                         GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -1104,10 +1103,7 @@ nm_connection_editor_dialog (GtkWindow *parent, GtkMessageType type, const char
                                         GTK_BUTTONS_CLOSE,
                                         "%s", heading);
 
-       message = g_strdup_vprintf (format, args);
-
        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", message);
-       g_free (message);
 
        gtk_widget_show_all (dialog);
        gtk_window_present (GTK_WINDOW (dialog));
@@ -1119,20 +1115,24 @@ void
 nm_connection_editor_error (GtkWindow *parent, const char *heading, const char *format, ...)
 {
        va_list args;
+       gs_free char *message = NULL;
 
        va_start (args, format);
-       nm_connection_editor_dialog (parent, GTK_MESSAGE_ERROR, heading, format, args);
+       message = g_strdup_vprintf (format, args);
        va_end (args);
+       nm_connection_editor_dialog (parent, GTK_MESSAGE_ERROR, heading, message);
 }
 
 void
 nm_connection_editor_warning (GtkWindow *parent, const char *heading, const char *format, ...)
 {
        va_list args;
+       gs_free char *message = NULL;
 
        va_start (args, format);
-       nm_connection_editor_dialog (parent, GTK_MESSAGE_WARNING, heading, format, args);
+       message = g_strdup_vprintf (format, args);
        va_end (args);
+       nm_connection_editor_dialog (parent, GTK_MESSAGE_WARNING, heading, message);
 }
 
 void
diff --git a/src/connection-editor/nm-connection-editor.h b/src/connection-editor/nm-connection-editor.h
index 6275baf..76255ab 100644
--- a/src/connection-editor/nm-connection-editor.h
+++ b/src/connection-editor/nm-connection-editor.h
@@ -99,11 +99,11 @@ void                nm_connection_editor_set_busy (NMConnectionEditor *editor, g
 void                nm_connection_editor_error (GtkWindow *parent,
                                                 const char *heading,
                                                 const char *format,
-                                                ...);
+                                                ...) _nm_printf(3,4);
 void                nm_connection_editor_warning (GtkWindow *parent,
                                                   const char *heading,
                                                   const char *format,
-                                                  ...);
+                                                  ...) _nm_printf(3,4);
 
 void               nm_connection_editor_inter_page_set_value (NMConnectionEditor *editor,
                                                               InterPageChangeType type,
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index 7f2b3c7..0bd1db0 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -895,7 +895,6 @@ void
 nm_connection_list_create (NMConnectionList *self, GType ctype, const char *detail)
 {
        ConnectionTypeData *types;
-       char *error_msg;
        int i;
 
        g_return_if_fail (NM_IS_CONNECTION_LIST (self));
@@ -908,13 +907,13 @@ nm_connection_list_create (NMConnectionList *self, GType ctype, const char *deta
                        break;
        }
        if (!types[i].name) {
-               if (ctype == NM_TYPE_SETTING_VPN)
-                       error_msg = g_strdup (_("No VPN plugins are installed."));
-               else
-                       error_msg = g_strdup_printf (_("Don't know how to create '%s' connections"), 
g_type_name (ctype));
-
-               nm_connection_editor_error (NULL, _("Error creating connection"), error_msg);
-               g_free (error_msg);
+               if (ctype == NM_TYPE_SETTING_VPN) {
+                       nm_connection_editor_error (NULL, _("Error creating connection"),
+                                                   _("No VPN plugins are installed."));
+               } else {
+                       nm_connection_editor_error (NULL, _("Error creating connection"),
+                                                   _("Don't know how to create '%s' connections"), 
g_type_name (ctype));
+               }
        } else {
                new_connection_of_type (GTK_WINDOW (self->dialog),
                                        detail,


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