https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d0ced4ffdffa83cd4aa1c…
commit d0ced4ffdffa83cd4aa1cf7694912a9a5c2c8793
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun May 17 20:08:41 2020 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon May 18 02:21:56 2020 +0200
[CMD] Fix the ErrorMessage() function.
Specify its szFormat parameter optional, and correctly initialize the
szMessage buffer.
---
base/shell/cmd/cmd.h | 6 +++++-
base/shell/cmd/del.c | 2 +-
base/shell/cmd/error.c | 16 ++++++++++------
base/shell/cmd/vol.c | 2 +-
4 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/base/shell/cmd/cmd.h b/base/shell/cmd/cmd.h
index 48f6df0b5b2..20f946463ca 100644
--- a/base/shell/cmd/cmd.h
+++ b/base/shell/cmd/cmd.h
@@ -165,7 +165,11 @@ INT CommandEchoerr (LPTSTR);
INT CommandEchoserr (LPTSTR);
/* Prototypes for ERROR.C */
-VOID ErrorMessage (DWORD, LPTSTR, ...);
+VOID
+ErrorMessage(
+ IN DWORD dwErrorCode,
+ IN LPTSTR szFormat OPTIONAL,
+ ...);
VOID error_no_pipe (VOID);
VOID error_bad_command (LPTSTR);
diff --git a/base/shell/cmd/del.c b/base/shell/cmd/del.c
index 7f2d2a63db6..8e5cfbdccb8 100644
--- a/base/shell/cmd/del.c
+++ b/base/shell/cmd/del.c
@@ -263,7 +263,7 @@ DeleteFiles(LPTSTR FileName, DWORD* dwFlags, DWORD dwAttrFlags)
}
else
{
- ErrorMessage (GetLastError(), _T(""));
+ ErrorMessage (GetLastError(), NULL);
// FindClose(hFile);
// return -1;
}
diff --git a/base/shell/cmd/error.c b/base/shell/cmd/error.c
index 92f08a0d996..c0f61fd00a7 100644
--- a/base/shell/cmd/error.c
+++ b/base/shell/cmd/error.c
@@ -22,19 +22,23 @@
#include "precomp.h"
-
-VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...)
+VOID
+ErrorMessage(
+ IN DWORD dwErrorCode,
+ IN LPTSTR szFormat OPTIONAL,
+ ...)
{
- TCHAR szMsg[RC_STRING_MAX_SIZE];
- TCHAR szMessage[1024];
- LPTSTR szError;
va_list arg_ptr;
+ LPTSTR szError;
+ TCHAR szMsg[RC_STRING_MAX_SIZE];
+ TCHAR szMessage[1024];
if (dwErrorCode == ERROR_SUCCESS)
return;
nErrorLevel = 1;
+ *szMessage = 0;
if (szFormat)
{
va_start(arg_ptr, szFormat);
@@ -48,7 +52,7 @@ VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...)
{
ConErrPrintf(_T("%s %s\n"), szError, szMessage);
if (szError)
- LocalFree (szError);
+ LocalFree(szError);
return;
}
diff --git a/base/shell/cmd/vol.c b/base/shell/cmd/vol.c
index eed27c9dd57..cdd529e6376 100644
--- a/base/shell/cmd/vol.c
+++ b/base/shell/cmd/vol.c
@@ -41,7 +41,7 @@ PrintVolumeHeader (LPTSTR pszRootPath)
NULL,
0))
{
- ErrorMessage(GetLastError (), _T(""));
+ ErrorMessage(GetLastError (), NULL);
return 1;
}