security_association_init(&c->sa);
- r = ordered_hashmap_ensure_allocated(&s->receive_associations_by_section, &network_config_hash_ops);
- if (r < 0)
- return r;
-
- r = ordered_hashmap_put(s->receive_associations_by_section, c->section, c);
+ r = ordered_hashmap_ensure_put(&s->receive_associations_by_section, &network_config_hash_ops, c->section, c);
if (r < 0)
return r;
c->section = TAKE_PTR(n);
- r = ordered_hashmap_ensure_allocated(&s->receive_channels_by_section, &network_config_hash_ops);
- if (r < 0)
- return r;
-
- r = ordered_hashmap_put(s->receive_channels_by_section, c->section, c);
+ r = ordered_hashmap_ensure_put(&s->receive_channels_by_section, &network_config_hash_ops, c->section, c);
if (r < 0)
return r;
security_association_init(&a->sa);
- r = ordered_hashmap_ensure_allocated(&s->transmit_associations_by_section, &network_config_hash_ops);
- if (r < 0)
- return r;
-
- r = ordered_hashmap_put(s->transmit_associations_by_section, a->section, a);
+ r = ordered_hashmap_ensure_put(&s->transmit_associations_by_section, &network_config_hash_ops, a->section, a);
if (r < 0)
return r;
"Ignoring [MACsecReceiveChannel] section from line %u",
c->section->filename, c->section->line);
- r = ordered_hashmap_ensure_allocated(&c->macsec->receive_channels, &uint64_hash_ops);
- if (r < 0)
+ r = ordered_hashmap_ensure_put(&c->macsec->receive_channels, &uint64_hash_ops, &c->sci.as_uint64, c);
+ if (r == -ENOMEM)
return log_oom();
-
- r = ordered_hashmap_put(c->macsec->receive_channels, &c->sci.as_uint64, c);
if (r == -EEXIST)
return log_netdev_error_errno(netdev, r,
"%s: Multiple [MACsecReceiveChannel] sections have same SCI, "
if (r < 0)
return log_oom();
- r = ordered_hashmap_ensure_allocated(&a->macsec->receive_channels, &uint64_hash_ops);
- if (r < 0)
+ r = ordered_hashmap_ensure_put(&a->macsec->receive_channels, &uint64_hash_ops, &new_channel->sci.as_uint64, new_channel);
+ if (r == -ENOMEM)
return log_oom();
-
- r = ordered_hashmap_put(a->macsec->receive_channels, &new_channel->sci.as_uint64, new_channel);
if (r < 0)
return log_netdev_error_errno(netdev, r,
"%s: Failed to store receive channel at hashmap, "