[network-manager-applet] coverity: fix warnings found with Coverity in nm-applet/nm-c-e
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet] coverity: fix warnings found with Coverity in nm-applet/nm-c-e
- Date: Fri, 15 Nov 2013 15:46:35 +0000 (UTC)
commit 77216f3ea5f29030541f9c52095f1de1c2848744
Author: Jiří Klimeš <jklimes redhat com>
Date: Fri Nov 8 08:40:16 2013 +0100
coverity: fix warnings found with Coverity in nm-applet/nm-c-e
https://bugzilla.redhat.com/show_bug.cgi?id=1025894#c3
Signed-off-by: Thomas Haller <thaller redhat com>
src/ap-menu-item.c | 2 +-
src/applet-device-ethernet.c | 2 +-
src/applet-device-gsm.c | 7 +++----
src/applet-device-wifi.c | 4 ++--
src/applet-dialogs.c | 4 +---
src/connection-editor/ce-page.c | 2 ++
src/connection-editor/ip4-routes-dialog.c | 2 +-
src/connection-editor/page-dsl.c | 4 ----
src/connection-editor/page-general.c | 8 +++++---
src/connection-editor/page-ip4.c | 4 +---
src/connection-editor/page-ip6.c | 4 +---
src/libnm-gtk/nm-wifi-dialog.c | 8 ++++----
src/mobile-helpers.c | 7 ++++---
13 files changed, 26 insertions(+), 32 deletions(-)
---
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index 500ad06..ad60d6b 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -151,7 +151,7 @@ nm_network_menu_item_best_strength (NMNetworkMenuItem * item,
g_return_if_fail (item != NULL);
g_return_if_fail (NM_IS_NETWORK_MENU_ITEM (item));
- strength = CLAMP (strength, 0, 100);
+ strength = MIN (strength, 100);
/* Just do nothing if the new strength is less */
if (strength < item->int_strength)
diff --git a/src/applet-device-ethernet.c b/src/applet-device-ethernet.c
index 30b19c8..6e1c5a3 100644
--- a/src/applet-device-ethernet.c
+++ b/src/applet-device-ethernet.c
@@ -365,7 +365,7 @@ pppoe_get_secrets (SecretsRequest *req, GError **error)
gtk_window_set_title (GTK_WINDOW (info->dialog), _("DSL authentication"));
gtk_window_set_modal (GTK_WINDOW (info->dialog), TRUE);
- w = gtk_dialog_add_button (GTK_DIALOG (info->dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+ gtk_dialog_add_button (GTK_DIALOG (info->dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
w = gtk_dialog_add_button (GTK_DIALOG (info->dialog), GTK_STOCK_OK, GTK_RESPONSE_OK);
info->ok_button = w;
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index 4409b58..ca5ad53 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -484,7 +484,7 @@ unlock_pin_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
msg = error ? error->message : NULL;
applet_mobile_pin_dialog_stop_spinner (info->dialog, msg);
- g_warning ("%s: error unlocking with PIN: %s", __func__, error->message);
+ g_warning ("%s: error unlocking with PIN: %s", __func__, error ? error->message : "unknown");
g_clear_error (&error);
}
@@ -507,7 +507,7 @@ unlock_puk_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
msg = error ? error->message : NULL;
applet_mobile_pin_dialog_stop_spinner (info->dialog, msg);
- g_warning ("%s: error unlocking with PIN: %s", __func__, error->message);
+ g_warning ("%s: error unlocking with PUK: %s", __func__, error ? error->message : "unknown");
g_clear_error (&error);
}
@@ -540,8 +540,7 @@ unlock_dialog_response (GtkDialog *dialog,
code1 = applet_mobile_pin_dialog_get_entry1 (info->dialog);
if (!code1 || !strlen (code1)) {
- g_warn_if_fail (code1 != NULL);
- g_warn_if_fail (strlen (code1));
+ g_warn_if_fail (code1 != NULL && strlen (code1));
unlock_dialog_destroy (info);
return;
}
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index eb09ed3..24bf2c9 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -1283,10 +1283,10 @@ wifi_get_icon (NMDevice *device,
break;
case NM_DEVICE_STATE_ACTIVATED:
if (ap) {
- guint32 strength;
+ guint8 strength;
strength = nm_access_point_get_strength (ap);
- strength = CLAMP (strength, 0, 100);
+ strength = MIN (strength, 100);
if (strength > 80)
pixbuf = nma_icon_check_and_load ("nm-signal-100", &applet->wifi_100_icon,
applet);
diff --git a/src/applet-dialogs.c b/src/applet-dialogs.c
index e084c27..c717493 100644
--- a/src/applet-dialogs.c
+++ b/src/applet-dialogs.c
@@ -227,11 +227,9 @@ create_info_label_security (NMConnection *connection)
connection_type = nm_setting_connection_get_connection_type (s_con);
if (!strcmp (connection_type, NM_SETTING_WIRELESS_SETTING_NAME)) {
- NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
NMSetting8021x *s_8021x;
- s_wireless = nm_connection_get_setting_wireless (connection);
s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
s_8021x = nm_connection_get_setting_802_1x (connection);
@@ -957,7 +955,7 @@ applet_mobile_password_dialog_new (NMConnection *connection,
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_window_set_title (GTK_WINDOW (dialog), _("Mobile broadband network password"));
- w = gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+ gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
w = gtk_dialog_add_button (dialog, GTK_STOCK_OK, GTK_RESPONSE_OK);
gtk_window_set_default (GTK_WINDOW (dialog), w);
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index da5a429..866d2cc 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -81,6 +81,8 @@ ce_get_property_default (NMSetting *setting, const char *property_name)
GParamSpec *spec;
GValue value = { 0, };
+ g_return_val_if_fail (NM_IS_SETTING (setting), -1);
+
spec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), property_name);
g_return_val_if_fail (spec != NULL, -1);
diff --git a/src/connection-editor/ip4-routes-dialog.c b/src/connection-editor/ip4-routes-dialog.c
index 7650c2b..494a357 100644
--- a/src/connection-editor/ip4-routes-dialog.c
+++ b/src/connection-editor/ip4-routes-dialog.c
@@ -426,7 +426,7 @@ cell_changed_cb (GtkEditable *editable,
/* Is it a prefix? */
if (!strchr (cell_text, '.')) {
tmp_prefix = strtol (cell_text, NULL, 10);
- if (!errno && tmp_prefix >= 0 && tmp_prefix <= 32)
+ if (!errno && tmp_prefix <= 32)
value_valid = TRUE;
} else {
struct in_addr tmp_addr;
diff --git a/src/connection-editor/page-dsl.c b/src/connection-editor/page-dsl.c
index f2394eb..ea35b27 100644
--- a/src/connection-editor/page-dsl.c
+++ b/src/connection-editor/page-dsl.c
@@ -68,7 +68,6 @@ populate_ui (CEPageDsl *self, NMConnection *connection)
CEPageDslPrivate *priv = CE_PAGE_DSL_GET_PRIVATE (self);
NMSettingPPPOE *setting = priv->setting;
const char *str;
- GHashTable *secrets = NULL;
str = nm_setting_pppoe_get_username (setting);
if (str)
@@ -79,9 +78,6 @@ populate_ui (CEPageDsl *self, NMConnection *connection)
if (str)
gtk_entry_set_text (priv->password, str);
- if (secrets)
- g_hash_table_destroy (secrets);
-
str = nm_setting_pppoe_get_service (setting);
if (str)
gtk_entry_set_text (priv->service, str);
diff --git a/src/connection-editor/page-general.c b/src/connection-editor/page-general.c
index 307d61c..6831fec 100644
--- a/src/connection-editor/page-general.c
+++ b/src/connection-editor/page-general.c
@@ -71,9 +71,11 @@ zones_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
CEPageGeneralPrivate *priv = CE_PAGE_GENERAL_GET_PRIVATE (self);
GError *error = NULL;
- dbus_g_proxy_end_call (proxy, call, &error,
- G_TYPE_STRV, &priv->zones,
- G_TYPE_INVALID);
+ if (!dbus_g_proxy_end_call (proxy, call, &error,
+ G_TYPE_STRV, &priv->zones,
+ G_TYPE_INVALID)) {
+ g_warning ("Failed to zones from FirewallD: (%d) %s", error->code, error->message);
+ }
priv->got_zones = TRUE;
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index fccc9cf..e35e8ac 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -1178,9 +1178,7 @@ ui_to_setting (CEPageIP4 *self)
if (strlen (stripped))
search_domains = g_slist_prepend (search_domains, g_strdup (stripped));
}
-
- if (items)
- g_strfreev (items);
+ g_strfreev (items);
}
search_domains = g_slist_reverse (search_domains);
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index b7ee693..1713a7f 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -1138,9 +1138,7 @@ ui_to_setting (CEPageIP6 *self)
if (strlen (stripped))
nm_setting_ip6_config_add_dns_search (priv->setting, stripped);
}
-
- if (items)
- g_strfreev (items);
+ g_strfreev (items);
}
may_fail = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->ip6_required));
diff --git a/src/libnm-gtk/nm-wifi-dialog.c b/src/libnm-gtk/nm-wifi-dialog.c
index b870943..546d6cc 100644
--- a/src/libnm-gtk/nm-wifi-dialog.c
+++ b/src/libnm-gtk/nm-wifi-dialog.c
@@ -533,8 +533,8 @@ connection_combo_init (NMAWifiDialog *self, NMConnection *connection)
gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "connection_label")));
gtk_widget_hide (widget);
}
- gtk_tree_model_get_iter_first (priv->connection_model, &tree_iter);
- gtk_tree_model_get (priv->connection_model, &tree_iter, C_CON_COLUMN, &priv->connection, -1);
+ if (gtk_tree_model_get_iter_first (priv->connection_model, &tree_iter))
+ gtk_tree_model_get (priv->connection_model, &tree_iter, C_CON_COLUMN, &priv->connection, -1);
return TRUE;
}
@@ -642,8 +642,8 @@ device_combo_init (NMAWifiDialog *self, NMDevice *device)
gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (priv->builder, "device_label")));
gtk_widget_hide (widget);
}
- gtk_tree_model_get_iter_first (priv->device_model, &iter);
- gtk_tree_model_get (priv->device_model, &iter, D_DEV_COLUMN, &priv->device, -1);
+ if (gtk_tree_model_get_iter_first (priv->device_model, &iter))
+ gtk_tree_model_get (priv->device_model, &iter, D_DEV_COLUMN, &priv->device, -1);
}
return num_added > 0 ? TRUE : FALSE;
diff --git a/src/mobile-helpers.c b/src/mobile-helpers.c
index adc45d9..b8f8d5c 100644
--- a/src/mobile-helpers.c
+++ b/src/mobile-helpers.c
@@ -268,8 +268,9 @@ mobile_helper_wizard (NMDeviceModemCapabilities capabilities,
method->provider_name = _("GSM");
else if (wizard_capability == NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
method->provider_name = _("CDMA");
- else
- g_assert_not_reached ();
+
+ g_assert ( wizard_capability == NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS
+ || wizard_capability == NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO);
mobile_wizard_done (NULL, FALSE, method, info);
g_free (method);
@@ -449,7 +450,7 @@ ask_for_pin (GtkEntry **out_secret_entry)
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_window_set_title (GTK_WINDOW (dialog), _("PIN code required"));
- ok_button = gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+ gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
ok_button = gtk_dialog_add_button (dialog, GTK_STOCK_OK, GTK_RESPONSE_OK);
gtk_window_set_default (GTK_WINDOW (dialog), ok_button);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]