diff options
author | Thomas Haller <thaller@redhat.com> | 2016-06-05 11:46:06 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-06-05 12:22:01 +0200 |
commit | 466bf2f6332e15a447a40e2a92b7f4493502855a (patch) | |
tree | aa7ae204fd0c5aabe3319b18dd71596a385af6fe /clients | |
parent | b1e267cd8ac371ff97186cdb986314643041cd6a (diff) | |
download | NetworkManager-466bf2f6332e15a447a40e2a92b7f4493502855a.tar.gz |
build: avoid compiler warnings about non-constant format strings (-Wformat-nonliteral)
Diffstat (limited to 'clients')
-rw-r--r-- | clients/cli/connections.c | 3 | ||||
-rw-r--r-- | clients/cli/devices.c | 15 | ||||
-rw-r--r-- | clients/cli/general.c | 15 | ||||
-rw-r--r-- | clients/cli/utils.c | 2 | ||||
-rw-r--r-- | clients/cli/utils.h | 2 | ||||
-rw-r--r-- | clients/tui/newt/nmt-newt-utils.h | 4 | ||||
-rw-r--r-- | clients/tui/nm-editor-utils.c | 16 |
7 files changed, 35 insertions, 22 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 0e9a18ed2d..0c61667d92 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -53,6 +53,8 @@ #define PROMPT_IP_TUNNEL_MODE _("Tunnel mode: ") #define PROMPT_MACVLAN_MODE _("MACVLAN mode: ") +#define BASE_PROMPT "nmcli> " + /* Available fields for 'connection show' */ static NmcOutputField nmc_fields_con_show[] = { {"NAME", N_("NAME")}, /* 0 */ @@ -9006,7 +9008,6 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t gboolean cmd_loop = TRUE; char *cmd_arg = NULL; char *cmd_arg_s, *cmd_arg_p, *cmd_arg_v; - const char *BASE_PROMPT = "nmcli> "; const NameItem *valid_settings_main = NULL; const NameItem *valid_settings_slave = NULL; char *valid_settings_str = NULL; diff --git a/clients/cli/devices.c b/clients/cli/devices.c index e1688278a4..cd4f942966 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -2498,13 +2498,16 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv) show_access_point_info (device, nmc); } } else { - const char *err_msg; if ( nm_device_get_device_type (device) == NM_DEVICE_TYPE_GENERIC - && g_strcmp0 (nm_device_get_type_description (device), "wifi") == 0) - err_msg = _("Error: Device '%s' was not recognized as a Wi-Fi device, check NetworkManager Wi-Fi plugin."); - else - err_msg = _("Error: Device '%s' is not a Wi-Fi device."); - g_string_printf (nmc->return_text, err_msg, ifname); + && g_strcmp0 (nm_device_get_type_description (device), "wifi") == 0) { + g_string_printf (nmc->return_text, + _("Error: Device '%s' was not recognized as a Wi-Fi device, check NetworkManager Wi-Fi plugin."), + ifname); + } else { + g_string_printf (nmc->return_text, + _("Error: Device '%s' is not a Wi-Fi device."), + ifname); + } nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; goto error; } diff --git a/clients/cli/general.c b/clients/cli/general.c index 280630c194..60022d18dc 100644 --- a/clients/cli/general.c +++ b/clients/cli/general.c @@ -893,20 +893,13 @@ static void networkmanager_running (NMClient *client, GParamSpec *param, NmCli *nmc) { gboolean running; - NmcTermColor color; - const char *message; char *str; running = nm_client_get_nm_running (client); - if (running) { - color = NMC_TERM_COLOR_GREEN; - message = _("NetworkManager has started"); - } else { - color = NMC_TERM_COLOR_RED; - message = _("NetworkManager has stopped"); - } - - str = nmc_colorize (nmc, color, NMC_TERM_FORMAT_NORMAL, message); + str = nmc_colorize (nmc, + running ? NMC_TERM_COLOR_GREEN : NMC_TERM_COLOR_RED, + NMC_TERM_FORMAT_NORMAL, + running ? _("NetworkManager has started") : _("NetworkManager has stopped")); g_print ("%s\n", str); g_free (str); } diff --git a/clients/cli/utils.c b/clients/cli/utils.c index a406eee459..361a98aafd 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -1005,7 +1005,7 @@ colorize_string (NmCli *nmc, if ( use_colors (nmc) && (color != NMC_TERM_COLOR_NORMAL || color_fmt != NMC_TERM_FORMAT_NORMAL)) { - out = nmc_colorize (nmc, color, color_fmt, str); + out = nmc_colorize (nmc, color, color_fmt, "%s", str); *dealloc = TRUE; } else { out = (char *) str; diff --git a/clients/cli/utils.h b/clients/cli/utils.h index eab60d3a10..917a237074 100644 --- a/clients/cli/utils.h +++ b/clients/cli/utils.h @@ -74,7 +74,7 @@ void nmc_terminal_show_progress (const char *str); const char *nmc_term_color_sequence (NmcTermColor color); const char *nmc_term_format_sequence (NmcTermFormat format); NmcTermColor nmc_term_color_parse_string (const char *str, GError **error); -char *nmc_colorize (NmCli *nmc, NmcTermColor color, NmcTermFormat format, const char * fmt, ...); +char *nmc_colorize (NmCli *nmc, NmcTermColor color, NmcTermFormat format, const char * fmt, ...) __attribute__((__format__ (__printf__, 4, 5))); void nmc_filter_out_colors_inplace (char *str); char *nmc_filter_out_colors (const char *str); char *nmc_get_user_input (const char *ask_str); diff --git a/clients/tui/newt/nmt-newt-utils.h b/clients/tui/newt/nmt-newt-utils.h index 706f10d3e3..4cbe8a09a3 100644 --- a/clients/tui/newt/nmt-newt-utils.h +++ b/clients/tui/newt/nmt-newt-utils.h @@ -41,11 +41,11 @@ char *nmt_newt_locale_from_utf8 (const char *str_utf8); int nmt_newt_text_width (const char *str); void nmt_newt_message_dialog (const char *message, - ...); + ...) __attribute__((__format__ (__printf__, 1, 2))); int nmt_newt_choice_dialog (const char *button1, const char *button2, const char *message, - ...); + ...) __attribute__((__format__ (__printf__, 3, 4))); char *nmt_newt_edit_string (const char *data); diff --git a/clients/tui/nm-editor-utils.c b/clients/tui/nm-editor-utils.c index e582d41fcc..4040e6ce05 100644 --- a/clients/tui/nm-editor-utils.c +++ b/clients/tui/nm-editor-utils.c @@ -252,6 +252,16 @@ nm_editor_utils_get_connection_type_list (void) return list; } +static void +_assert_format_int (const char *format) +{ + g_assert (format); + format = strchr (format, '%'); + g_assert (format); + g_assert (!strchr (format, '%')); + g_assert (format[1] == 'd'); +} + static char * get_available_connection_name (const char *format, NMClient *client) @@ -261,6 +271,10 @@ get_available_connection_name (const char *format, char *cname = NULL; int i = 0; +#if NM_MORE_ASSERTS + _assert_format_int (format); +#endif + conns = nm_client_get_connections (client); for (i = 0; i < conns->len; i++) { const char *id; @@ -275,7 +289,9 @@ get_available_connection_name (const char *format, char *temp; gboolean found = FALSE; + NM_PRAGMA_WARNING_DISABLE("-Wformat-nonliteral") temp = g_strdup_printf (format, i); + NM_PRAGMA_WARNING_REENABLE for (iter = names; iter; iter = g_slist_next (iter)) { if (!strcmp (iter->data, temp)) { found = TRUE; |