ShellPkg/HandleParsingLib: Return NULL name for unknown GUID
authorRuiyu Ni <ruiyu.ni@intel.com>
Mon, 9 Jan 2017 08:45:40 +0000 (16:45 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Wed, 11 Jan 2017 02:07:06 +0000 (10:07 +0800)
GetStringNameFromGuid() returns NULL for unknown GUID, instead of
returning "UnknownDevice".
The behavior change matches ShellProtocol.GetGuidName().

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c

index 1049dea0c009bdb628e0032f890f0d6ba03a9d20..780c4587b821a1bc20b61f76576ebe62756b897b 100644 (file)
@@ -933,25 +933,22 @@ AdapterInformationDumpInformation (
       } else {\r
 \r
         GuidStr = GetStringNameFromGuid (&InfoTypesBuffer[GuidIndex], NULL);\r
+        if (GuidStr == NULL) {\r
+          TempRetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType");\r
+          SHELL_FREE_NON_NULL (RetVal);\r
+          RetVal = TempRetVal;\r
 \r
-        if (GuidStr != NULL) {\r
-          if (StrCmp(GuidStr, L"UnknownDevice") == 0) {\r
-            TempRetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType");\r
-            SHELL_FREE_NON_NULL (RetVal);\r
-            RetVal = TempRetVal;\r
-\r
-            SHELL_FREE_NON_NULL (TempStr);\r
-            SHELL_FREE_NON_NULL(GuidStr);\r
-            //\r
-            // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP\r
-            //\r
-            continue;\r
-          } else {\r
-            TempRetVal = CatSPrint (RetVal, TempStr, GuidStr);\r
-            SHELL_FREE_NON_NULL (RetVal);\r
-            RetVal = TempRetVal;\r
-            SHELL_FREE_NON_NULL(GuidStr);\r
-          }\r
+          SHELL_FREE_NON_NULL (TempStr);\r
+          SHELL_FREE_NON_NULL(GuidStr);\r
+          //\r
+          // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP\r
+          //\r
+          continue;\r
+        } else {\r
+          TempRetVal = CatSPrint (RetVal, TempStr, GuidStr);\r
+          SHELL_FREE_NON_NULL (RetVal);\r
+          RetVal = TempRetVal;\r
+          SHELL_FREE_NON_NULL(GuidStr);\r
         }\r
       }\r
 \r
@@ -1500,7 +1497,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringListNT[] = {
   {STRING_TOKEN(STR_WINNT_THUNK),           (EFI_GUID*)&WinNtThunkProtocolGuid,               NULL},\r
   {STRING_TOKEN(STR_WINNT_DRIVER_IO),       (EFI_GUID*)&WinNtIoProtocolGuid,                  NULL},\r
   {STRING_TOKEN(STR_WINNT_SERIAL_PORT),     (EFI_GUID*)&WinNtSerialPortGuid,                  NULL},\r
-  {STRING_TOKEN(STR_UNKNOWN_DEVICE),        NULL,                                             NULL},\r
+  {0,                                       NULL,                                             NULL},\r
 };\r
 \r
 STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {\r
@@ -1816,7 +1813,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
 //\r
 // terminator\r
 //\r
-  {STRING_TOKEN(STR_UNKNOWN_DEVICE),        NULL,                                             NULL},\r
+  {0,                                       NULL,                                             NULL},\r
 };\r
 \r
 /**\r
@@ -1964,7 +1961,10 @@ GetStringNameFromGuid(
   HandleParsingHiiInit();\r
 \r
   Id = InternalShellGetNodeFromGuid(Guid);\r
-  return (HiiGetString(mHandleParsingHiiHandle, Id==NULL?STRING_TOKEN(STR_UNKNOWN_DEVICE):Id->StringId, Lang));\r
+  if (Id == NULL) {\r
+    return NULL;\r
+  }\r
+  return HiiGetString (mHandleParsingHiiHandle, Id->StringId, Lang);\r
 }\r
 \r
 /**\r
index aa6663d24752a1c9366d90e9f71520d09b893273..0d51627c5fc80597511d507eaf16f48abf6c57c7 100644 (file)
@@ -1,6 +1,6 @@
 // /**\r
 //\r
-// Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved. <BR>\r
+// Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. <BR>\r
 // (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
 // (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
 // This program and the accompanying materials\r
 #string STR_WINNT_DRIVER_IO       #language en-US "WinNTDriverIO"\r
 #string STR_WINNT_SERIAL_PORT     #language en-US "WinNTSerialPort"\r
 \r
-#string STR_UNKNOWN_DEVICE        #language en-US "UnknownDevice"\r
-\r
 // deprecated protocols\r
 #string STR_SHELL_INTERFACE       #language en-US "ShellInterface"\r
 #string STR_SHELL_ENV             #language en-US "ShellEnvironment"\r
index e07304cd7fe86b19c9d0d45702f4cd1820209711..0ac49e1e7877323aaa3f53a561d2d36df50fb60c 100644 (file)
@@ -2,7 +2,7 @@
   Main file for Dh shell Driver1 function.\r
 \r
   (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2017, 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
@@ -153,6 +153,7 @@ GetProtocolInfoString(
   CHAR16                    *RetVal;\r
   UINTN                     Size;\r
   CHAR16                    *Temp;\r
+  CHAR16                    GuidStr[40];\r
 \r
   ProtocolGuidArray = NULL;\r
   RetVal            = NULL;\r
@@ -166,16 +167,19 @@ GetProtocolInfoString(
   if (!EFI_ERROR (Status)) {\r
     for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {\r
       Temp = GetStringNameFromGuid(ProtocolGuidArray[ProtocolIndex], Language);\r
-      if (Temp != NULL) {\r
-        ASSERT((RetVal == NULL && Size == 0) || (RetVal != NULL));\r
-        if (Size != 0) {\r
-          StrnCatGrow(&RetVal, &Size, Separator, 0);\r
-        }\r
-        StrnCatGrow(&RetVal, &Size, L"%H", 0);\r
+      ASSERT((RetVal == NULL && Size == 0) || (RetVal != NULL));\r
+      if (Size != 0) {\r
+        StrnCatGrow(&RetVal, &Size, Separator, 0);\r
+      }\r
+      StrnCatGrow(&RetVal, &Size, L"%H", 0);\r
+      if (Temp == NULL) {\r
+        UnicodeSPrint (GuidStr, sizeof (GuidStr), L"%g", ProtocolGuidArray[ProtocolIndex]);\r
+        StrnCatGrow (&RetVal, &Size, GuidStr, 0);\r
+      } else {\r
         StrnCatGrow(&RetVal, &Size, Temp, 0);\r
-        StrnCatGrow(&RetVal, &Size, L"%N", 0);\r
         FreePool(Temp);\r
       }\r
+      StrnCatGrow(&RetVal, &Size, L"%N", 0);\r
       if (ExtraInfo) {\r
         Temp = GetProtocolInformationDump(TheHandle, ProtocolGuidArray[ProtocolIndex], Verbose);\r
         if (Temp != NULL) {\r