aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-04-07 16:17:44 +0200
committerBrian Behlendorf <[email protected]>2021-04-14 13:19:49 -0700
commitbb8db9d9277094142f829f0407713807e29a802a (patch)
tree6d3b6d09409eedb4b91d32d82921263ef17100fd
parent32cc3f0837f9ea959fb06bfcb8bdb658a585d2bb (diff)
zed: untangle _zed_conf_parse_path()
Dunno, maybe it's just me, but the previous style was /really/ confusing Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #11860
-rw-r--r--cmd/zed/zed_conf.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/cmd/zed/zed_conf.c b/cmd/zed/zed_conf.c
index 9e67363f7..b66b67b53 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));
}