K8: add new variable PasswordSize to remove immeidate constant.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7307 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12 2009-01-20 01:48:39 +00:00
parent d64ac71565
commit 5a829f5688

View File

@ -33,7 +33,7 @@ CHAR16 VariableName[] = L"MyIfrNVData";
VOID VOID
EncodePassword ( EncodePassword (
IN CHAR16 *Password, IN CHAR16 *Password,
IN UINT8 MaxSize IN UINTN MaxSize
) )
{ {
UINTN Index; UINTN Index;
@ -167,6 +167,7 @@ SetPassword (
EFI_STATUS Status; EFI_STATUS Status;
UINTN BufferSize; UINTN BufferSize;
CHAR16 *Password; CHAR16 *Password;
UINTN PasswordSize;
DRIVER_SAMPLE_CONFIGURATION *Configuration; DRIVER_SAMPLE_CONFIGURATION *Configuration;
// //
@ -188,7 +189,9 @@ SetPassword (
// Get user input password // Get user input password
// //
Password = &PrivateData->Configuration.WhatIsThePassword2[0]; Password = &PrivateData->Configuration.WhatIsThePassword2[0];
ZeroMem (Password, 20 * sizeof (CHAR16)); PasswordSize = sizeof (PrivateData->Configuration.WhatIsThePassword2);
ZeroMem (Password, PasswordSize);
Status = HiiLibGetString (PrivateData->HiiHandle[0], StringId, Password, &BufferSize); Status = HiiLibGetString (PrivateData->HiiHandle[0], StringId, Password, &BufferSize);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
@ -205,7 +208,7 @@ SetPassword (
// //
// Update password's clear text in the screen // Update password's clear text in the screen
// //
CopyMem (Configuration->PasswordClearText, Password, 20 * sizeof (CHAR16)); CopyMem (Configuration->PasswordClearText, Password, PasswordSize);
// //
// Update uncommitted data of Browser // Update uncommitted data of Browser
@ -224,7 +227,7 @@ SetPassword (
// //
// Set password // Set password
// //
EncodePassword (Password, 20 * sizeof (CHAR16)); EncodePassword (Password, PasswordSize);
Status = gRT->SetVariable( Status = gRT->SetVariable(
VariableName, VariableName,
&mFormSetGuid, &mFormSetGuid,