https://git.reactos.org/?p=reactos.git;a=commitdiff;h=41e3badc9a778449c252d…
commit 41e3badc9a778449c252df73c1646d640534884c
Author: Thamatip Chitpong <thamatip.chitpong(a)reactos.org>
AuthorDate: Wed Jul 26 23:26:20 2023 +0700
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Jul 26 23:26:20 2023 +0700
[TASKMGR] Process page: Don't hardcode string length (#5490)
Addendum to 59dcec1 (#4323).
---
base/applications/taskmgr/procpage.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/base/applications/taskmgr/procpage.c b/base/applications/taskmgr/procpage.c
index 1740e0a2753..e3e791b6182 100644
--- a/base/applications/taskmgr/procpage.c
+++ b/base/applications/taskmgr/procpage.c
@@ -16,6 +16,8 @@
#define CMP(x1, x2)\
(x1 < x2 ? -1 : (x1 > x2 ? 1 : 0))
+#define CONST_STR_LEN(str) (_countof(str) - 1)
+
typedef struct
{
ULONG ProcessId;
@@ -994,7 +996,7 @@ DevicePathToDosPath(
WCHAR szDeviceName[MAX_PATH];
/* Check if lpDevicePath is a device path */
- if (_wcsnicmp(lpDevicePath, L"\\Device\\",
_countof(L"\\Device\\")-1) != 0)
+ if (_wcsnicmp(lpDevicePath, L"\\Device\\",
CONST_STR_LEN(L"\\Device\\")) != 0)
{
return 0;
}
@@ -1150,7 +1152,7 @@ GetProcessExecutablePathById(
if (GetSystemDirectoryW(pszSystemDir, uLength) != 0)
{
/* Get the required length, including the NULL terminator */
- dwRet = uLength + _countof(szKernelExe) - 1;
+ dwRet = uLength + CONST_STR_LEN(szKernelExe);
if (lpExePath && (dwLength >= dwRet))
{
@@ -1238,11 +1240,11 @@ void ProcessPage_OnOpenFileLocation(void)
goto Cleanup;
/* Build the shell command line */
- pszCmdLine = HeapAlloc(GetProcessHeap(), 0, (dwLength + 10) * sizeof(WCHAR));
+ pszCmdLine = HeapAlloc(GetProcessHeap(), 0, (dwLength +
CONST_STR_LEN(L"/select,\"\"")) * sizeof(WCHAR));
if (!pszCmdLine)
goto Cleanup;
- StringCchPrintfW(pszCmdLine, dwLength + 10, L"/select,\"%s\"",
pszExePath);
+ StringCchPrintfW(pszCmdLine, dwLength +
CONST_STR_LEN(L"/select,\"\""), L"/select,\"%s\"",
pszExePath);
/* Call the shell to open the file location and select it */
ShellExecuteW(NULL, L"open", L"explorer.exe", pszCmdLine, NULL,
SW_SHOWNORMAL);