From af6a67ffa0c5accb90126972116cb1e8e332f3b7 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Tue, 23 Apr 2024 12:41:08 +0200 Subject: 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 Tested-by: Andrew Clayton Reviewed-by: Andrew Clayton Signed-off-by: Alejandro Colomar --- src/nxt_fs.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src') 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); } -- cgit