mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 22:48:01 +02:00
all: use nm_g_array_append_new() at various places
This commit is contained in:
parent
ef8fa9f6aa
commit
2c8dcbeaf9
6 changed files with 14 additions and 20 deletions
|
|
@ -331,9 +331,8 @@ device_ip6_prefix_delegated(NMDevice *device,
|
||||||
|
|
||||||
if (i == priv->ip6_prefix_delegations->len) {
|
if (i == priv->ip6_prefix_delegations->len) {
|
||||||
/* Allocate a delegation for new prefix. */
|
/* Allocate a delegation for new prefix. */
|
||||||
g_array_set_size(priv->ip6_prefix_delegations, i + 1);
|
delegation = nm_g_array_append_new(priv->ip6_prefix_delegations, IP6PrefixDelegation);
|
||||||
delegation = &g_array_index(priv->ip6_prefix_delegations, IP6PrefixDelegation, i);
|
delegation->subnets = g_hash_table_new(nm_direct_hash, NULL);
|
||||||
delegation->subnets = g_hash_table_new(nm_direct_hash, NULL);
|
|
||||||
delegation->next_subnet = 0;
|
delegation->next_subnet = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -234,8 +234,7 @@ link_add_pre(NMPlatform *platform,
|
||||||
|
|
||||||
g_assert(!name || strlen(name) < IFNAMSIZ);
|
g_assert(!name || strlen(name) < IFNAMSIZ);
|
||||||
|
|
||||||
g_array_set_size(priv->links, priv->links->len + 1);
|
device = nm_g_array_append_new(priv->links, NMFakePlatformLink);
|
||||||
device = &g_array_index(priv->links, NMFakePlatformLink, priv->links->len - 1);
|
|
||||||
ifindex = priv->links->len;
|
ifindex = priv->links->len;
|
||||||
|
|
||||||
memset(device, 0, sizeof(*device));
|
memset(device, 0, sizeof(*device));
|
||||||
|
|
|
||||||
|
|
@ -360,8 +360,7 @@ _nm_setting_class_commit(NMSettingClass *setting_class,
|
||||||
name))
|
name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
g_array_set_size(properties_override, properties_override->len + 1);
|
p = nm_g_array_append_new(properties_override, NMSettInfoProperty);
|
||||||
p = &g_array_index(properties_override, NMSettInfoProperty, properties_override->len - 1);
|
|
||||||
memset(p, 0, sizeof(*p));
|
memset(p, 0, sizeof(*p));
|
||||||
p->name = name;
|
p->name = name;
|
||||||
p->param_spec = property_specs[i];
|
p->param_spec = property_specs[i];
|
||||||
|
|
|
||||||
|
|
@ -4247,13 +4247,13 @@ _nm_utils_generate_mac_address_mask_parse(const char *value,
|
||||||
ouis = g_array_sized_new(FALSE, FALSE, sizeof(struct ether_addr), 4);
|
ouis = g_array_sized_new(FALSE, FALSE, sizeof(struct ether_addr), 4);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
struct ether_addr *new;
|
||||||
|
|
||||||
s = s_next;
|
s = s_next;
|
||||||
s_next = _split_word(s);
|
s_next = _split_word(s);
|
||||||
|
|
||||||
g_array_set_size(ouis, ouis->len + 1);
|
new = nm_g_array_append_new(ouis, struct ether_addr);
|
||||||
if (!nm_utils_hwaddr_aton(s,
|
if (!nm_utils_hwaddr_aton(s, new, ETH_ALEN)) {
|
||||||
&g_array_index(ouis, struct ether_addr, ouis->len - 1),
|
|
||||||
ETH_ALEN)) {
|
|
||||||
g_set_error(error,
|
g_set_error(error,
|
||||||
NM_UTILS_ERROR,
|
NM_UTILS_ERROR,
|
||||||
NM_UTILS_ERROR_UNKNOWN,
|
NM_UTILS_ERROR_UNKNOWN,
|
||||||
|
|
|
||||||
|
|
@ -2541,16 +2541,15 @@ _wireguard_update_from_peers_nla(CList *peers, GArray **p_allowed_ips, struct nl
|
||||||
GArray *allowed_ips = *p_allowed_ips;
|
GArray *allowed_ips = *p_allowed_ips;
|
||||||
|
|
||||||
nla_for_each_nested (attr, tb[WGPEER_A_ALLOWEDIPS], rem) {
|
nla_for_each_nested (attr, tb[WGPEER_A_ALLOWEDIPS], rem) {
|
||||||
|
NMPWireGuardAllowedIP *new;
|
||||||
|
|
||||||
if (!allowed_ips) {
|
if (!allowed_ips) {
|
||||||
allowed_ips = g_array_new(FALSE, FALSE, sizeof(NMPWireGuardAllowedIP));
|
allowed_ips = g_array_new(FALSE, FALSE, sizeof(NMPWireGuardAllowedIP));
|
||||||
*p_allowed_ips = allowed_ips;
|
*p_allowed_ips = allowed_ips;
|
||||||
g_array_set_size(allowed_ips, 1);
|
}
|
||||||
} else
|
|
||||||
g_array_set_size(allowed_ips, allowed_ips->len + 1);
|
|
||||||
|
|
||||||
if (!_wireguard_update_from_allowed_ips_nla(
|
new = nm_g_array_append_new(allowed_ips, NMPWireGuardAllowedIP);
|
||||||
&g_array_index(allowed_ips, NMPWireGuardAllowedIP, allowed_ips->len - 1),
|
if (!_wireguard_update_from_allowed_ips_nla(new, attr)) {
|
||||||
attr)) {
|
|
||||||
/* we ignore the error of parsing one allowed-ip. */
|
/* we ignore the error of parsing one allowed-ip. */
|
||||||
g_array_set_size(allowed_ips, allowed_ips->len - 1);
|
g_array_set_size(allowed_ips, allowed_ips->len - 1);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -262,9 +262,7 @@ _stack_push(GArray *netns_stack, NMPNetns *netns, int ns_types)
|
||||||
nm_assert(NM_FLAGS_ANY(ns_types, _CLONE_NS_ALL));
|
nm_assert(NM_FLAGS_ANY(ns_types, _CLONE_NS_ALL));
|
||||||
nm_assert(!NM_FLAGS_ANY(ns_types, ~_CLONE_NS_ALL));
|
nm_assert(!NM_FLAGS_ANY(ns_types, ~_CLONE_NS_ALL));
|
||||||
|
|
||||||
g_array_set_size(netns_stack, netns_stack->len + 1);
|
info = nm_g_array_append_new(netns_stack, NetnsInfo);
|
||||||
|
|
||||||
info = &g_array_index(netns_stack, NetnsInfo, (netns_stack->len - 1));
|
|
||||||
*info = (NetnsInfo){
|
*info = (NetnsInfo){
|
||||||
.netns = g_object_ref(netns),
|
.netns = g_object_ref(netns),
|
||||||
.ns_types = ns_types,
|
.ns_types = ns_types,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue