Message ID | pull.756.git.git.1586427853403.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mingw: cope with the Isilon network file system | expand |
On Thu, 9 Apr 2020 at 12:26, Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com> wrote: > handle = CreateFileW(wfilename, FILE_APPEND_DATA, > FILE_SHARE_WRITE | FILE_SHARE_READ, > NULL, create, FILE_ATTRIBUTE_NORMAL, NULL); > - if (handle == INVALID_HANDLE_VALUE) > - return errno = err_win_to_posix(GetLastError()), -1; (This code, which is being removed, used "," to avoid having to introduce braces. There's another instance of this pattern a bit above.) > + if (handle == INVALID_HANDLE_VALUE) { (Adding a brace here.) > + DWORD err = GetLastError(); > + /* > + * Some network storage solutions (e.g. Isilon) might return > + * ERROR_INVALID_PARAMETER instead of expected error > + * ERROR_PATH_NOT_FOUND, which results in a unknow error. If s/ a / an / s/unknow/&n/ > + * so, the error is now forced to be an ERROR_PATH_NOT_FOUND > + * error instead. > + */ "is now forced" sounds more like it describes this change/commit, rather than this piece of code. Maybe this final sentence can be scrapped entirely, since the forcing/translating/mapping is obvious from the code anyway? The remainder of the comment goes into *why* and looks more useful. Just my 2 cents. > + if (err == ERROR_INVALID_PARAMETER) > + err = ERROR_PATH_NOT_FOUND; > + return errno = err_win_to_posix(err), -1; > + } Now there's no need to avoid introducing braces, so maybe split this into two lines for a lower huh-factor? errno = err_win_to_posix(err); return -1; Martin
Hi Martin, On Thu, 9 Apr 2020, Martin Ågren wrote: > On Thu, 9 Apr 2020 at 12:26, Johannes Schindelin via GitGitGadget > <gitgitgadget@gmail.com> wrote: > > > handle = CreateFileW(wfilename, FILE_APPEND_DATA, > > FILE_SHARE_WRITE | FILE_SHARE_READ, > > NULL, create, FILE_ATTRIBUTE_NORMAL, NULL); > > - if (handle == INVALID_HANDLE_VALUE) > > - return errno = err_win_to_posix(GetLastError()), -1; > > (This code, which is being removed, used "," to avoid having to introduce > braces. There's another instance of this pattern a bit above.) Oh yes, that's an important point I had missed. > > + if (handle == INVALID_HANDLE_VALUE) { > > (Adding a brace here.) > > > + DWORD err = GetLastError(); > > + /* > > + * Some network storage solutions (e.g. Isilon) might return > > + * ERROR_INVALID_PARAMETER instead of expected error > > + * ERROR_PATH_NOT_FOUND, which results in a unknow error. If > > s/ a / an / > s/unknow/&n/ Oh shucks. Usually I try to do a final review of the patches before I "upstream" them. Seems like the quality of my submission here is not what I want it to be. > > > + * so, the error is now forced to be an ERROR_PATH_NOT_FOUND > > + * error instead. > > + */ > > "is now forced" sounds more like it describes this change/commit, rather > than this piece of code. Maybe this final sentence can be scrapped > entirely, since the forcing/translating/mapping is obvious from the code > anyway? The remainder of the comment goes into *why* and looks more > useful. Just my 2 cents. > > > + if (err == ERROR_INVALID_PARAMETER) > > + err = ERROR_PATH_NOT_FOUND; > > + return errno = err_win_to_posix(err), -1; > > + } > > Now there's no need to avoid introducing braces, so maybe split this > into two lines for a lower huh-factor? > > errno = err_win_to_posix(err); > return -1; Absolutely. I updated the PR at https://github.com/git/git/pull/756 (also addressing issues with the commit message) and will wait for while before sending v2. Thank you for your excellent review, Dscho
diff --git a/compat/mingw.c b/compat/mingw.c index d14065d60ec..201e99292fd 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -460,8 +460,19 @@ static int mingw_open_append(wchar_t const *wfilename, int oflags, ...) handle = CreateFileW(wfilename, FILE_APPEND_DATA, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, create, FILE_ATTRIBUTE_NORMAL, NULL); - if (handle == INVALID_HANDLE_VALUE) - return errno = err_win_to_posix(GetLastError()), -1; + if (handle == INVALID_HANDLE_VALUE) { + DWORD err = GetLastError(); + /* + * Some network storage solutions (e.g. Isilon) might return + * ERROR_INVALID_PARAMETER instead of expected error + * ERROR_PATH_NOT_FOUND, which results in a unknow error. If + * so, the error is now forced to be an ERROR_PATH_NOT_FOUND + * error instead. + */ + if (err == ERROR_INVALID_PARAMETER) + err = ERROR_PATH_NOT_FOUND; + return errno = err_win_to_posix(err), -1; + } /* * No O_APPEND here, because the CRT uses it only to reset the