From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4000E81951 for ; Mon, 9 Jan 2017 01:31:10 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 09 Jan 2017 01:30:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,339,1477983600"; d="scan'208";a="211175754" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by fmsmga004.fm.intel.com with ESMTP; 09 Jan 2017 01:30:56 -0800 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Jaben Carsey Date: Mon, 9 Jan 2017 17:30:49 +0800 Message-Id: <20170109093052.140504-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 In-Reply-To: <20170109093052.140504-1-ruiyu.ni@intel.com> References: <20170109093052.140504-1-ruiyu.ni@intel.com> Subject: [PATCH 2/5] ShellPkg/HandleParsingLib: Return NULL name for unknown GUID X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2017 09:31:10 -0000 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 Cc: Jaben Carsey --- .../UefiHandleParsingLib/UefiHandleParsingLib.c | 42 +++++++++++----------- .../UefiHandleParsingLib/UefiHandleParsingLib.uni | 4 +-- ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c | 20 ++++++----- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index 1049dea..780c458 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -933,25 +933,22 @@ AdapterInformationDumpInformation ( } else { GuidStr = GetStringNameFromGuid (&InfoTypesBuffer[GuidIndex], NULL); + if (GuidStr == NULL) { + TempRetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType"); + SHELL_FREE_NON_NULL (RetVal); + RetVal = TempRetVal; - if (GuidStr != NULL) { - if (StrCmp(GuidStr, L"UnknownDevice") == 0) { - TempRetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType"); - SHELL_FREE_NON_NULL (RetVal); - RetVal = TempRetVal; - - SHELL_FREE_NON_NULL (TempStr); - SHELL_FREE_NON_NULL(GuidStr); - // - // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP - // - continue; - } else { - TempRetVal = CatSPrint (RetVal, TempStr, GuidStr); - SHELL_FREE_NON_NULL (RetVal); - RetVal = TempRetVal; - SHELL_FREE_NON_NULL(GuidStr); - } + SHELL_FREE_NON_NULL (TempStr); + SHELL_FREE_NON_NULL(GuidStr); + // + // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP + // + continue; + } else { + TempRetVal = CatSPrint (RetVal, TempStr, GuidStr); + SHELL_FREE_NON_NULL (RetVal); + RetVal = TempRetVal; + SHELL_FREE_NON_NULL(GuidStr); } } @@ -1500,7 +1497,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringListNT[] = { {STRING_TOKEN(STR_WINNT_THUNK), (EFI_GUID*)&WinNtThunkProtocolGuid, NULL}, {STRING_TOKEN(STR_WINNT_DRIVER_IO), (EFI_GUID*)&WinNtIoProtocolGuid, NULL}, {STRING_TOKEN(STR_WINNT_SERIAL_PORT), (EFI_GUID*)&WinNtSerialPortGuid, NULL}, - {STRING_TOKEN(STR_UNKNOWN_DEVICE), NULL, NULL}, + {0, NULL, NULL}, }; STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = { @@ -1816,7 +1813,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = { // // terminator // - {STRING_TOKEN(STR_UNKNOWN_DEVICE), NULL, NULL}, + {0, NULL, NULL}, }; /** @@ -1964,7 +1961,10 @@ GetStringNameFromGuid( HandleParsingHiiInit(); Id = InternalShellGetNodeFromGuid(Guid); - return (HiiGetString(mHandleParsingHiiHandle, Id==NULL?STRING_TOKEN(STR_UNKNOWN_DEVICE):Id->StringId, Lang)); + if (Id == NULL) { + return NULL; + } + return HiiGetString (mHandleParsingHiiHandle, Id->StringId, Lang); } /** diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni index aa6663d..0d51627 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni @@ -1,6 +1,6 @@ // /** // -// Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
+// Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
// (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
// (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
// This program and the accompanying materials @@ -159,8 +159,6 @@ #string STR_WINNT_DRIVER_IO #language en-US "WinNTDriverIO" #string STR_WINNT_SERIAL_PORT #language en-US "WinNTSerialPort" -#string STR_UNKNOWN_DEVICE #language en-US "UnknownDevice" - // deprecated protocols #string STR_SHELL_INTERFACE #language en-US "ShellInterface" #string STR_SHELL_ENV #language en-US "ShellEnvironment" diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c index e07304c..0ac49e1 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c @@ -2,7 +2,7 @@ Main file for Dh shell Driver1 function. (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -153,6 +153,7 @@ GetProtocolInfoString( CHAR16 *RetVal; UINTN Size; CHAR16 *Temp; + CHAR16 GuidStr[40]; ProtocolGuidArray = NULL; RetVal = NULL; @@ -166,16 +167,19 @@ GetProtocolInfoString( if (!EFI_ERROR (Status)) { for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) { Temp = GetStringNameFromGuid(ProtocolGuidArray[ProtocolIndex], Language); - if (Temp != NULL) { - ASSERT((RetVal == NULL && Size == 0) || (RetVal != NULL)); - if (Size != 0) { - StrnCatGrow(&RetVal, &Size, Separator, 0); - } - StrnCatGrow(&RetVal, &Size, L"%H", 0); + ASSERT((RetVal == NULL && Size == 0) || (RetVal != NULL)); + if (Size != 0) { + StrnCatGrow(&RetVal, &Size, Separator, 0); + } + StrnCatGrow(&RetVal, &Size, L"%H", 0); + if (Temp == NULL) { + UnicodeSPrint (GuidStr, sizeof (GuidStr), L"%g", ProtocolGuidArray[ProtocolIndex]); + StrnCatGrow (&RetVal, &Size, GuidStr, 0); + } else { StrnCatGrow(&RetVal, &Size, Temp, 0); - StrnCatGrow(&RetVal, &Size, L"%N", 0); FreePool(Temp); } + StrnCatGrow(&RetVal, &Size, L"%N", 0); if (ExtraInfo) { Temp = GetProtocolInformationDump(TheHandle, ProtocolGuidArray[ProtocolIndex], Verbose); if (Temp != NULL) { -- 2.9.0.windows.1