summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2024-04-22 21:48:14 +0200
committerAlejandro Colomar <alx@kernel.org>2024-06-18 22:59:44 +0200
commit7b7b303a729508c4a6a02c2dd46e94c5683ad2a2 (patch)
treed52fcce3be774a1a4a48a491cf1bea9e6de12760 /src
parent3873f98f7e43967458a5080a30107cff52f8d935 (diff)
downloadunit-7b7b303a729508c4a6a02c2dd46e94c5683ad2a2.tar.gz
unit-7b7b303a729508c4a6a02c2dd46e94c5683ad2a2.tar.bz2
fs: Invert logic to reduce indentation in nxt_fs_mkdir_dirname()
This refactor isn't very appealing alone, but it prepares the code for the following commits. Link: <https://github.com/nginx/unit/issues/742> Tested-by: Andy Postnikov <apostnikov@gmail.com> Tested-by: Andrew Clayton <a.clayton@nginx.com> Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Cc: Liam Crilly <liam@nginx.com> Cc: Konstantin Pavlov <thresh@nginx.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'src')
-rw-r--r--src/nxt_fs.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/nxt_fs.c b/src/nxt_fs.c
index 0d10f623..6a93c670 100644
--- a/src/nxt_fs.c
+++ b/src/nxt_fs.c
@@ -58,11 +58,14 @@ nxt_fs_mkdir_dirname(const u_char *path, mode_t mode)
ret = NXT_OK;
ptr = strrchr(dir, '/');
- if (nxt_fast_path(ptr != NULL)) {
- *ptr = '\0';
- ret = nxt_fs_mkdir((const u_char *) dir, mode);
+ if (nxt_slow_path(ptr == NULL)) {
+ goto out_free;
}
+ *ptr = '\0';
+ ret = nxt_fs_mkdir((const u_char *) dir, mode);
+
+out_free:
nxt_free(dir);
return ret;