diff options
author | Tom Gundersen <teg@jklm.no> | 2013-10-29 15:36:26 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2013-10-29 16:12:11 +0100 |
commit | 5b9d4dc05560ddda89e48b6b39365824b15e1300 (patch) | |
tree | 2c71463e908fc382ae9df5b044483f16aa73680f | |
parent | 97f2d76d4f4dfab8b0629c09926a05a1e5621125 (diff) |
udev: link-config - use _cleanup_ macro locally
-rw-r--r-- | src/udev/net/link-config.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index 598f93e384..cc8ff6fda7 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -49,8 +49,11 @@ struct link_config_ctx { usec_t link_dirs_ts_usec; }; +DEFINE_TRIVIAL_CLEANUP_FUNC(link_config_ctx*, link_config_ctx_free); +#define _cleanup_link_config_ctx_free_ _cleanup_(link_config_ctx_freep) + int link_config_ctx_new(link_config_ctx **ret) { - link_config_ctx *ctx; + _cleanup_link_config_ctx_free_ link_config_ctx *ctx = NULL; int r; if (!ret) @@ -61,16 +64,12 @@ int link_config_ctx_new(link_config_ctx **ret) { return -ENOMEM; r = ethtool_connect(&ctx->ethtool_fd); - if (r < 0) { - link_config_ctx_free(ctx); + if (r < 0) return r; - } r = sd_rtnl_open(0, &ctx->rtnl); - if (r < 0) { - link_config_ctx_free(ctx); + if (r < 0) return r; - } LIST_HEAD_INIT(ctx->links); @@ -80,16 +79,17 @@ int link_config_ctx_new(link_config_ctx **ret) { NULL); if (!ctx->link_dirs) { log_error("failed to build link config directory array"); - link_config_ctx_free(ctx); return -ENOMEM; } + if (!path_strv_canonicalize_uniq(ctx->link_dirs)) { log_error("failed to canonicalize link config directories\n"); - link_config_ctx_free(ctx); return -ENOMEM; } *ret = ctx; + ctx = NULL; + return 0; } |