all: use nm_g_array_first()/nm_g_array_first_p() where suitable
This commit is contained in:
@@ -1061,7 +1061,7 @@ _resolve_handle_call_cb(GObject *source, GAsyncResult *result, gpointer user_dat
|
||||
g_variant_iter_free(v_names_iter);
|
||||
|
||||
_resolve_complete(handle,
|
||||
nm_g_array_index_p(v_names, NMDnsSystemdResolvedAddressResult, 0),
|
||||
nm_g_array_first_p(v_names, NMDnsSystemdResolvedAddressResult),
|
||||
v_names->len,
|
||||
v_flags,
|
||||
NULL);
|
||||
|
@@ -1385,7 +1385,7 @@ clean_gateways(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap *changed, gint6
|
||||
if (rdata->gateways->len == 0)
|
||||
return;
|
||||
|
||||
arr = &nm_g_array_index(rdata->gateways, NMNDiscGateway, 0);
|
||||
arr = &nm_g_array_first(rdata->gateways, NMNDiscGateway);
|
||||
|
||||
for (i = 0, j = 0; i < rdata->gateways->len; i++) {
|
||||
if (!expiry_next(now_msec, arr[i].expiry_msec, next_msec))
|
||||
@@ -1418,7 +1418,7 @@ clean_addresses(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap *changed, gint
|
||||
if (rdata->addresses->len == 0)
|
||||
return;
|
||||
|
||||
arr = &nm_g_array_index(rdata->addresses, NMNDiscAddress, 0);
|
||||
arr = &nm_g_array_first(rdata->addresses, NMNDiscAddress);
|
||||
|
||||
for (i = 0, j = 0; i < rdata->addresses->len; i++) {
|
||||
if (!expiry_next(now_msec, arr[i].expiry_msec, next_msec))
|
||||
@@ -1448,7 +1448,7 @@ clean_routes(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap *changed, gint64
|
||||
if (rdata->routes->len == 0)
|
||||
return;
|
||||
|
||||
arr = &nm_g_array_index(rdata->routes, NMNDiscRoute, 0);
|
||||
arr = &nm_g_array_first(rdata->routes, NMNDiscRoute);
|
||||
|
||||
for (i = 0, j = 0; i < rdata->routes->len; i++) {
|
||||
if (!expiry_next(now_msec, arr[i].expiry_msec, next_msec))
|
||||
@@ -1478,7 +1478,7 @@ clean_dns_servers(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap *changed, gi
|
||||
if (rdata->dns_servers->len == 0)
|
||||
return;
|
||||
|
||||
arr = &nm_g_array_index(rdata->dns_servers, NMNDiscDNSServer, 0);
|
||||
arr = &nm_g_array_first(rdata->dns_servers, NMNDiscDNSServer);
|
||||
|
||||
for (i = 0, j = 0; i < rdata->dns_servers->len; i++) {
|
||||
if (!expiry_next(now_msec, arr[i].expiry_msec, next_msec))
|
||||
@@ -1508,7 +1508,7 @@ clean_dns_domains(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap *changed, gi
|
||||
if (rdata->dns_domains->len == 0)
|
||||
return;
|
||||
|
||||
arr = &nm_g_array_index(rdata->dns_domains, NMNDiscDNSDomain, 0);
|
||||
arr = &nm_g_array_first(rdata->dns_domains, NMNDiscDNSDomain);
|
||||
|
||||
for (i = 0, j = 0; i < rdata->dns_domains->len; i++) {
|
||||
if (!expiry_next(now_msec, arr[i].expiry_msec, next_msec))
|
||||
|
@@ -7905,7 +7905,7 @@ nm_manager_set_capability(NMManager *self, NMCapability cap)
|
||||
|
||||
priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
|
||||
idx = nm_array_find_bsearch(nm_g_array_index_p(priv->capabilities, guint32, 0),
|
||||
idx = nm_array_find_bsearch(nm_g_array_first_p(priv->capabilities, guint32),
|
||||
priv->capabilities->len,
|
||||
sizeof(guint32),
|
||||
&cap_i,
|
||||
|
@@ -773,7 +773,7 @@ build_device_hostname_infos(NMPolicy *self)
|
||||
|
||||
g_array_sort(array, device_hostname_info_compare);
|
||||
|
||||
info0 = &nm_g_array_index(array, DeviceHostnameInfo, 0);
|
||||
info0 = &nm_g_array_first(array, DeviceHostnameInfo);
|
||||
if (info0->priority < 0) {
|
||||
for (i = 1; i < array->len; i++) {
|
||||
const DeviceHostnameInfo *info = &nm_g_array_index(array, DeviceHostnameInfo, i);
|
||||
|
@@ -118,7 +118,7 @@ test_ip4_address_general(void)
|
||||
addresses = nmtstp_platform_ip4_address_get_all(NM_PLATFORM_GET, ifindex);
|
||||
g_assert(addresses);
|
||||
g_assert_cmpint(addresses->len, ==, 1);
|
||||
address = &nm_g_array_index(addresses, NMPlatformIP4Address, 0);
|
||||
address = &nm_g_array_first(addresses, NMPlatformIP4Address);
|
||||
g_assert_cmpint(address->ifindex, ==, ifindex);
|
||||
g_assert_cmphex(address->address, ==, addr);
|
||||
g_assert_cmphex(address->peer_address, ==, addr);
|
||||
@@ -193,7 +193,7 @@ test_ip6_address_general(void)
|
||||
addresses = nmtstp_platform_ip6_address_get_all(NM_PLATFORM_GET, ifindex);
|
||||
g_assert(addresses);
|
||||
g_assert_cmpint(addresses->len, ==, 1);
|
||||
address = &nm_g_array_index(addresses, NMPlatformIP6Address, 0);
|
||||
address = &nm_g_array_first(addresses, NMPlatformIP6Address);
|
||||
g_assert_cmpint(address->ifindex, ==, ifindex);
|
||||
g_assert(!memcmp(&address->address, &addr, sizeof(addr)));
|
||||
g_assert_cmpint(address->plen, ==, IP6_PLEN);
|
||||
|
@@ -63,7 +63,7 @@ test_cleanup_internal(void)
|
||||
nm_platform_process_events(NM_PLATFORM_GET);
|
||||
}
|
||||
addrs = nmtstp_platform_ip6_address_get_all(NM_PLATFORM_GET, ifindex);
|
||||
if (addrs->len == 1 && (a = &nm_g_array_index(addrs, NMPlatformIP6Address, 0))
|
||||
if (addrs->len == 1 && (a = &nm_g_array_first(addrs, NMPlatformIP6Address))
|
||||
&& IN6_IS_ADDR_LINKLOCAL(&a->address))
|
||||
break;
|
||||
});
|
||||
|
@@ -530,9 +530,7 @@ test_nm_utils_array_remove_at_indexes(void)
|
||||
for (i = 0; i < i_len; i++)
|
||||
nm_g_array_index(array, gssize, i) = i;
|
||||
|
||||
nm_utils_array_remove_at_indexes(array,
|
||||
nm_g_array_index_p(idx, guint, 0),
|
||||
i_idx_len);
|
||||
nm_utils_array_remove_at_indexes(array, nm_g_array_first_p(idx, guint), i_idx_len);
|
||||
|
||||
g_hash_table_remove_all(unique);
|
||||
/* ensure that all the indexes are still unique */
|
||||
|
@@ -4385,7 +4385,7 @@ _PROP_IDX_OWNER(GHashTable *h_property_types, const NMSettInfoPropertType *prope
|
||||
g_assert(arr);
|
||||
g_assert(arr->len > 0);
|
||||
|
||||
idx = nm_g_array_index(arr, guint, 0);
|
||||
idx = nm_g_array_first(arr, guint);
|
||||
|
||||
meta_type = (idx & 0xFFu);
|
||||
prop_idx = idx >> 8;
|
||||
|
@@ -1983,7 +1983,7 @@ con_show_get_items_cmp(gconstpointer pa, gconstpointer pb, gpointer user_data)
|
||||
nmc_print_output_to_accessor_get_type(sort_info->nmc->nmc_config.print_output);
|
||||
|
||||
if (sort_info->order) {
|
||||
order_arr = nm_g_array_index_p(sort_info->order, NmcSortOrder, 0);
|
||||
order_arr = nm_g_array_first_p(sort_info->order, NmcSortOrder);
|
||||
order_len = sort_info->order->len;
|
||||
} else {
|
||||
static const NmcSortOrder def[] = {NMC_SORT_ACTIVE, NMC_SORT_NAME, NMC_SORT_PATH};
|
||||
|
@@ -1410,8 +1410,8 @@ nmc_print(const NmcConfig *nmc_config,
|
||||
header_name_no_l10n,
|
||||
header_row->len,
|
||||
cells->len / header_row->len,
|
||||
nm_g_array_index_p(header_row, PrintDataHeaderCell, 0),
|
||||
nm_g_array_index_p(cells, PrintDataCell, 0));
|
||||
nm_g_array_first_p(header_row, PrintDataHeaderCell),
|
||||
nm_g_array_first_p(cells, PrintDataCell));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user