* [PATCH] Explicitly set errno to ENOENT if err is not ERROR_DIRECTORY
@ 2022-12-19 15:51 Rose via GitGitGadget
2022-12-19 16:20 ` [PATCH v2] win32: explicitly set errno to enoent if err is not error_directory Rose via GitGitGadget
2022-12-19 18:33 ` [PATCH] Explicitly set errno to ENOENT if err is not ERROR_DIRECTORY Ævar Arnfjörð Bjarmason
0 siblings, 2 replies; 4+ messages in thread
From: Rose via GitGitGadget @ 2022-12-19 15:51 UTC (permalink / raw)
To: git; +Cc: Rose, Seija Kijin
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>
---
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.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1402%2FAtariDreams%2Fopendir-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1402/AtariDreams/opendir-v1
Pull-Request: https://github.com/git/git/pull/1402
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2] win32: explicitly set errno to enoent if err is not error_directory
2022-12-19 15:51 [PATCH] Explicitly set errno to ENOENT if err is not ERROR_DIRECTORY Rose via GitGitGadget
@ 2022-12-19 16:20 ` Rose via GitGitGadget
2022-12-20 7:21 ` Johannes Sixt
2022-12-19 18:33 ` [PATCH] Explicitly set errno to ENOENT if err is not ERROR_DIRECTORY Ævar Arnfjörð Bjarmason
1 sibling, 1 reply; 4+ messages in thread
From: Rose via GitGitGadget @ 2022-12-19 16:20 UTC (permalink / raw)
To: git; +Cc: Rose, Seija Kijin
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.com
Published-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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Explicitly set errno to ENOENT if err is not ERROR_DIRECTORY
2022-12-19 15:51 [PATCH] Explicitly set errno to ENOENT if err is not ERROR_DIRECTORY Rose via GitGitGadget
2022-12-19 16:20 ` [PATCH v2] win32: explicitly set errno to enoent if err is not error_directory Rose via GitGitGadget
@ 2022-12-19 18:33 ` Ævar Arnfjörð Bjarmason
1 sibling, 0 replies; 4+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-12-19 18:33 UTC (permalink / raw)
To: Rose via GitGitGadget; +Cc: git, Seija Kijin
On Mon, Dec 19 2022, Rose via GitGitGadget wrote:
> 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>
> ---
> 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.com
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1402%2FAtariDreams%2Fopendir-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1402/AtariDreams/opendir-v1
> Pull-Request: https://github.com/git/git/pull/1402
>
> 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';
Maybe the subject of this patch is a good change (I have no idea, and
don't use Windows), but this just seems like unrelated general cleanup.
I think it's probably good to change these sorts cases from 0 to '\0',
but let's do that as a seperate change...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] win32: explicitly set errno to enoent if err is not error_directory
2022-12-19 16:20 ` [PATCH v2] win32: explicitly set errno to enoent if err is not error_directory Rose via GitGitGadget
@ 2022-12-20 7:21 ` Johannes Sixt
0 siblings, 0 replies; 4+ messages in thread
From: Johannes Sixt @ 2022-12-20 7:21 UTC (permalink / raw)
To: Rose via GitGitGadget; +Cc: Rose, Seija Kijin, git
Am 19.12.22 um 17:20 schrieb Rose via GitGitGadget:
> 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>
> ---
> 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;
This change does not look correct. The documentation of
FindFirstFileW()[*] does not give any guarantees that ERROR_DIRECTORY
and ERROR_BAD_PATHNAME are the only possible error values. It is
certainly not unthinkable that a hardware error is reported as
ERROR_IO_DEVICE and should be translated to EIO.
[*]
https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findfirstfilew
-- Hannes
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-20 7:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-19 15:51 [PATCH] Explicitly set errno to ENOENT if err is not ERROR_DIRECTORY Rose via GitGitGadget
2022-12-19 16:20 ` [PATCH v2] win32: explicitly set errno to enoent if err is not error_directory Rose via GitGitGadget
2022-12-20 7:21 ` Johannes Sixt
2022-12-19 18:33 ` [PATCH] Explicitly set errno to ENOENT if err is not ERROR_DIRECTORY Ævar Arnfjörð Bjarmason
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).