diff options
-rw-r--r-- | clients/cli/connections.c | 28 | ||||
-rw-r--r-- | clients/cli/devices.c | 45 | ||||
-rw-r--r-- | clients/tui/nmt-connect-connection-list.c | 14 | ||||
-rw-r--r-- | clients/tui/nmt-device-entry.c | 6 | ||||
-rw-r--r-- | examples/C/glib/get-ap-info-libnm.c | 4 | ||||
-rw-r--r-- | libnm/nm-active-connection.c | 2 | ||||
-rw-r--r-- | libnm/nm-client.c | 6 | ||||
-rw-r--r-- | libnm/nm-device-bond.c | 2 | ||||
-rw-r--r-- | libnm/nm-device-bridge.c | 2 | ||||
-rw-r--r-- | libnm/nm-device-team.c | 2 | ||||
-rw-r--r-- | libnm/nm-device-wifi.c | 2 | ||||
-rw-r--r-- | libnm/nm-device-wimax.c | 2 | ||||
-rw-r--r-- | libnm/nm-device.c | 2 | ||||
-rw-r--r-- | libnm/nm-object-private.h | 9 | ||||
-rw-r--r-- | libnm/tests/test-nm-client.c | 6 |
15 files changed, 55 insertions, 77 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 74279bec1c..e3a8e182a8 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -585,7 +585,7 @@ get_ac_device_string (NMActiveConnection *active) /* Get devices of the active connection */ dev_str = g_string_new (NULL); devices = nm_active_connection_get_devices (active); - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *device = g_ptr_array_index (devices, i); const char *dev_iface = nm_device_get_iface (device); @@ -609,7 +609,7 @@ get_ac_for_connection (const GPtrArray *active_cons, NMConnection *connection) /* Is the connection active? */ con_path = nm_connection_get_path (connection); - for (i = 0; active_cons && i < active_cons->len; i++) { + for (i = 0; i < active_cons->len; i++) { NMActiveConnection *candidate = g_ptr_array_index (active_cons, i); if (!g_strcmp0 (nm_active_connection_get_connection (candidate), con_path)) { @@ -719,7 +719,7 @@ find_active_connection (const GPtrArray *active_cons, NMConnection *con; NMActiveConnection *found = NULL; - for (i = start; active_cons && (i < active_cons->len); i++) { + for (i = start; i < active_cons->len; i++) { NMActiveConnection *candidate = g_ptr_array_index (active_cons, i); path = nm_active_connection_get_connection (candidate); @@ -840,7 +840,7 @@ fill_output_active_connection (NMActiveConnection *active, /* Get devices of the active connection */ dev_str = g_string_new (NULL); devices = nm_active_connection_get_devices (active); - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *device = g_ptr_array_index (devices, i); const char *dev_iface = nm_device_get_iface (device); @@ -1445,12 +1445,12 @@ get_default_active_connection (NmCli *nmc, NMDevice **device) g_return_val_if_fail (*device == NULL, NULL); connections = nm_client_get_active_connections (nmc->client); - for (i = 0; connections && (i < connections->len); i++) { + for (i = 0; i < connections->len; i++) { NMActiveConnection *candidate = g_ptr_array_index (connections, i); const GPtrArray *devices; devices = nm_active_connection_get_devices (candidate); - if (!devices || !devices->len) + if (!devices->len) continue; if (nm_active_connection_get_default (candidate)) { @@ -1536,7 +1536,7 @@ find_device_for_connection (NmCli *nmc, NMDevice *found_device = NULL; const GPtrArray *devices = nm_client_get_devices (nmc->client); - for (i = 0; devices && (i < devices->len) && !found_device; i++) { + for (i = 0; i < devices->len && !found_device; i++) { NMDevice *dev = g_ptr_array_index (devices, i); if (iface) { @@ -1556,7 +1556,7 @@ find_device_for_connection (NmCli *nmc, const GPtrArray *aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (dev)); found_device = NULL; /* Mark as not found; set to the device again later, only if AP matches */ - for (j = 0; aps && (j < aps->len); j++) { + for (j = 0; j < aps->len; j++) { NMAccessPoint *candidate_ap = g_ptr_array_index (aps, j); const char *candidate_bssid = nm_access_point_get_bssid (candidate_ap); @@ -1577,7 +1577,7 @@ find_device_for_connection (NmCli *nmc, const GPtrArray *nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (dev)); found_device = NULL; /* Mark as not found; set to the device again later, only if NSP matches */ - for (j = 0; nsps && (j < nsps->len); j++) { + for (j = 0; j < nsps->len; j++) { NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j); const char *candidate_name = nm_wimax_nsp_get_name (candidate_nsp); @@ -1699,7 +1699,7 @@ active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpoin NMDevice *device; devices = nm_active_connection_get_devices (active); - device = devices && devices->len ? g_ptr_array_index (devices, 0) : NULL; + device = devices->len ? g_ptr_array_index (devices, 0) : NULL; if ( device && ( NM_IS_DEVICE_BOND (device) || NM_IS_DEVICE_TEAM (device) @@ -1820,7 +1820,7 @@ activate_connection_cb (NMClient *client, NMActiveConnection *active, GError *er if (!device) { /* device could be NULL for virtual devices. Fill it here. */ ac_devs = nm_active_connection_get_devices (active); - info->device = device = ac_devs && ac_devs->len > 0 ? g_ptr_array_index (ac_devs, 0) : NULL; + info->device = device = ac_devs->len > 0 ? g_ptr_array_index (ac_devs, 0) : NULL; } if (nmc->nowait_flag || state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) { @@ -5487,7 +5487,7 @@ gen_compat_devices (const char *text, int state) char *ret; devices = nm_client_get_devices (nmc_tab_completion.nmc->client); - if (!devices || devices->len < 1) + if (devices->len == 0) return NULL; compatible_devices = g_new (const char *, devices->len + 1); @@ -6402,7 +6402,7 @@ activate_connection_editor_cb (NMClient *client, if (!error) { if (!device) { ac_devs = nm_active_connection_get_devices (active); - device = ac_devs && ac_devs->len > 0 ? g_ptr_array_index (ac_devs, 0) : NULL; + device = ac_devs->len > 0 ? g_ptr_array_index (ac_devs, 0) : NULL; } if (device) { monitor_ac_info = g_malloc0 (sizeof (AddConnectionInfo)); @@ -7608,7 +7608,7 @@ get_ethernet_device_name (NmCli *nmc) nmc->get_client (nmc); devices = nm_client_get_devices (nmc->client); - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *dev = g_ptr_array_index (devices, i); if (NM_IS_DEVICE_ETHERNET (dev)) return nm_device_get_iface (dev); diff --git a/clients/cli/devices.c b/clients/cli/devices.c index da7fa178f2..705838de4d 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -420,11 +420,6 @@ get_devices_sorted (NMClient *client) NMDevice **sorted; devs = nm_client_get_devices (client); - if (!devs) { - sorted = g_new (NMDevice *, 1); - sorted[0] = NULL; - return sorted; - } sorted = g_new (NMDevice *, devs->len + 1); memcpy (sorted, devs->pdata, devs->len * sizeof (NMDevice *)); @@ -680,7 +675,7 @@ get_active_connection_id (NMDevice *device) ac_uuid = nm_active_connection_get_uuid (ac); avail_cons = nm_device_get_available_connections (device); - for (i = 0; avail_cons && (i < avail_cons->len); i++) { + for (i = 0; i < avail_cons->len; i++) { NMRemoteConnection *candidate = g_ptr_array_index (avail_cons, i); const char *test_uuid = nm_connection_get_uuid (NM_CONNECTION (candidate)); @@ -886,8 +881,7 @@ show_device_info (NMDevice *device, NmCli *nmc) info->active_bssid = active_bssid; info->device = nm_device_get_iface (device); aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device)); - if (aps && aps->len) - g_ptr_array_foreach ((GPtrArray *) aps, fill_output_access_point, (gpointer) info); + g_ptr_array_foreach ((GPtrArray *) aps, fill_output_access_point, (gpointer) info); g_free (info); print_data (nmc); /* Print all data */ was_output = TRUE; @@ -974,7 +968,7 @@ show_device_info (NMDevice *device, NmCli *nmc) g_ptr_array_add (nmc->output_data, arr); nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device)); - for (g = 0; nsps && g < nsps->len; g++) { + for (g = 0; g < nsps->len; g++) { NMWimaxNsp *nsp = g_ptr_array_index (nsps, g); fill_output_wimax_nsp (nsp, nmc, device, idx++, NMC_OF_FLAG_SECTION_PREFIX); @@ -1016,7 +1010,7 @@ show_device_info (NMDevice *device, NmCli *nmc) bond_slaves_str = g_string_new (NULL); slaves = nm_device_bond_get_slaves (NM_DEVICE_BOND (device)); - for (idx = 0; slaves && idx < slaves->len; idx++) { + for (idx = 0; idx < slaves->len; idx++) { NMDevice *slave = g_ptr_array_index (slaves, idx); const char *iface = nm_device_get_iface (slave); @@ -1087,11 +1081,11 @@ show_device_info (NMDevice *device, NmCli *nmc) /* available-connections */ avail_cons = nm_device_get_available_connections (device); ac_paths_str = g_string_new (NULL); - if (avail_cons && avail_cons->len) { + if (avail_cons->len) { ac_arr = g_new (char *, avail_cons->len + 1); ac_arr[avail_cons->len] = NULL; } - for (i = 0; avail_cons && (i < avail_cons->len); i++) { + for (i = 0; i < avail_cons->len; i++) { NMRemoteConnection *avail_con = g_ptr_array_index (avail_cons, i); const char *ac_path = nm_connection_get_path (NM_CONNECTION (avail_con)); const char *ac_id = nm_connection_get_id (NM_CONNECTION (avail_con)); @@ -1335,7 +1329,7 @@ connect_device_cb (NMClient *client, NMActiveConnection *active, GError *error, } else { g_assert (active); devices = nm_active_connection_get_devices (active); - if (!devices || devices->len == 0) { + if (devices->len == 0) { g_string_printf (nmc->return_text, _("Error: Device activation failed: device was disconnected")); nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION; quit (); @@ -1699,8 +1693,7 @@ show_access_point_info (NMDevice *device, NmCli *nmc) info->active_bssid = active_bssid; info->device = nm_device_get_iface (device); aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device)); - if (aps && aps->len) - g_ptr_array_foreach ((GPtrArray *) aps, fill_output_access_point, (gpointer) info); + g_ptr_array_foreach ((GPtrArray *) aps, fill_output_access_point, (gpointer) info); print_data (nmc); /* Print all data */ nmc_empty_output_fields (nmc); @@ -1804,7 +1797,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv) if (bssid_user) { /* Specific AP requested - list only that */ aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device)); - for (j = 0; aps && (j < aps->len); j++) { + for (j = 0; j < aps->len; j++) { char *bssid_up; NMAccessPoint *candidate_ap = g_ptr_array_index (aps, j); const char *candidate_bssid = nm_access_point_get_bssid (candidate_ap); @@ -1863,7 +1856,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv) g_ptr_array_add (nmc->output_data, arr); aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (dev)); - for (j = 0; aps && (j < aps->len); j++) { + for (j = 0; j < aps->len; j++) { char *bssid_up; NMAccessPoint *candidate_ap = g_ptr_array_index (aps, j); const char *candidate_bssid = nm_access_point_get_bssid (candidate_ap); @@ -2010,7 +2003,7 @@ find_wifi_device_by_iface (const GPtrArray *devices, const char *iface, int *idx NMDevice *device = NULL; int i; - for (i = *idx; devices && (i < devices->len); i++) { + for (i = *idx; i < devices->len; i++) { NMDevice *candidate = g_ptr_array_index (devices, i); const char *dev_iface = nm_device_get_iface (candidate); @@ -2049,7 +2042,7 @@ find_ap_on_device (NMDevice *device, GByteArray *bssid, const char *ssid) g_return_val_if_fail ((bssid && !ssid) || (!bssid && ssid), NULL); aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device)); - for (i = 0; aps && (i < aps->len); i++) { + for (i = 0; i < aps->len; i++) { NMAccessPoint *candidate_ap = g_ptr_array_index (aps, i); if (ssid) { @@ -2457,7 +2450,7 @@ show_nsp_info (NMDevice *device, NmCli *nmc) g_ptr_array_add (nmc->output_data, arr); nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device)); - for (i = 0; nsps && i < nsps->len; i++) { + for (i = 0; i < nsps->len; i++) { NMWimaxNsp *nsp = g_ptr_array_index (nsps, i); fill_output_wimax_nsp (nsp, nmc, device, idx++, 0); @@ -2539,7 +2532,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv) devices = nm_client_get_devices (nmc->client); if (ifname) { /* Device specified - list only NSPs of this interface */ - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *candidate = g_ptr_array_index (devices, i); const char *dev_iface = nm_device_get_iface (candidate); @@ -2562,7 +2555,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv) if (nsp_user) { /* Specific NSP requested - list only that */ nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device)); - for (j = 0, nsp = NULL; nsps && (j < nsps->len); j++) { + for (j = 0, nsp = NULL; j < nsps->len; j++) { NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j); const char *candidate_name = nm_wimax_nsp_get_name (candidate_nsp); char *nsp_up; @@ -2596,7 +2589,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv) /* List NSPs for all devices */ if (nsp_user) { /* Specific NSP requested - list only that */ - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *dev = g_ptr_array_index (devices, i); int idx = 1; @@ -2611,7 +2604,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv) g_ptr_array_add (nmc->output_data, arr); nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (dev)); - for (j = 0, nsp = NULL; nsps && (j < nsps->len); j++) { + for (j = 0, nsp = NULL; j < nsps->len; j++) { NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j); const char *candidate_name = nm_wimax_nsp_get_name (candidate_nsp); char *nsp_up; @@ -2635,7 +2628,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv) goto error; } } else { - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *dev = g_ptr_array_index (devices, i); /* Main header name */ @@ -2704,7 +2697,7 @@ gen_func_ifnames (const char *text, int state) nm_cli.get_client (&nm_cli); devices = nm_client_get_devices (nm_cli.client); - if (!devices || devices->len < 1) + if (devices->len == 0) return NULL; ifnames = g_new (const char *, devices->len + 1); diff --git a/clients/tui/nmt-connect-connection-list.c b/clients/tui/nmt-connect-connection-list.c index 2f98fb7ef1..f3b02e99a7 100644 --- a/clients/tui/nmt-connect-connection-list.c +++ b/clients/tui/nmt-connect-connection-list.c @@ -272,7 +272,7 @@ add_connections_for_aps (NmtConnectDevice *nmtdev, int i; aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (nmtdev->device)); - if (!aps) + if (!aps->len) return; seen_ssids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); @@ -450,7 +450,7 @@ connection_find_ac (NMConnection *conn, int i; path = nm_connection_get_path (conn); - for (i = 0; acs && i < acs->len; i++) { + for (i = 0; i < acs->len; i++) { ac = acs->pdata[i]; ac_path = nm_active_connection_get_connection (ac); @@ -484,11 +484,11 @@ nmt_connect_connection_list_rebuild (NmtConnectConnectionList *list) connections = nm_remote_settings_list_connections (nm_settings); nmt_devices = NULL; - if (devices) { - names = nm_device_disambiguate_names ((NMDevice **) devices->pdata, devices->len); - nmt_devices = append_nmt_devices_for_devices (nmt_devices, devices, names, connections); - g_strfreev (names); - } + + names = nm_device_disambiguate_names ((NMDevice **) devices->pdata, devices->len); + nmt_devices = append_nmt_devices_for_devices (nmt_devices, devices, names, connections); + g_strfreev (names); + nmt_devices = append_nmt_devices_for_virtual_devices (nmt_devices, connections); nmt_devices = append_nmt_devices_for_vpns (nmt_devices, connections); diff --git a/clients/tui/nmt-device-entry.c b/clients/tui/nmt-device-entry.c index b8db86869f..184ed96ffc 100644 --- a/clients/tui/nmt-device-entry.c +++ b/clients/tui/nmt-device-entry.c @@ -187,9 +187,6 @@ find_device_by_interface_name (NmtDeviceEntry *deventry, int i; devices = nm_client_get_devices (nm_client); - if (!devices) - return NULL; - for (i = 0; i < devices->len && !device; i++) { NMDevice *candidate = devices->pdata[i]; @@ -218,9 +215,6 @@ find_device_by_mac_address (NmtDeviceEntry *deventry, int i; devices = nm_client_get_devices (nm_client); - if (!devices) - return NULL; - for (i = 0; i < devices->len && !device; i++) { NMDevice *candidate = devices->pdata[i]; char *hwaddr; diff --git a/examples/C/glib/get-ap-info-libnm.c b/examples/C/glib/get-ap-info-libnm.c index c5e9b5b238..044cec9c04 100644 --- a/examples/C/glib/get-ap-info-libnm.c +++ b/examples/C/glib/get-ap-info-libnm.c @@ -182,7 +182,7 @@ show_wifi_device_info (NMDevice *device) aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device)); /* Print AP details */ - for (i = 0; aps && (i < aps->len); i++) { + for (i = 0; i < aps->len; i++) { NMAccessPoint *ap = g_ptr_array_index (aps, i); show_access_point_info (ap); } @@ -212,7 +212,7 @@ int main (int argc, char *argv[]) devices = nm_client_get_devices (client); /* Go through the array and process Wi-Fi devices */ - for (i = 0; devices && (i < devices->len); i++) { + for (i = 0; i < devices->len; i++) { NMDevice *device = g_ptr_array_index (devices, i); if (NM_IS_DEVICE_WIFI (device)) show_wifi_device_info (device); diff --git a/libnm/nm-active-connection.c b/libnm/nm-active-connection.c index 659b820d82..7088e496a4 100644 --- a/libnm/nm-active-connection.c +++ b/libnm/nm-active-connection.c @@ -284,7 +284,7 @@ nm_active_connection_get_devices (NMActiveConnection *connection) { g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (connection), NULL); - return handle_ptr_array_return (NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->devices); + return NM_ACTIVE_CONNECTION_GET_PRIVATE (connection)->devices; } /** diff --git a/libnm/nm-client.c b/libnm/nm-client.c index fdbaed38b7..70c9c813ab 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -380,7 +380,7 @@ nm_client_get_devices (NMClient *client) { g_return_val_if_fail (NM_IS_CLIENT (client), NULL); - return handle_ptr_array_return (NM_CLIENT_GET_PRIVATE (client)->devices); + return NM_CLIENT_GET_PRIVATE (client)->devices; } /** @@ -522,7 +522,7 @@ recheck_pending_activations (NMClient *self, const char *failed_path, GError *er ainfo = info; } - for (i = 0; active_connections && i < active_connections->len; i++) { + for (i = 0; i < active_connections->len; i++) { NMActiveConnection *active = g_ptr_array_index (active_connections, i); const char *active_path = nm_object_get_path (NM_OBJECT (active)); @@ -803,7 +803,7 @@ nm_client_get_active_connections (NMClient *client) if (!nm_client_get_nm_running (client)) return NULL; - return handle_ptr_array_return (priv->active_connections); + return priv->active_connections; } /** diff --git a/libnm/nm-device-bond.c b/libnm/nm-device-bond.c index d0a3e94a82..e378c9cc31 100644 --- a/libnm/nm-device-bond.c +++ b/libnm/nm-device-bond.c @@ -118,7 +118,7 @@ nm_device_bond_get_slaves (NMDeviceBond *device) { g_return_val_if_fail (NM_IS_DEVICE_BOND (device), FALSE); - return handle_ptr_array_return (NM_DEVICE_BOND_GET_PRIVATE (device)->slaves); + return NM_DEVICE_BOND_GET_PRIVATE (device)->slaves; } static gboolean diff --git a/libnm/nm-device-bridge.c b/libnm/nm-device-bridge.c index 1a17196656..cb9cb2ad46 100644 --- a/libnm/nm-device-bridge.c +++ b/libnm/nm-device-bridge.c @@ -118,7 +118,7 @@ nm_device_bridge_get_slaves (NMDeviceBridge *device) { g_return_val_if_fail (NM_IS_DEVICE_BRIDGE (device), FALSE); - return handle_ptr_array_return (NM_DEVICE_BRIDGE_GET_PRIVATE (device)->slaves); + return NM_DEVICE_BRIDGE_GET_PRIVATE (device)->slaves; } static gboolean diff --git a/libnm/nm-device-team.c b/libnm/nm-device-team.c index 0aeda17039..27deda8a5a 100644 --- a/libnm/nm-device-team.c +++ b/libnm/nm-device-team.c @@ -118,7 +118,7 @@ nm_device_team_get_slaves (NMDeviceTeam *device) { g_return_val_if_fail (NM_IS_DEVICE_TEAM (device), FALSE); - return handle_ptr_array_return (NM_DEVICE_TEAM_GET_PRIVATE (device)->slaves); + return NM_DEVICE_TEAM_GET_PRIVATE (device)->slaves; } static const char * diff --git a/libnm/nm-device-wifi.c b/libnm/nm-device-wifi.c index 6a41ccc218..7252672f2d 100644 --- a/libnm/nm-device-wifi.c +++ b/libnm/nm-device-wifi.c @@ -247,7 +247,7 @@ nm_device_wifi_get_access_points (NMDeviceWifi *device) { g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); - return handle_ptr_array_return (NM_DEVICE_WIFI_GET_PRIVATE (device)->aps); + return NM_DEVICE_WIFI_GET_PRIVATE (device)->aps; } /** diff --git a/libnm/nm-device-wimax.c b/libnm/nm-device-wimax.c index 5f190ea3f0..fc5793acb2 100644 --- a/libnm/nm-device-wimax.c +++ b/libnm/nm-device-wimax.c @@ -161,7 +161,7 @@ nm_device_wimax_get_nsps (NMDeviceWimax *wimax) { g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL); - return handle_ptr_array_return (NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->nsps); + return NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->nsps; } /** diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 3e67f09472..1eff7386d6 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -1364,7 +1364,7 @@ nm_device_get_available_connections (NMDevice *device) { g_return_val_if_fail (NM_IS_DEVICE (device), NULL); - return handle_ptr_array_return (NM_DEVICE_GET_PRIVATE (device)->available_connections); + return NM_DEVICE_GET_PRIVATE (device)->available_connections; } static char * diff --git a/libnm/nm-object-private.h b/libnm/nm-object-private.h index 4422883f8d..78764c8611 100644 --- a/libnm/nm-object-private.h +++ b/libnm/nm-object-private.h @@ -70,15 +70,6 @@ void _nm_object_set_property (NMObject *object, const char *prop_name, GValue *value); -static inline const GPtrArray * -handle_ptr_array_return (GPtrArray *array) -{ - /* zero-length is special-case; return NULL */ - if (!array || !array->len) - return NULL; - return array; -} - /* object demarshalling support */ typedef GType (*NMObjectTypeFunc) (DBusGConnection *, const char *); typedef void (*NMObjectTypeCallbackFunc) (GType, gpointer); diff --git a/libnm/tests/test-nm-client.c b/libnm/tests/test-nm-client.c index 5f0bcbffbf..5bf11e4aa7 100644 --- a/libnm/tests/test-nm-client.c +++ b/libnm/tests/test-nm-client.c @@ -156,7 +156,7 @@ test_device_added (void) client = test_client_new (); devices = nm_client_get_devices (client); - g_assert (devices == NULL); + g_assert (devices->len == 0); /* Tell the test service to add a new device */ add_device ("AddWiredDevice", "eth0", NULL); @@ -293,7 +293,7 @@ wifi_ap_remove_notify_cb (NMDeviceWifi *w, const GPtrArray *aps; aps = nm_device_wifi_get_access_points (w); - g_assert (aps == NULL); + g_assert (aps->len == 0); info->notified = TRUE; wifi_check_quit (info); @@ -516,7 +516,7 @@ wimax_nsp_remove_notify_cb (NMDeviceWimax *w, const GPtrArray *nsps; nsps = nm_device_wimax_get_nsps (w); - g_assert (nsps == NULL); + g_assert (nsps->len == 0); info->notified = TRUE; wimax_check_quit (info); |