[network-manager-applet/nma-0-9-6] editor: use nm_utils_hwaddr_ntoa() for converting MAC address to string
- From: JiÅÃ KlimeÅ <jklimes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/nma-0-9-6] editor: use nm_utils_hwaddr_ntoa() for converting MAC address to string
- Date: Wed, 5 Sep 2012 13:35:11 +0000 (UTC)
commit 6dae878bbd1c2d0813f26b38cd6c447e33c903fe
Author: JiÅÃ KlimeÅ <jklimes redhat com>
Date: Wed Sep 5 14:59:26 2012 +0200
editor: use nm_utils_hwaddr_ntoa() for converting MAC address to string
and fix the string leakage.
src/connection-editor/page-wired.c | 11 +++++------
src/connection-editor/page-wireless.c | 10 ++++------
2 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/src/connection-editor/page-wired.c b/src/connection-editor/page-wired.c
index 2d1ad0f..58e13be 100644
--- a/src/connection-editor/page-wired.c
+++ b/src/connection-editor/page-wired.c
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2008 - 2011 Red Hat, Inc.
+ * (C) Copyright 2008 - 2012 Red Hat, Inc.
*/
#include "config.h"
@@ -31,6 +31,8 @@
#include <nm-setting-connection.h>
#include <nm-setting-wired.h>
#include <nm-device-ethernet.h>
+#include <nm-utils.h>
+#include <net/if_arp.h> /* for ARPHRD_ETHER for MAC utilies */
#include "page-wired.h"
@@ -174,11 +176,7 @@ populate_ui (CEPageWired *self)
/* Device MAC address */
mac_list = ce_page_get_mac_list (CE_PAGE (self));
s_mac = nm_setting_wired_get_mac_address (setting);
- s_mac_str = s_mac ? g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X",
- s_mac->data[0], s_mac->data[1], s_mac->data[2],
- s_mac->data[3], s_mac->data[4], s_mac->data[5]):
- NULL;
-
+ s_mac_str = s_mac ? nm_utils_hwaddr_ntoa (s_mac->data, ARPHRD_ETHER) : NULL;
for (iter = mac_list; iter && *iter; iter++) {
#if GTK_CHECK_VERSION (2,24,0)
gtk_combo_box_text_append_text (priv->device_mac, *iter);
@@ -202,6 +200,7 @@ populate_ui (CEPageWired *self)
if (entry)
gtk_entry_set_text (GTK_ENTRY (entry), active_mac ? active_mac : s_mac_str);
}
+ g_free (s_mac_str);
g_strfreev (mac_list);
g_signal_connect (priv->device_mac, "changed", G_CALLBACK (stuff_changed), self);
diff --git a/src/connection-editor/page-wireless.c b/src/connection-editor/page-wireless.c
index 886f175..74b48cf 100644
--- a/src/connection-editor/page-wireless.c
+++ b/src/connection-editor/page-wireless.c
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2008 - 2010 Red Hat, Inc.
+ * (C) Copyright 2008 - 2012 Red Hat, Inc.
*/
#include "config.h"
@@ -32,6 +32,7 @@
#include <nm-setting-wireless.h>
#include <nm-device-wifi.h>
#include <nm-utils.h>
+#include <net/if_arp.h> /* for ARPHRD_ETHER for MAC utilies */
#include "page-wireless.h"
@@ -374,11 +375,7 @@ populate_ui (CEPageWireless *self)
/* Device MAC address */
mac_list = ce_page_get_mac_list (CE_PAGE (self));
s_mac = nm_setting_wireless_get_mac_address (setting);
- s_mac_str = s_mac ? g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X",
- s_mac->data[0], s_mac->data[1], s_mac->data[2],
- s_mac->data[3], s_mac->data[4], s_mac->data[5]):
- NULL;
-
+ s_mac_str = s_mac ? nm_utils_hwaddr_ntoa (s_mac->data, ARPHRD_ETHER) : NULL;
for (iter = mac_list; iter && *iter; iter++) {
#if GTK_CHECK_VERSION (2,24,0)
gtk_combo_box_text_append_text (priv->device_mac, *iter);
@@ -402,6 +399,7 @@ populate_ui (CEPageWireless *self)
if (entry)
gtk_entry_set_text (GTK_ENTRY (entry), active_mac ? active_mac : s_mac_str);
}
+ g_free (s_mac_str);
g_strfreev (mac_list);
g_signal_connect_swapped (priv->device_mac, "changed", G_CALLBACK (ce_page_changed), self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]