[PATCH v2] win32: explicitly set errno to enoent if err is not error_directory
- From
- Rose via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Dec 19, 2022, 16:20 UTC
- Message-ID
- <pull.1402.v2.git.git.1671466826159.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1402.git.git.1671465108414.gitgitgadget@gmail.com>
From: Seija Kijin <doremylover123@gmail.com>
At this point, the only two possible errors are ERROR_DIRECTORY or ERROR_BAD_PATHNAME.
This code clarifies this and also saves a call to err_win_to_posix.
Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
win32: explicitly set errno to enoent if err is not error_directory
At this point, the only two possible errors are ERROR_DIRECTORY or
ERROR_BAD_PATHNAME.
This code clarifies this and also saves a call to err_win_to_posix.
Signed-off-by: Seija Kijin doremylover123@gmail.comPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1402%2FAtariDreams%2Fopendir-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1402/AtariDreams/opendir-v2 Pull-Request: https://github.com/git/git/pull/1402
Range-diff vs v1:
1: 6e66c0deaf9 ! 1: bf757aee0be Explicitly set errno to ENOENT if err is not ERROR_DIRECTORY
@@ Metadata
Author: Seija Kijin <doremylover123@gmail.com>
## Commit message ##
- Explicitly set errno to ENOENT if err is not ERROR_DIRECTORY
+ win32: explicitly set errno to enoent if err is not error_directory
At this point, the only two possible errors are
ERROR_DIRECTORY or ERROR_BAD_PATHNAME.compat/win32/dirent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/compat/win32/dirent.c b/compat/win32/dirent.c index 52420ec7d4d..8f94a5ab6db 100644 --- a/compat/win32/dirent.c +++ b/compat/win32/dirent.c @@ -34,13 +34,13 @@ DIR *opendir(const char *name) if (len && !is_dir_sep(pattern[len - 1])) pattern[len++] = '/'; pattern[len++] = '*'; - pattern[len] = 0; + pattern[len] = '\0'; /* open find handle */ h = FindFirstFileW(pattern, &fdata); if (h == INVALID_HANDLE_VALUE) { DWORD err = GetLastError(); - errno = (err == ERROR_DIRECTORY) ? ENOTDIR : err_win_to_posix(err); + errno = (err == ERROR_DIRECTORY) ? ENOTDIR : ENOENT; return NULL; } base-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7
-- gitgitgadget