[gnome-control-center] network: Fix warning about freeing const string
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Fix warning about freeing const string
- Date: Wed, 14 Nov 2018 10:43:33 +0000 (UTC)
commit 41e34268739255cf2463ebb505d7906d5d43e8ed
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Nov 13 15:30:03 2018 +1300
network: Fix warning about freeing const string
The use of g_clear_pointer (&str, g_free) with str being a const gchar *
caused warning errors.
Instead of using str for both constant and allocated strings use separate
variables. Autofree the allocated strings.
panels/network/connection-editor/ce-page-details.c | 38 ++++++++++------------
1 file changed, 18 insertions(+), 20 deletions(-)
---
diff --git a/panels/network/connection-editor/ce-page-details.c
b/panels/network/connection-editor/ce-page-details.c
index c972c0e5b..dbcc3d363 100644
--- a/panels/network/connection-editor/ce-page-details.c
+++ b/panels/network/connection-editor/ce-page-details.c
@@ -186,8 +186,11 @@ connect_details_page (CEPageDetails *page)
guint strength;
NMDeviceState state;
NMAccessPoint *active_ap;
- const gchar *str;
+ g_autofree gchar *speed_label = NULL;
const gchar *type;
+ const gchar *hw_address = NULL;
+ g_autofree gchar *security_string = NULL;
+ const gchar *strength_label;
gboolean device_is_active;
sc = nm_connection_get_setting_connection (CE_PAGE (page)->connection);
@@ -222,42 +225,37 @@ connect_details_page (CEPageDetails *page)
}
}
if (speed > 0)
- str = g_strdup_printf (_("%d Mb/s"), speed);
- else
- str = NULL;
- panel_set_device_widget_details (CE_PAGE (page)->builder, "speed", str);
- g_clear_pointer (&str, g_free);
+ speed_label = g_strdup_printf (_("%d Mb/s"), speed);
+ panel_set_device_widget_details (CE_PAGE (page)->builder, "speed", speed_label);
if (NM_IS_DEVICE_WIFI (page->device))
- str = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (page->device));
+ hw_address = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (page->device));
else if (NM_IS_DEVICE_ETHERNET (page->device))
- str = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (page->device));
+ hw_address = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (page->device));
- panel_set_device_widget_details (CE_PAGE (page)->builder, "mac", str);
+ panel_set_device_widget_details (CE_PAGE (page)->builder, "mac", hw_address);
- str = NULL;
if (device_is_active && active_ap)
- str = get_ap_security_string (active_ap);
- panel_set_device_widget_details (CE_PAGE (page)->builder, "security", str);
- g_clear_pointer (&str, g_free);
+ security_string = get_ap_security_string (active_ap);
+ panel_set_device_widget_details (CE_PAGE (page)->builder, "security", security_string);
strength = 0;
if (page->ap != NULL)
strength = nm_access_point_get_strength (page->ap);
if (strength <= 0)
- str = NULL;
+ strength_label = NULL;
else if (strength < 20)
- str = C_("Signal strength", "None");
+ strength_label = C_("Signal strength", "None");
else if (strength < 40)
- str = C_("Signal strength", "Weak");
+ strength_label = C_("Signal strength", "Weak");
else if (strength < 50)
- str = C_("Signal strength", "Ok");
+ strength_label = C_("Signal strength", "Ok");
else if (strength < 80)
- str = C_("Signal strength", "Good");
+ strength_label = C_("Signal strength", "Good");
else
- str = C_("Signal strength", "Excellent");
- panel_set_device_widget_details (CE_PAGE (page)->builder, "strength", str);
+ strength_label = C_("Signal strength", "Excellent");
+ panel_set_device_widget_details (CE_PAGE (page)->builder, "strength", strength_label);
/* set IP entries */
if (device_is_active)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]