]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
Update the code of processing device path info in browser to follow UEFI spec.
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Expression.c
index ff46fcbc5a7df49a30eb39692baa7ac780f58cf6..4a431f0dec5124c472bafd06361d7042a4affa47 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Utility functions for expression evaluation.\r
 \r
-Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -1071,7 +1071,7 @@ IfrToString (
       CopyMem (TmpBuf, Value.Buffer, Value.BufferLen * sizeof (CHAR16));\r
       PrintFormat = L"%s";  \r
     }\r
-    UnicodeSPrint (Buffer, MAXIMUM_VALUE_CHARACTERS, PrintFormat, Value.Buffer);  \r
+    UnicodeSPrint (Buffer, sizeof (Buffer), PrintFormat, Value.Buffer);  \r
     String = Buffer; \r
     FreePool (TmpBuf);\r
     FreePool (Value.Buffer);\r
@@ -2210,6 +2210,7 @@ EvaluateExpression (
   UINT8                   *TempBuffer;\r
   EFI_TIME                EfiTime;\r
   EFI_HII_VALUE           QuestionVal;\r
+  EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
 \r
   //\r
   // Save current stack offset.\r
@@ -2469,17 +2470,22 @@ EvaluateExpression (
       }\r
 \r
       if (OpCode->DevicePath != 0) {\r
+        Value->Type = EFI_IFR_TYPE_UNDEFINED;\r
+\r
         StrPtr = GetToken (OpCode->DevicePath, FormSet->HiiHandle);\r
-        if (StrPtr == NULL) {\r
-          Value->Type = EFI_IFR_TYPE_UNDEFINED;\r
-          break;\r
+        if (StrPtr != NULL && mPathFromText != NULL) {\r
+          DevicePath = mPathFromText->ConvertTextToDevicePath(StrPtr);\r
+          if (DevicePath != NULL && GetQuestionValueFromForm(DevicePath, NULL, &OpCode->Guid, Value->Value.u16, &QuestionVal)) {\r
+            Value = &QuestionVal;\r
+          }\r
+          if (DevicePath != NULL) {\r
+            FreePool (DevicePath);\r
+          }\r
         }\r
 \r
-        if (!GetQuestionValueFromForm((EFI_DEVICE_PATH_PROTOCOL*)StrPtr, NULL, &OpCode->Guid, Value->Value.u16, &QuestionVal)){\r
-          Value->Type = EFI_IFR_TYPE_UNDEFINED;\r
-          break;\r
+        if (StrPtr != NULL) {\r
+          FreePool (StrPtr);\r
         }\r
-        Value = &QuestionVal;\r
       } else if (CompareGuid (&OpCode->Guid, &gZeroGuid) != 0) {\r
         if (!GetQuestionValueFromForm(NULL, FormSet->HiiHandle, &OpCode->Guid, Value->Value.u16, &QuestionVal)){\r
           Value->Type = EFI_IFR_TYPE_UNDEFINED;\r