https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e1d0128ffce745d4c1b22…
commit e1d0128ffce745d4c1b22f28a394d90f14df5dbc
Author: Doug Lyons <douglyons(a)douglyons.com>
AuthorDate: Tue Dec 10 22:24:03 2019 -0600
Commit: Victor Perevertkin <victor(a)perevertkin.ru>
CommitDate: Tue Dec 28 02:03:54 2021 +0300
Fewer GetLastError() function calls.
---
base/applications/cmdutils/attrib/attrib.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/base/applications/cmdutils/attrib/attrib.c
b/base/applications/cmdutils/attrib/attrib.c
index fd5b5e8372a..eb207eb7d80 100644
--- a/base/applications/cmdutils/attrib/attrib.c
+++ b/base/applications/cmdutils/attrib/attrib.c
@@ -86,14 +86,14 @@ ErrorMessage(
ConPrintf(StdOut, L"%s\n", szMsg);
}
-/* Returns TRUE if anything found and listed, FALSE otherwise */
+/* Returns TRUE if anything is printed, FALSE otherwise */
static
BOOL
PrintAttribute(
LPWSTR pszPath,
LPWSTR pszFile,
- BOOL bRecurse,
- BOOL bDirectories)
+ BOOL bRecurse,
+ BOOL bDirectories)
{
WIN32_FIND_DATAW findData;
HANDLE hFind;
@@ -102,6 +102,7 @@ PrintAttribute(
BOOL bFound = FALSE;
BOOL bIsDir;
BOOL bExactMatch;
+ DWORD Error;
/* prepare full file name buffer */
wcscpy(szFullName, pszPath);
@@ -116,9 +117,10 @@ PrintAttribute(
hFind = FindFirstFileW(szFullName, &findData);
if (hFind == INVALID_HANDLE_VALUE)
{
- if ((GetLastError() != ERROR_DIRECTORY) && (GetLastError() !=
ERROR_SHARING_VIOLATION)
- && (GetLastError() != ERROR_FILE_NOT_FOUND))
- ErrorMessage(GetLastError(), pszFile);
+ Error = GetLastError();
+ if ((Error != ERROR_DIRECTORY) && (Error != ERROR_SHARING_VIOLATION)
+ && (Error != ERROR_FILE_NOT_FOUND))
+ ErrorMessage(Error, pszFile);
return FALSE;
}
@@ -197,6 +199,7 @@ ChangeAttribute(
BOOL bIsDir;
BOOL bExactMatch;
DWORD dwAttribute;
+ DWORD Error;
/* prepare full file name buffer */
wcscpy(szFullName, pszPath);
@@ -211,9 +214,10 @@ ChangeAttribute(
hFind = FindFirstFileW(szFullName, &findData);
if (hFind == INVALID_HANDLE_VALUE)
{
- if ((GetLastError() != ERROR_DIRECTORY) && (GetLastError() !=
ERROR_SHARING_VIOLATION)
- && (GetLastError() != ERROR_FILE_NOT_FOUND))
- ErrorMessage(GetLastError(), pszFile);
+ Error = GetLastError();
+ if ((Error != ERROR_DIRECTORY) && (Error != ERROR_SHARING_VIOLATION)
+ && (Error != ERROR_FILE_NOT_FOUND))
+ ErrorMessage(Error, pszFile);
return FALSE;
}