Commit b224ab8e authored by Kjartan Maraas's avatar Kjartan Maraas Committed by Dan Williams

trivial: let g_free and g_strdup handle NULL (bgo #644763)

parent 925f21f7
......@@ -508,8 +508,7 @@ finalize (GObject *object)
if (priv->ssid)
g_byte_array_free (priv->ssid, TRUE);
if (priv->bssid)
g_free (priv->bssid);
g_free (priv->bssid);
G_OBJECT_CLASS (nm_access_point_parent_class)->finalize (object);
}
......
......@@ -322,11 +322,8 @@ finalize (GObject *object)
{
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object);
if (priv->hw_address)
g_free (priv->hw_address);
if (priv->perm_hw_address)
g_free (priv->perm_hw_address);
g_free (priv->hw_address);
g_free (priv->perm_hw_address);
G_OBJECT_CLASS (nm_device_ethernet_parent_class)->finalize (object);
}
......
......@@ -763,11 +763,8 @@ finalize (GObject *object)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object);
if (priv->hw_address)
g_free (priv->hw_address);
if (priv->perm_hw_address)
g_free (priv->perm_hw_address);
g_free (priv->hw_address);
g_free (priv->perm_hw_address);
G_OBJECT_CLASS (nm_device_wifi_parent_class)->finalize (object);
}
......
......@@ -186,9 +186,7 @@ finalize (GObject *object)
{
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object);
if (priv->banner)
g_free (priv->banner);
g_free (priv->banner);
g_object_unref (priv->proxy);
G_OBJECT_CLASS (nm_vpn_connection_parent_class)->finalize (object);
......
......@@ -1024,10 +1024,8 @@ nm_connection_set_path (NMConnection *connection, const char *path)
priv = NM_CONNECTION_GET_PRIVATE (connection);
if (priv->path) {
g_free (priv->path);
priv->path = NULL;
}
g_free (priv->path);
priv->path = NULL;
if (path)
priv->path = g_strdup (path);
......
......@@ -502,9 +502,7 @@ finalize (GObject *object)
NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (object);
g_free (priv->method);
if (priv->dns)
g_slist_free (priv->dns);
g_slist_free (priv->dns);
nm_utils_slist_free (priv->dns_search, g_free);
nm_utils_slist_free (priv->addresses, g_free);
......
......@@ -195,7 +195,7 @@ property_changed (DBusGProxy *proxy,
|| (priv->name && !str)
|| (priv->name && str && strcmp (priv->name, str))) {
g_free (priv->name);
priv->name = str ? g_strdup (str) : NULL;
priv->name = g_strdup (str);
g_object_notify (G_OBJECT (self), NM_BLUEZ_DEVICE_NAME);
}
} else if (!strcmp (property, "RSSI")) {
......
......@@ -216,8 +216,7 @@ nm_act_request_set_specific_object (NMActRequest *req,
priv = NM_ACT_REQUEST_GET_PRIVATE (req);
if (priv->specific_object)
g_free (priv->specific_object);
g_free (priv->specific_object);
priv->specific_object = g_strdup (specific_object);
}
......
......@@ -192,8 +192,7 @@ set_property (GObject *object, guint prop_id,
switch (prop_id) {
case PROP_PARENT_IFACE:
if (priv->parent_iface)
g_free (priv->parent_iface);
g_free (priv->parent_iface);
priv->parent_iface = g_value_dup_string (value);
break;
default:
......
......@@ -501,7 +501,7 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname)
svCloseFile (network);
g_free (priv->hostname);
priv->hostname = hostname ? g_strdup (hostname) : NULL;
priv->hostname = g_strdup (hostname);
return TRUE;
}
......
......@@ -90,8 +90,8 @@ svOpenFile(const char *name, gboolean create)
bail:
if (s->fd != -1) close(s->fd);
if (s->arena) g_free (s->arena);
if (s->fileName) g_free (s->fileName);
g_free (s->arena);
g_free (s->fileName);
g_free (s);
return NULL;
}
......
......@@ -195,7 +195,7 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname)
}
g_free (priv->hostname);
priv->hostname = hostname ? g_strdup (hostname) : NULL;
priv->hostname = g_strdup (hostname);
}
static void
......
......@@ -470,8 +470,7 @@ eap_ttls_reader (const char *eap_method,
done:
if (list)
g_strfreev (list);
if (inner_auth)
g_free (inner_auth);
g_free (inner_auth);
return success;
}
......
......@@ -158,8 +158,7 @@ finalize (GObject * object)
NM_IFNET_CONNECTION_GET_PRIVATE (object);
g_return_if_fail (priv);
if (priv->conn_name)
g_free (priv->conn_name);
g_free (priv->conn_name);
G_OBJECT_CLASS (nm_ifnet_connection_parent_class)->finalize (object);
}
......
......@@ -90,8 +90,7 @@ update_system_hostname (gpointer config)
PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Updating hostname");
if (priv->hostname)
g_free (priv->hostname);
g_free (priv->hostname);
priv->hostname = read_hostname (IFNET_SYSTEM_HOSTNAME_FILE);
g_object_notify (G_OBJECT (config),
......@@ -110,8 +109,7 @@ write_system_hostname (NMSystemConfigInterface * config,
PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Write system hostname: %s",
newhostname);
if (write_hostname (newhostname, IFNET_SYSTEM_HOSTNAME_FILE)) {
if (priv->hostname)
g_free (priv->hostname);
g_free (priv->hostname);
priv->hostname = g_strdup (newhostname);
g_object_notify (G_OBJECT (config),
NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME);
......@@ -512,8 +510,7 @@ dispose (GObject * object)
g_hash_table_destroy (priv->config_connections);
}
if (priv->hostname)
g_free (priv->hostname);
g_free (priv->hostname);
ifnet_destroy ();
wpa_parser_destroy ();
G_OBJECT_CLASS (sc_plugin_ifnet_parent_class)->dispose (object);
......
......@@ -600,9 +600,7 @@ update_system_hostname(NMInotifyHelper *inotify_helper,
return;
}
if (priv->hostname)
g_free(priv->hostname);
g_free(priv->hostname);
priv->hostname = g_strstrip(hostname_file);
/* We shouldn't return a zero-length hostname, but NULL */
......
......@@ -493,7 +493,7 @@ plugin_set_hostname (SCPluginKeyfile *plugin, const char *hostname)
g_free (data);
g_free (priv->hostname);
priv->hostname = hostname ? g_strdup (hostname) : NULL;
priv->hostname = g_strdup (hostname);
result = TRUE;
}
......
......@@ -474,8 +474,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
val = (GValue *) g_hash_table_lookup (config_hash, NM_VPN_PLUGIN_IP4_CONFIG_BANNER);
if (val) {
if (priv->banner)
g_free (priv->banner);
g_free (priv->banner);
priv->banner = g_strdup (g_value_get_string (val));
}
......@@ -954,15 +953,11 @@ vpn_cleanup (NMVPNConnection *connection)
priv->gw_route = NULL;
}
if (priv->banner) {
g_free (priv->banner);
priv->banner = NULL;
}
g_free (priv->banner);
priv->banner = NULL;
if (priv->ip_iface) {
g_free (priv->ip_iface);
priv->ip_iface = NULL;
}
g_free (priv->ip_iface);
priv->ip_iface = NULL;
/* Clear out connection secrets to ensure that the settings service
* gets asked for them next time the connection is activated.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment