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>
This commit is contained in:
parent
3873f98f7e
commit
7b7b303a72
1 changed files with 6 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue