all: remove more pointless NULL checks

GObject creation cannot normally fail, except for types that implement
GInitable and take a GError in their _new() method. Some NM types
override constructor() and return NULL in some cases, but these
generally only happen in the case of programmer error (eg, failing to
set a mandatory property), and so crashing is reasonable (and most
likely inevitable anyway).

So, remove all NULL checks after calls to g_object_new() and its
myriad wrappers.

https://bugzilla.gnome.org/show_bug.cgi?id=693678
This commit is contained in:
Dan Winship 2013-01-31 15:36:12 -05:00
parent d04f286327
commit 08f04466e8
24 changed files with 68 additions and 748 deletions

View file

@ -67,14 +67,9 @@ make_tls_connection (const char *detail, NMSetting8021xCKScheme scheme)
GError *error = NULL;
connection = nm_connection_new ();
ASSERT (connection != NULL,
detail, "failed to allocate new connection");
/* Connection setting */
s_con = (NMSettingConnection *) nm_setting_connection_new ();
ASSERT (s_con != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_CONNECTION_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_con));
uuid = nm_utils_uuid_generate ();
@ -88,16 +83,10 @@ make_tls_connection (const char *detail, NMSetting8021xCKScheme scheme)
/* Wired setting */
s_wired = (NMSettingWired *) nm_setting_wired_new ();
ASSERT (s_wired != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_WIRED_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wired));
/* Wireless security setting */
s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
ASSERT (s_8021x != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_802_1X_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_8021x));
g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, "Bill Smith", NULL);
@ -134,9 +123,6 @@ make_tls_connection (const char *detail, NMSetting8021xCKScheme scheme)
/* IP4 setting */
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
ASSERT (s_ip4 != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
@ -247,14 +233,9 @@ make_tls_phase2_connection (const char *detail, NMSetting8021xCKScheme scheme)
GError *error = NULL;
connection = nm_connection_new ();
ASSERT (connection != NULL,
detail, "failed to allocate new connection");
/* Connection setting */
s_con = (NMSettingConnection *) nm_setting_connection_new ();
ASSERT (s_con != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_CONNECTION_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_con));
uuid = nm_utils_uuid_generate ();
@ -268,16 +249,10 @@ make_tls_phase2_connection (const char *detail, NMSetting8021xCKScheme scheme)
/* Wired setting */
s_wired = (NMSettingWired *) nm_setting_wired_new ();
ASSERT (s_wired != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_WIRED_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wired));
/* Wireless security setting */
s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
ASSERT (s_8021x != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_802_1X_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_8021x));
g_object_set (s_8021x, NM_SETTING_802_1X_ANONYMOUS_IDENTITY, "blahblah", NULL);
@ -316,9 +291,6 @@ make_tls_phase2_connection (const char *detail, NMSetting8021xCKScheme scheme)
/* IP4 setting */
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
ASSERT (s_ip4 != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);

View file

@ -112,8 +112,6 @@ nm_dnsmasq_manager_new (const char *iface)
NMDnsMasqManagerPrivate *priv;
manager = (NMDnsMasqManager *) g_object_new (NM_TYPE_DNSMASQ_MANAGER, NULL);
if (!manager)
return NULL;
priv = NM_DNSMASQ_MANAGER_GET_PRIVATE (manager);
priv->iface = g_strdup (iface);

View file

@ -1496,11 +1496,6 @@ nm_ip6_manager_get_ip6_config (NMIP6Manager *manager, int ifindex)
}
config = nm_ip6_config_new ();
if (!config) {
nm_log_err (LOGD_IP6, "(%s): out of memory creating IP6 config object.",
device->iface);
return NULL;
}
/* Make sure we refill the route and address caches, otherwise we won't get
* up-to-date information here since the netlink route/addr change messages

View file

@ -800,8 +800,6 @@ build_supplicant_config (NMDeviceEthernet *self)
con_uuid = nm_connection_get_uuid (connection);
config = nm_supplicant_config_new ();
if (!config)
return NULL;
security = nm_connection_get_setting_802_1x (connection);
if (!nm_supplicant_config_add_setting_8021x (config, security, con_uuid, TRUE)) {

View file

@ -110,32 +110,31 @@ nm_default_wired_connection_new (const GByteArray *mac,
g_return_val_if_fail (defname != NULL, NULL);
self = (NMDefaultWiredConnection *) g_object_new (NM_TYPE_DEFAULT_WIRED_CONNECTION, NULL);
if (self) {
priv = NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (self);
priv->device = g_object_ref (device);
priv->mac = g_byte_array_sized_new (ETH_ALEN);
g_byte_array_append (priv->mac, mac->data, mac->len);
setting = nm_setting_connection_new ();
priv = NM_DEFAULT_WIRED_CONNECTION_GET_PRIVATE (self);
priv->device = g_object_ref (device);
priv->mac = g_byte_array_sized_new (ETH_ALEN);
g_byte_array_append (priv->mac, mac->data, mac->len);
uuid = nm_utils_uuid_generate ();
g_object_set (setting,
NM_SETTING_CONNECTION_ID, defname,
NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
NM_SETTING_CONNECTION_UUID, uuid,
NM_SETTING_CONNECTION_READ_ONLY, read_only,
NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL),
NULL);
g_free (uuid);
setting = nm_setting_connection_new ();
nm_connection_add_setting (NM_CONNECTION (self), setting);
uuid = nm_utils_uuid_generate ();
g_object_set (setting,
NM_SETTING_CONNECTION_ID, defname,
NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
NM_SETTING_CONNECTION_UUID, uuid,
NM_SETTING_CONNECTION_READ_ONLY, read_only,
NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL),
NULL);
g_free (uuid);
/* Lock the connection to the specific device */
setting = nm_setting_wired_new ();
g_object_set (setting, NM_SETTING_WIRED_MAC_ADDRESS, priv->mac, NULL);
nm_connection_add_setting (NM_CONNECTION (self), setting);
}
nm_connection_add_setting (NM_CONNECTION (self), setting);
/* Lock the connection to the specific device */
setting = nm_setting_wired_new ();
g_object_set (setting, NM_SETTING_WIRED_MAC_ADDRESS, priv->mac, NULL);
nm_connection_add_setting (NM_CONNECTION (self), setting);
return self;
}

View file

@ -133,13 +133,6 @@ init_inotify (NMInotifyHelper *self)
/* Watch the inotify descriptor for file/directory change events */
channel = g_io_channel_unix_new (priv->ifd);
if (!channel) {
nm_log_warn (LOGD_SETTINGS, "couldn't create new GIOChannel");
close (priv->ifd);
priv->ifd = -1;
return FALSE;
}
g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
g_io_channel_set_encoding (channel, NULL, NULL);
@ -158,11 +151,9 @@ nm_inotify_helper_get (void)
if (!singleton) {
singleton = (NMInotifyHelper *) g_object_new (NM_TYPE_INOTIFY_HELPER, NULL);
if (!singleton)
return NULL;
if (!init_inotify (singleton)) {
g_object_unref (singleton);
g_clear_object (&singleton);
return NULL;
}
} else

View file

@ -445,26 +445,24 @@ nm_secret_agent_new (NMDBusManager *dbus_mgr,
username = g_strdup (pw->pw_name);
self = (NMSecretAgent *) g_object_new (NM_TYPE_SECRET_AGENT, NULL);
if (self) {
priv = NM_SECRET_AGENT_GET_PRIVATE (self);
priv = NM_SECRET_AGENT_GET_PRIVATE (self);
priv->owner = g_strdup (owner);
priv->identifier = g_strdup (identifier);
priv->owner_uid = owner_uid;
priv->owner_username = g_strdup (username);
priv->owner = g_strdup (owner);
priv->identifier = g_strdup (identifier);
priv->owner_uid = owner_uid;
priv->owner_username = g_strdup (username);
hash_str = g_strdup_printf ("%08u%s", owner_uid, identifier);
priv->hash = g_str_hash (hash_str);
g_free (hash_str);
hash_str = g_strdup_printf ("%08u%s", owner_uid, identifier);
priv->hash = g_str_hash (hash_str);
g_free (hash_str);
priv->dbus_mgr = g_object_ref (dbus_mgr);
bus = nm_dbus_manager_get_connection (priv->dbus_mgr);
priv->proxy = dbus_g_proxy_new_for_name (bus,
owner,
NM_DBUS_PATH_SECRET_AGENT,
NM_DBUS_INTERFACE_SECRET_AGENT);
g_assert (priv->proxy);
}
priv->dbus_mgr = g_object_ref (dbus_mgr);
bus = nm_dbus_manager_get_connection (priv->dbus_mgr);
priv->proxy = dbus_g_proxy_new_for_name (bus,
owner,
NM_DBUS_PATH_SECRET_AGENT,
NM_DBUS_INTERFACE_SECRET_AGENT);
g_assert (priv->proxy);
g_free (username);
return self;

View file

@ -1752,8 +1752,6 @@ nm_settings_new (const char *config_file,
NMSettingsPrivate *priv;
self = g_object_new (NM_TYPE_SETTINGS, NULL);
if (!self)
return NULL;
priv = NM_SETTINGS_GET_PRIVATE (self);

View file

@ -71,9 +71,6 @@ nm_example_connection_new (const char *full_path,
/* Actually create the new NMExampleConnection object */
object = (GObject *) g_object_new (NM_TYPE_EXAMPLE_CONNECTION, NULL);
if (!object)
goto out;
priv = NM_EXAMPLE_CONNECTION_GET_PRIVATE (object);
priv->path = g_strdup (full_path);

View file

@ -852,12 +852,10 @@ nm_system_config_factory (const char *config_file)
if (!singleton) {
/* Instantiate our plugin */
singleton = SC_PLUGIN_EXAMPLE (g_object_new (SC_TYPE_PLUGIN_EXAMPLE, NULL));
if (singleton) {
priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (singleton);
priv = SC_PLUGIN_EXAMPLE_GET_PRIVATE (singleton);
/* Cache the config file path */
priv->conf_file = g_strdup (config_file);
}
/* Cache the config file path */
priv->conf_file = g_strdup (config_file);
} else {
/* This function should never be called twice */
g_assert_not_reached ();

View file

@ -859,14 +859,12 @@ nm_system_config_factory (const char *config_file)
if (!singleton) {
singleton = SC_PLUGIN_IFCFG (g_object_new (SC_TYPE_PLUGIN_IFCFG, NULL));
if (singleton) {
priv = SC_PLUGIN_IFCFG_GET_PRIVATE (singleton);
if (priv->bus)
dbus_g_connection_register_g_object (priv->bus,
DBUS_OBJECT_PATH,
G_OBJECT (singleton));
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "Acquired D-Bus service %s", DBUS_SERVICE_NAME);
}
priv = SC_PLUGIN_IFCFG_GET_PRIVATE (singleton);
if (priv->bus)
dbus_g_connection_register_g_object (priv->bus,
DBUS_OBJECT_PATH,
G_OBJECT (singleton));
PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "Acquired D-Bus service %s", DBUS_SERVICE_NAME);
} else
g_object_ref (singleton);

View file

@ -1195,11 +1195,6 @@ make_ip4_setting (shvarFile *ifcfg,
gboolean never_default = FALSE, tmp_success;
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
if (!s_ip4) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not allocate IP4 setting");
return NULL;
}
/* First check if DEFROUTE is set for this device; DEFROUTE has the
* opposite meaning from never-default. The default if DEFROUTE is not
@ -1496,11 +1491,6 @@ make_ip6_setting (shvarFile *ifcfg,
NMSettingIP6ConfigPrivacy ip6_privacy_val;
s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
if (!s_ip6) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Could not allocate IP6 setting");
return NULL;
}
/* First check if IPV6_DEFROUTE is set for this device; IPV6_DEFROUTE has the
* opposite meaning from never-default. The default if IPV6_DEFROUTE is not
@ -3198,11 +3188,6 @@ wireless_connection_from_ifcfg (const char *file,
g_return_val_if_fail (*error == NULL, NULL);
connection = nm_connection_new ();
if (!connection) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Failed to allocate new connection for %s.", file);
return NULL;
}
/* Wireless */
wireless_setting = make_wireless_setting (ifcfg, nm_controlled, unmanaged, error);
@ -3476,11 +3461,6 @@ wired_connection_from_ifcfg (const char *file,
g_return_val_if_fail (ifcfg != NULL, NULL);
connection = nm_connection_new ();
if (!connection) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Failed to allocate new connection for %s.", file);
return NULL;
}
con_setting = make_connection_setting (file, ifcfg, NM_SETTING_WIRED_SETTING_NAME, NULL, NULL);
if (!con_setting) {
@ -3584,11 +3564,6 @@ infiniband_connection_from_ifcfg (const char *file,
g_return_val_if_fail (ifcfg != NULL, NULL);
connection = nm_connection_new ();
if (!connection) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Failed to allocate new connection for %s.", file);
return NULL;
}
con_setting = make_connection_setting (file, ifcfg, NM_SETTING_INFINIBAND_SETTING_NAME, NULL, NULL);
if (!con_setting) {
@ -3693,11 +3668,6 @@ bond_connection_from_ifcfg (const char *file,
g_return_val_if_fail (ifcfg != NULL, NULL);
connection = nm_connection_new ();
if (!connection) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Failed to allocate new connection for %s.", file);
return NULL;
}
con_setting = make_connection_setting (file, ifcfg, NM_SETTING_BOND_SETTING_NAME, NULL, _("Bond"));
if (!con_setting) {
@ -3878,11 +3848,6 @@ bridge_connection_from_ifcfg (const char *file,
g_return_val_if_fail (ifcfg != NULL, NULL);
connection = nm_connection_new ();
if (!connection) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Failed to allocate new connection for %s.", file);
return NULL;
}
con_setting = make_connection_setting (file, ifcfg, NM_SETTING_BRIDGE_SETTING_NAME, NULL, _("Bridge"));
if (!con_setting) {
@ -4143,11 +4108,6 @@ vlan_connection_from_ifcfg (const char *file,
g_return_val_if_fail (ifcfg != NULL, NULL);
connection = nm_connection_new ();
if (!connection) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Failed to allocate new connection for %s.", file);
return NULL;
}
con_setting = make_connection_setting (file, ifcfg, NM_SETTING_VLAN_SETTING_NAME, NULL, "Vlan");
if (!con_setting) {

File diff suppressed because it is too large Load diff

View file

@ -782,11 +782,6 @@ make_ip6_setting (NMConnection *connection,
gboolean never_default = !has_default_ip6_route (conn_name);
s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
if (!s_ip6) {
g_set_error (error, ifnet_plugin_error_quark (), 0,
"Could not allocate IP6 setting");
return;
}
value = ifnet_get_data (conn_name, "enable_ipv6");
if (value && is_true (value))
@ -1671,8 +1666,6 @@ ifnet_update_connection_from_config_block (const char *conn_name,
gboolean success = FALSE;
connection = nm_connection_new ();
if (!connection)
return NULL;
setting = nm_connection_get_setting_connection (connection);
if (!setting) {
setting = NM_SETTING_CONNECTION (nm_setting_connection_new ());

View file

@ -76,11 +76,6 @@ nm_ifnet_connection_new (const char *conn_name, NMConnection *source)
}
object = (GObject *) g_object_new (NM_TYPE_IFNET_CONNECTION, NULL);
if (!object) {
g_object_unref (tmp);
return NULL;
}
NM_IFNET_CONNECTION_GET_PRIVATE (object)->conn_name = g_strdup (conn_name);
nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), tmp, NULL);
g_object_unref (tmp);

View file

@ -590,10 +590,8 @@ nm_system_config_factory (const char *config_file)
if (!singleton) {
singleton = SC_PLUGIN_IFNET (g_object_new (SC_TYPE_PLUGIN_IFNET, NULL));
if (singleton) {
priv = SC_PLUGIN_IFNET_GET_PRIVATE (singleton);
priv->conf_file = strdup (config_file);
}
priv = SC_PLUGIN_IFNET_GET_PRIVATE (singleton);
priv->conf_file = strdup (config_file);
} else
g_object_ref (singleton);

View file

@ -712,10 +712,8 @@ nm_system_config_factory (const char *config_file)
if (!singleton) {
singleton = SC_PLUGIN_IFUPDOWN (g_object_new (SC_TYPE_PLUGIN_IFUPDOWN, NULL));
if (singleton) {
priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (singleton);
priv->conf_file = strdup (config_file);
}
priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (singleton);
priv->conf_file = strdup (config_file);
} else
g_object_ref (singleton);

View file

@ -62,8 +62,6 @@ nm_keyfile_connection_new (const char *full_path,
}
object = (GObject *) g_object_new (NM_TYPE_KEYFILE_CONNECTION, NULL);
if (!object)
goto out;
priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (object);
priv->path = g_strdup (full_path);

View file

@ -656,14 +656,12 @@ nm_settings_keyfile_plugin_new (const char *config_file)
if (!singleton) {
singleton = SC_PLUGIN_KEYFILE (g_object_new (SC_TYPE_PLUGIN_KEYFILE, NULL));
if (singleton) {
priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (singleton);
priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (singleton);
priv->conf_file = g_strdup (config_file);
priv->conf_file = g_strdup (config_file);
/* plugin_set_hostname() has to be called *after* priv->conf_file is set */
priv->hostname = plugin_get_hostname (singleton);
}
/* plugin_set_hostname() has to be called *after* priv->conf_file is set */
priv->hostname = plugin_get_hostname (singleton);
} else
g_object_ref (singleton);

View file

@ -506,15 +506,10 @@ test_write_wired_connection (void)
guint64 timestamp = 0x12345678L;
connection = nm_connection_new ();
ASSERT (connection != NULL,
"connection-write", "failed to allocate new connection");
/* Connection setting */
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
ASSERT (s_con != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_CONNECTION_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_con));
uuid = nm_utils_uuid_generate ();
@ -530,9 +525,6 @@ test_write_wired_connection (void)
/* Wired setting */
s_wired = NM_SETTING_WIRED (nm_setting_wired_new ());
ASSERT (s_wired != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_WIRED_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wired));
mac = g_byte_array_sized_new (ETH_ALEN);
@ -546,9 +538,6 @@ test_write_wired_connection (void)
/* IP4 setting */
s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
ASSERT (s_ip4 != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
g_object_set (s_ip4,
@ -572,9 +561,6 @@ test_write_wired_connection (void)
/* IP6 setting */
s_ip6 = NM_SETTING_IP6_CONFIG (nm_setting_ip6_config_new ());
ASSERT (s_ip6 != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_IP6_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip6));
g_object_set (s_ip6,
@ -754,15 +740,10 @@ test_write_ip6_wired_connection (void)
const char *gw = "dcba::beef";
connection = nm_connection_new ();
ASSERT (connection != NULL,
"connection-write", "failed to allocate new connection");
/* Connection setting */
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
ASSERT (s_con != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_CONNECTION_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_con));
uuid = nm_utils_uuid_generate ();
@ -777,17 +758,11 @@ test_write_ip6_wired_connection (void)
/* Wired setting */
s_wired = NM_SETTING_WIRED (nm_setting_wired_new ());
ASSERT (s_wired != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_WIRED_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wired));
/* IP4 setting */
s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
ASSERT (s_ip4 != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
g_object_set (s_ip4,
@ -797,9 +772,6 @@ test_write_ip6_wired_connection (void)
/* IP6 setting */
s_ip6 = NM_SETTING_IP6_CONFIG (nm_setting_ip6_config_new ());
ASSERT (s_ip6 != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_IP6_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip6));
g_object_set (s_ip6,
@ -1066,15 +1038,10 @@ test_write_wireless_connection (void)
guint64 timestamp = 0x12344433L;
connection = nm_connection_new ();
ASSERT (connection != NULL,
"connection-write", "failed to allocate new connection");
/* Connection setting */
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
ASSERT (s_con != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_CONNECTION_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_con));
uuid = nm_utils_uuid_generate ();
@ -1090,9 +1057,6 @@ test_write_wireless_connection (void)
/* Wireless setting */
s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
ASSERT (s_wireless != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_WIRELESS_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wireless));
bssid = g_byte_array_sized_new (ETH_ALEN);
@ -1113,9 +1077,6 @@ test_write_wireless_connection (void)
/* IP4 setting */
s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
ASSERT (s_ip4 != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
g_object_set (s_ip4,
@ -1125,9 +1086,6 @@ test_write_wireless_connection (void)
/* IP6 setting */
s_ip6 = NM_SETTING_IP6_CONFIG (nm_setting_ip6_config_new ());
ASSERT (s_ip6 != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_IP6_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip6));
g_object_set (s_ip6,
@ -1220,15 +1178,10 @@ test_write_string_ssid (void)
GKeyFile *keyfile;
connection = nm_connection_new ();
ASSERT (connection != NULL,
"connection-write", "failed to allocate new connection");
/* Connection setting */
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
ASSERT (s_con != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_CONNECTION_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_con));
uuid = nm_utils_uuid_generate ();
@ -1242,9 +1195,6 @@ test_write_string_ssid (void)
/* Wireless setting */
s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
ASSERT (s_wireless != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_WIRELESS_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wireless));
ssid = g_byte_array_sized_new (sizeof (tmpssid));
@ -1255,9 +1205,6 @@ test_write_string_ssid (void)
/* IP4 setting */
s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
ASSERT (s_ip4 != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
g_object_set (s_ip4,
@ -1846,15 +1793,10 @@ test_write_bt_dun_connection (void)
guint64 timestamp = 0x12344433L;
connection = nm_connection_new ();
ASSERT (connection != NULL,
"connection-write", "failed to allocate new connection");
/* Connection setting */
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
ASSERT (s_con != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_CONNECTION_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_con));
uuid = nm_utils_uuid_generate ();
@ -1870,9 +1812,6 @@ test_write_bt_dun_connection (void)
/* Bluetooth setting */
s_bt = NM_SETTING_BLUETOOTH (nm_setting_bluetooth_new ());
ASSERT (s_bt != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_BLUETOOTH_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_bt));
bdaddr = g_byte_array_sized_new (ETH_ALEN);
@ -1888,9 +1827,6 @@ test_write_bt_dun_connection (void)
/* IP4 setting */
s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
ASSERT (s_ip4 != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
g_object_set (s_ip4,
@ -1899,9 +1835,6 @@ test_write_bt_dun_connection (void)
/* GSM setting */
s_gsm = NM_SETTING_GSM (nm_setting_gsm_new ());
ASSERT (s_gsm != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_GSM_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_gsm));
g_object_set (s_gsm,
@ -2106,15 +2039,10 @@ test_write_gsm_connection (void)
guint64 timestamp = 0x12344433L;
connection = nm_connection_new ();
ASSERT (connection != NULL,
"connection-write", "failed to allocate new connection");
/* Connection setting */
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
ASSERT (s_con != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_CONNECTION_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_con));
uuid = nm_utils_uuid_generate ();
@ -2130,9 +2058,6 @@ test_write_gsm_connection (void)
/* IP4 setting */
s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
ASSERT (s_ip4 != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
g_object_set (s_ip4,
@ -2141,9 +2066,6 @@ test_write_gsm_connection (void)
/* GSM setting */
s_gsm = NM_SETTING_GSM (nm_setting_gsm_new ());
ASSERT (s_gsm != NULL,
"connection-write", "failed to allocate new %s setting",
NM_SETTING_GSM_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_gsm));
g_object_set (s_gsm,

View file

@ -1493,24 +1493,22 @@ nm_supplicant_interface_new (NMSupplicantManager *smgr,
g_return_val_if_fail (ifname != NULL, NULL);
self = g_object_new (NM_TYPE_SUPPLICANT_INTERFACE, NULL);
if (self) {
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
priv->smgr = g_object_ref (smgr);
id = g_signal_connect (priv->smgr,
"notify::" NM_SUPPLICANT_MANAGER_AVAILABLE,
G_CALLBACK (smgr_avail_cb),
self);
priv->smgr_avail_id = id;
priv->smgr = g_object_ref (smgr);
id = g_signal_connect (priv->smgr,
"notify::" NM_SUPPLICANT_MANAGER_AVAILABLE,
G_CALLBACK (smgr_avail_cb),
self);
priv->smgr_avail_id = id;
priv->dev = g_strdup (ifname);
priv->is_wireless = is_wireless;
priv->fast_supported = fast_supported;
priv->ap_support = ap_support;
priv->dev = g_strdup (ifname);
priv->is_wireless = is_wireless;
priv->fast_supported = fast_supported;
priv->ap_support = ap_support;
if (start_now)
interface_add (self, priv->is_wireless);
}
if (start_now)
interface_add (self, priv->is_wireless);
return self;
}

View file

@ -128,14 +128,9 @@ test_wifi_open (void)
const char *bssid_str = "11:22:33:44:55:66";
connection = nm_connection_new ();
ASSERT (connection != NULL,
"wifi-open", "failed to allocate new connection");
/* Connection setting */
s_con = (NMSettingConnection *) nm_setting_connection_new ();
ASSERT (s_con != NULL,
"wifi-open", "failed to allocate new %s setting",
NM_SETTING_CONNECTION_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_con));
uuid = nm_utils_uuid_generate ();
@ -149,9 +144,6 @@ test_wifi_open (void)
/* Wifi setting */
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
ASSERT (s_wifi != NULL,
"wifi-open", "failed to allocate new %s setting",
NM_SETTING_WIRELESS_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
ssid = g_byte_array_sized_new (sizeof (ssid_data));
@ -171,9 +163,6 @@ test_wifi_open (void)
/* IP4 setting */
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
ASSERT (s_ip4 != NULL,
"wifi-open", "failed to allocate new %s setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
@ -183,8 +172,6 @@ test_wifi_open (void)
(error && error->message) ? error->message : "(unknown)");
config = nm_supplicant_config_new ();
ASSERT (config != NULL,
"wifi-open", "failed to create new supplicant config");
success = nm_supplicant_config_add_setting_wireless (config, s_wifi, TRUE, 0, TRUE);
ASSERT (success == TRUE,
@ -230,14 +217,9 @@ test_wifi_wep_key (const char *detail,
const char *bssid_str = "11:22:33:44:55:66";
connection = nm_connection_new ();
ASSERT (connection != NULL,
detail, "failed to allocate new connection");
/* Connection setting */
s_con = (NMSettingConnection *) nm_setting_connection_new ();
ASSERT (s_con != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_CONNECTION_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_con));
uuid = nm_utils_uuid_generate ();
@ -251,9 +233,6 @@ test_wifi_wep_key (const char *detail,
/* Wifi setting */
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
ASSERT (s_wifi != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_WIRELESS_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
ssid = g_byte_array_sized_new (sizeof (ssid_data));
@ -274,9 +253,6 @@ test_wifi_wep_key (const char *detail,
/* Wifi Security setting */
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
ASSERT (s_wsec != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wsec));
g_object_set (s_wsec,
@ -287,9 +263,6 @@ test_wifi_wep_key (const char *detail,
/* IP4 setting */
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
ASSERT (s_ip4 != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
@ -299,8 +272,6 @@ test_wifi_wep_key (const char *detail,
(error && error->message) ? error->message : "(unknown)");
config = nm_supplicant_config_new ();
ASSERT (config != NULL,
detail, "failed to create new supplicant config");
success = nm_supplicant_config_add_setting_wireless (config, s_wifi, TRUE, 0, TRUE);
ASSERT (success == TRUE,
@ -374,14 +345,9 @@ test_wifi_wpa_psk (const char *detail,
const char *bssid_str = "11:22:33:44:55:66";
connection = nm_connection_new ();
ASSERT (connection != NULL,
detail, "failed to allocate new connection");
/* Connection setting */
s_con = (NMSettingConnection *) nm_setting_connection_new ();
ASSERT (s_con != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_CONNECTION_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_con));
uuid = nm_utils_uuid_generate ();
@ -395,9 +361,6 @@ test_wifi_wpa_psk (const char *detail,
/* Wifi setting */
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
ASSERT (s_wifi != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_WIRELESS_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
ssid = g_byte_array_sized_new (sizeof (ssid_data));
@ -418,9 +381,6 @@ test_wifi_wpa_psk (const char *detail,
/* Wifi Security setting */
s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
ASSERT (s_wsec != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_wsec));
g_object_set (s_wsec,
@ -437,9 +397,6 @@ test_wifi_wpa_psk (const char *detail,
/* IP4 setting */
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
ASSERT (s_ip4 != NULL,
detail, "failed to allocate new %s setting",
NM_SETTING_IP4_CONFIG_SETTING_NAME);
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
@ -449,8 +406,6 @@ test_wifi_wpa_psk (const char *detail,
(error && error->message) ? error->message : "(unknown)");
config = nm_supplicant_config_new ();
ASSERT (config != NULL,
detail, "failed to create new supplicant config");
success = nm_supplicant_config_add_setting_wireless (config, s_wifi, TRUE, 0, TRUE);
ASSERT (success == TRUE,

View file

@ -91,11 +91,6 @@ nm_vpn_service_new (const char *namefile, GError **error)
}
self = (NMVPNService *) g_object_new (NM_TYPE_VPN_SERVICE, NULL);
if (!self) {
g_set_error (error, 0, 0, "out of memory creating VPN service object");
goto out;
}
NM_VPN_SERVICE_GET_PRIVATE (self)->name = g_strdup (name);
NM_VPN_SERVICE_GET_PRIVATE (self)->dbus_service = g_strdup (dbus_service);
NM_VPN_SERVICE_GET_PRIVATE (self)->program = g_strdup (program);

View file

@ -30,18 +30,13 @@ nm_device_factory_create_device (GUdevDevice *device,
const char *driver,
GError **error)
{
GObject *dev;
/* FIXME: check 'DEVTYPE' instead; but since we only support Intel
* WiMAX devices for now this is appropriate.
*/
if (g_strcmp0 (driver, "i2400m_usb") != 0)
return NULL; /* unsupported */
dev = (GObject *) nm_device_wimax_new (devpath, ifname, driver);
if (dev == NULL)
g_set_error_literal (error, 0, 0, "Failed to create WiMAX device.");
return dev;
return (GObject *) nm_device_wimax_new (devpath, ifname, driver);
}
G_MODULE_EXPORT guint32