https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0bede0062aaeb495a30e15...
commit 0bede0062aaeb495a30e151677ae84b33a459d78 Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Sun Dec 29 16:53:36 2019 +0100 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Sun Dec 29 19:13:59 2019 +0100
[CMD] Code formatting; don't hardcode the string buffer sizes in function calls. --- base/shell/cmd/prompt.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/base/shell/cmd/prompt.c b/base/shell/cmd/prompt.c index f89817a2b2e..9bf01e07e76 100644 --- a/base/shell/cmd/prompt.c +++ b/base/shell/cmd/prompt.c @@ -52,7 +52,7 @@ static TCHAR DefaultPrompt[] = _T("$P$G");
/* - * Initialize prompt support + * Initialize prompt support. */ VOID InitPrompt(VOID) { @@ -62,12 +62,12 @@ VOID InitPrompt(VOID) * Set the PROMPT environment variable if it doesn't exist already. * You can change the PROMPT environment variable before cmd starts. */ - if (GetEnvironmentVariable(_T("PROMPT"), Buffer, ARRAYSIZE(Buffer)) == 0) + if (GetEnvironmentVariable(_T("PROMPT"), Buffer, _countof(Buffer)) == 0) SetEnvironmentVariable(_T("PROMPT"), DefaultPrompt); }
/* - * Print an information line on top of the screen + * Print an information line on top of the screen. */ VOID PrintInfoLine(VOID) { @@ -104,14 +104,15 @@ VOID PrintInfoLine(VOID) }
/* - * Print the command-line prompt + * Print the command-line prompt. */ VOID PrintPrompt(VOID) { - TCHAR szPrompt[256]; LPTSTR pr; + TCHAR szPrompt[256]; + TCHAR szPath[MAX_PATH];
- if (GetEnvironmentVariable(_T("PROMPT"), szPrompt, 256)) + if (GetEnvironmentVariable(_T("PROMPT"), szPrompt, _countof(szPrompt))) pr = szPrompt; else pr = DefaultPrompt; @@ -171,20 +172,18 @@ VOID PrintPrompt(VOID) break;
case _T('N'): - { - TCHAR szPath[MAX_PATH]; - GetCurrentDirectory(MAX_PATH, szPath); - ConOutChar(szPath[0]); - } + { + GetCurrentDirectory(_countof(szPath), szPath); + ConOutChar(szPath[0]); break; + }
case _T('P'): - { - TCHAR szPath[MAX_PATH]; - GetCurrentDirectory(MAX_PATH, szPath); - ConOutPrintf(_T("%s"), szPath); - } + { + GetCurrentDirectory(_countof(szPath), szPath); + ConOutPrintf(_T("%s"), szPath); break; + }
case _T('Q'): ConOutChar(_T('=')); @@ -212,12 +211,12 @@ VOID PrintPrompt(VOID)
#ifdef FEATURE_DIRECTORY_STACK case '+': - { - INT i; - for (i = 0; i < GetDirectoryStackDepth (); i++) - ConOutChar(_T('+')); - } + { + INT i; + for (i = 0; i < GetDirectoryStackDepth(); i++) + ConOutChar(_T('+')); break; + } #endif } }