1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-26 14:04:03 +03:00

udev/net: use structured initializer at one more place

This commit is contained in:
Yu Watanabe 2019-02-25 11:53:57 +09:00
parent 79a60834e2
commit 6cdab9f17f

View File

@ -119,6 +119,7 @@ int link_config_ctx_new(link_config_ctx **ret) {
static int load_link(link_config_ctx *ctx, const char *filename) {
_cleanup_(link_config_freep) link_config *link = NULL;
_cleanup_fclose_ FILE *file = NULL;
_cleanup_free_ char *name = NULL;
size_t i;
int r;
@ -134,15 +135,22 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
return 0;
}
link = new0(link_config, 1);
name = strdup(filename);
if (!name)
return -ENOMEM;
link = new(link_config, 1);
if (!link)
return -ENOMEM;
link->mac_policy = _MACPOLICY_INVALID;
link->wol = _WOL_INVALID;
link->duplex = _DUP_INVALID;
link->port = _NET_DEV_PORT_INVALID;
link->autonegotiation = -1;
*link = (link_config) {
.filename = TAKE_PTR(name),
.mac_policy = _MACPOLICY_INVALID,
.wol = _WOL_INVALID,
.duplex = _DUP_INVALID,
.port = _NET_DEV_PORT_INVALID,
.autonegotiation = -1,
};
for (i = 0; i < ELEMENTSOF(link->features); i++)
link->features[i] = -1;
@ -153,15 +161,11 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
CONFIG_PARSE_WARN, link);
if (r < 0)
return r;
else
log_debug("Parsed configuration file %s", filename);
if (link->speed > UINT_MAX)
return -ERANGE;
link->filename = strdup(filename);
if (!link->filename)
return -ENOMEM;
log_debug("Parsed configuration file %s", filename);
LIST_PREPEND(links, ctx->links, link);
link = NULL;