From 7b7b303a729508c4a6a02c2dd46e94c5683ad2a2 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Mon, 22 Apr 2024 21:48:14 +0200 Subject: 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: Tested-by: Andy Postnikov Tested-by: Andrew Clayton Reviewed-by: Andrew Clayton Cc: Liam Crilly Cc: Konstantin Pavlov Signed-off-by: Alejandro Colomar --- src/nxt_fs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') 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; -- cgit