From e0779d1e204438d5a4df7f2a12dc949fe7a5ac7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 7 Apr 2021 16:17:44 +0200 Subject: [PATCH] zed: untangle _zed_conf_parse_path() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dunno, maybe it's just me, but the previous style was /really/ confusing Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia ZiemiaƄska Closes #11860 --- cmd/zed/zed_conf.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cmd/zed/zed_conf.c b/cmd/zed/zed_conf.c index 9e67363f7f..b66b67b530 100644 --- a/cmd/zed/zed_conf.c +++ b/cmd/zed/zed_conf.c @@ -206,16 +206,19 @@ _zed_conf_parse_path(char **resultp, const char *path) if (path[0] == '/') { *resultp = strdup(path); - } else if (!getcwd(buf, sizeof (buf))) { - zed_log_die("Failed to get current working dir: %s", - strerror(errno)); - } else if (strlcat(buf, "/", sizeof (buf)) >= sizeof (buf)) { - zed_log_die("Failed to copy path: %s", strerror(ENAMETOOLONG)); - } else if (strlcat(buf, path, sizeof (buf)) >= sizeof (buf)) { - zed_log_die("Failed to copy path: %s", strerror(ENAMETOOLONG)); } else { + if (!getcwd(buf, sizeof (buf))) + zed_log_die("Failed to get current working dir: %s", + strerror(errno)); + + if (strlcat(buf, "/", sizeof (buf)) >= sizeof (buf) || + strlcat(buf, path, sizeof (buf)) >= sizeof (buf)) + zed_log_die("Failed to copy path: %s", + strerror(ENAMETOOLONG)); + *resultp = strdup(buf); } + if (!*resultp) zed_log_die("Failed to copy path: %s", strerror(ENOMEM)); }