summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-12-01 16:16:51 +0100
committerThomas Haller <thaller@redhat.com>2022-12-09 09:15:53 +0100
commit977c1e76a85abdbf93372ac07c9e3663e2390b7f (patch)
treeda43f387c461a092c6e270807d65d7ab19e4bc3f
parentcfc6e63403ae0d22d14ba8b5c9e9d934d7dcc70b (diff)
downloadNetworkManager-977c1e76a85abdbf93372ac07c9e3663e2390b7f.tar.gz
all: use nm_g_array_first()/nm_g_array_first_p() where suitable
-rw-r--r--src/core/dns/nm-dns-systemd-resolved.c2
-rw-r--r--src/core/ndisc/nm-ndisc.c10
-rw-r--r--src/core/nm-manager.c2
-rw-r--r--src/core/nm-policy.c2
-rw-r--r--src/core/platform/tests/test-address.c4
-rw-r--r--src/core/platform/tests/test-cleanup.c2
-rw-r--r--src/core/tests/test-core-with-expect.c4
-rw-r--r--src/libnm-core-impl/tests/test-setting.c2
-rw-r--r--src/nmcli/connections.c2
-rw-r--r--src/nmcli/utils.c4
10 files changed, 16 insertions, 18 deletions
diff --git a/src/core/dns/nm-dns-systemd-resolved.c b/src/core/dns/nm-dns-systemd-resolved.c
index 6bdc8460a8..24c7c77453 100644
--- a/src/core/dns/nm-dns-systemd-resolved.c
+++ b/src/core/dns/nm-dns-systemd-resolved.c
@@ -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);
diff --git a/src/core/ndisc/nm-ndisc.c b/src/core/ndisc/nm-ndisc.c
index 5c1520e140..a2d06e49be 100644
--- a/src/core/ndisc/nm-ndisc.c
+++ b/src/core/ndisc/nm-ndisc.c
@@ -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))
diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c
index c71e649c15..8eeca2709d 100644
--- a/src/core/nm-manager.c
+++ b/src/core/nm-manager.c
@@ -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,
diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c
index f6b4be5158..3cd11ba810 100644
--- a/src/core/nm-policy.c
+++ b/src/core/nm-policy.c
@@ -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);
diff --git a/src/core/platform/tests/test-address.c b/src/core/platform/tests/test-address.c
index cdee042860..8e5ad13b43 100644
--- a/src/core/platform/tests/test-address.c
+++ b/src/core/platform/tests/test-address.c
@@ -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);
diff --git a/src/core/platform/tests/test-cleanup.c b/src/core/platform/tests/test-cleanup.c
index 62d7e4b93c..139a028001 100644
--- a/src/core/platform/tests/test-cleanup.c
+++ b/src/core/platform/tests/test-cleanup.c
@@ -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;
});
diff --git a/src/core/tests/test-core-with-expect.c b/src/core/tests/test-core-with-expect.c
index 4e6ee9e4c3..b05144ac21 100644
--- a/src/core/tests/test-core-with-expect.c
+++ b/src/core/tests/test-core-with-expect.c
@@ -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 */
diff --git a/src/libnm-core-impl/tests/test-setting.c b/src/libnm-core-impl/tests/test-setting.c
index 40cdd47929..b57c23888f 100644
--- a/src/libnm-core-impl/tests/test-setting.c
+++ b/src/libnm-core-impl/tests/test-setting.c
@@ -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;
diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c
index e5fbb3e490..c0b7d8f1dc 100644
--- a/src/nmcli/connections.c
+++ b/src/nmcli/connections.c
@@ -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};
diff --git a/src/nmcli/utils.c b/src/nmcli/utils.c
index ebe234706a..8eb9fa950a 100644
--- a/src/nmcli/utils.c
+++ b/src/nmcli/utils.c
@@ -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;
}