network: use structured initializers

This commit is contained in:
Yu Watanabe
2018-11-12 16:32:10 +09:00
parent 1a75764a32
commit 17f9c355d5
7 changed files with 111 additions and 104 deletions
+11 -7
View File
@@ -356,12 +356,14 @@ static int netdev_enslave(NetDev *netdev, Link *link, sd_netlink_message_handler
/* the netdev is not yet read, save this request for when it is */
netdev_join_callback *cb;
cb = new0(netdev_join_callback, 1);
cb = new(netdev_join_callback, 1);
if (!cb)
return log_oom();
cb->callback = callback;
cb->link = link_ref(link);
*cb = (netdev_join_callback) {
.callback = callback,
.link = link_ref(link),
};
LIST_PREPEND(callbacks, netdev->callbacks, cb);
@@ -651,13 +653,15 @@ int netdev_load_one(Manager *manager, const char *filename) {
return 0;
}
netdev_raw = new0(NetDev, 1);
netdev_raw = new(NetDev, 1);
if (!netdev_raw)
return log_oom();
netdev_raw->n_ref = 1;
netdev_raw->kind = _NETDEV_KIND_INVALID;
netdev_raw->state = _NETDEV_STATE_INVALID; /* an invalid state means done() of the implementation won't be called on destruction */
*netdev_raw = (NetDev) {
.n_ref = 1,
.kind = _NETDEV_KIND_INVALID,
.state = _NETDEV_STATE_INVALID, /* an invalid state means done() of the implementation won't be called on destruction */
};
dropin_dirname = strjoina(basename(filename), ".d");
r = config_parse_many(filename, network_dirs, dropin_dirname,