[edk2] [Patch] MdeModulePkg/DeviceManagerUiLib: Fix the network device MAC display issue

Jiaxin Wu posted 1 patch 6 years, 11 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
[edk2] [Patch] MdeModulePkg/DeviceManagerUiLib: Fix the network device MAC display issue
Posted by Jiaxin Wu 6 years, 11 months ago
Network device tile (STR_FORM_NETWORK_DEVICE_TITLE) is dynamic adjusted
according the different MAC value. So, the string value shouldn't be treated
as a constant string (Network Device). Otherwise, the display will be
incorrect.

Reproduce: Device Manager->Network Device List, select to enter MAC, then to
press ESC back to previous page, then re-enter, found each enter/ESC operation,
the MAC address display +1.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
 MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
index 5098b70..8630ab0 100644
--- a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
+++ b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
@@ -538,17 +538,15 @@ CreateDeviceManagerForm(
 
   //
   // Update the network device form titile.
   //
   if (NextShowFormId == NETWORK_DEVICE_FORM_ID) {
-    String = HiiGetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), NULL);
     NewStringLen = StrLen(mSelectedMacAddrString) * 2;
-    NewStringLen += (StrLen(String) + 2) * 2;
+    NewStringLen += (StrLen (L"Network Device") + 2) * 2;
     NewStringTitle = AllocatePool (NewStringLen);
-    UnicodeSPrint (NewStringTitle, NewStringLen, L"%s %s", String, mSelectedMacAddrString);
+    UnicodeSPrint (NewStringTitle, NewStringLen, L"Network Device %s", mSelectedMacAddrString);
     HiiSetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), NewStringTitle, NULL);    
-    FreePool (String);
     FreePool (NewStringTitle);
   }
 
   //
   // Allocate space for creation of UpdateData Buffer
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch] MdeModulePkg/DeviceManagerUiLib: Fix the network device MAC display issue
Posted by Dong, Eric 6 years, 11 months ago
Jiaxin,

Thanks to help to fix this issue. 

We'd better define new STR_FORM_NETWORK_DEVICE_TITLE_HEAD for L" Network Device " instead of hard code in the code.

Thanks,
Eric

-----Original Message-----
From: Wu, Jiaxin 
Sent: Monday, April 17, 2017 4:08 PM
To: edk2-devel@lists.01.org
Cc: Dong, Eric; Ye, Ting; Fu, Siyuan; Wu, Jiaxin
Subject: [Patch] MdeModulePkg/DeviceManagerUiLib: Fix the network device MAC display issue

Network device tile (STR_FORM_NETWORK_DEVICE_TITLE) is dynamic adjusted according the different MAC value. So, the string value shouldn't be treated as a constant string (Network Device). Otherwise, the display will be incorrect.

Reproduce: Device Manager->Network Device List, select to enter MAC, then to press ESC back to previous page, then re-enter, found each enter/ESC operation, the MAC address display +1.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
 MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
index 5098b70..8630ab0 100644
--- a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
+++ b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c
@@ -538,17 +538,15 @@ CreateDeviceManagerForm(
 
   //
   // Update the network device form titile.
   //
   if (NextShowFormId == NETWORK_DEVICE_FORM_ID) {
-    String = HiiGetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), NULL);
     NewStringLen = StrLen(mSelectedMacAddrString) * 2;
-    NewStringLen += (StrLen(String) + 2) * 2;
+    NewStringLen += (StrLen (L"Network Device") + 2) * 2;
     NewStringTitle = AllocatePool (NewStringLen);
-    UnicodeSPrint (NewStringTitle, NewStringLen, L"%s %s", String, mSelectedMacAddrString);
+    UnicodeSPrint (NewStringTitle, NewStringLen, L"Network Device %s", 
+ mSelectedMacAddrString);
     HiiSetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), NewStringTitle, NULL);    
-    FreePool (String);
     FreePool (NewStringTitle);
   }
 
   //
   // Allocate space for creation of UpdateData Buffer
--
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel