summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2024-04-23 12:41:08 +0200
committerAlejandro Colomar <alx@kernel.org>2024-06-18 22:59:43 +0200
commitaf6a67ffa0c5accb90126972116cb1e8e332f3b7 (patch)
tree863ed3a93d1506293220cf9c11c28e7902e8e2c3 /src
parent40eaf4e4f711978625ecbbdd359caa33d947ec8d (diff)
downloadunit-af6a67ffa0c5accb90126972116cb1e8e332f3b7.tar.gz
unit-af6a67ffa0c5accb90126972116cb1e8e332f3b7.tar.bz2
fs: Use branchless code in nxt_fs_mkdir_p()
That branch was to avoid an infinite loop on the slash. However, we can achieve the same by using a +1 to make sure we advance at least 1 byte in each iteration. Tested-by: Andy Postnikov <apostnikov@gmail.com> Tested-by: Andrew Clayton <a.clayton@nginx.com> Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'src')
-rw-r--r--src/nxt_fs.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/nxt_fs.c b/src/nxt_fs.c
index 59e9a766..0af84742 100644
--- a/src/nxt_fs.c
+++ b/src/nxt_fs.c
@@ -23,11 +23,7 @@ nxt_fs_mkdir_p(const u_char *dir, mode_t mode)
start = (char *) dir;
while (*start != '\0') {
- if (*start == '/') {
- *dst++ = *start++;
- }
-
- end = strchr(start, '/');
+ end = strchr(start + 1, '/');
if (end == NULL) {
end = ((char *)dir + dirlen);
}