[edk2] [PATCH v4] Ifconfig : Fixed False information about Media State.

Meenakshi Aggarwal posted 1 patch 7 years, 2 months ago
Failed in applying to current master (apply log)
ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
[edk2] [PATCH v4] Ifconfig : Fixed False information about Media State.
Posted by Meenakshi Aggarwal 7 years, 2 months ago
Issue : We were setting MediaPresent as TRUE (default) and
not checking return status of NetLibDetectMedia().
NetLibDetectMedia() sets MediaPresent FLAG in case of success
only and dont change flag on error.
So, Media State will display as 'Media Present', in case of
error also.

Fix : Check return value of NetLibDetectMedia(), if error then
print "Media State Unknown"

Contributed-under: TianoCore Contribution Agreement 1.1

Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
 ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index 4db07b2..082ab72 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -576,11 +576,14 @@ IfConfigShowInterfaceInfo (
     //
     // Get Media State.
     //
-    NetLibDetectMedia (IfCb->NicHandle, &MediaPresent);
-    if (!MediaPresent) {
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media disconnected");
+    if (EFI_SUCCESS == NetLibDetectMedia (IfCb->NicHandle, &MediaPresent)) {
+      if (!MediaPresent) {
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media disconnected");
+      } else {
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media present");
+      }
     } else {
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media present");
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media state unknown");
     }
 
     //
-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH v4] Ifconfig : Fixed False information about Media State.
Posted by Wu, Jiaxin 7 years, 2 months ago
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Meenakshi Aggarwal
> Sent: Tuesday, October 10, 2017 10:08 PM
> To: edk2-devel@lists.01.org; Wu, Jiaxin <jiaxin.wu@intel.com>; Carsey,
> Jaben <jaben.carsey@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: [edk2] [PATCH v4] Ifconfig : Fixed False information about Media
> State.
> 
> Issue : We were setting MediaPresent as TRUE (default) and
> not checking return status of NetLibDetectMedia().
> NetLibDetectMedia() sets MediaPresent FLAG in case of success
> only and dont change flag on error.
> So, Media State will display as 'Media Present', in case of
> error also.
> 
> Fix : Check return value of NetLibDetectMedia(), if error then
> print "Media State Unknown"
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> 
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> ---
>  ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c | 11 +++++++--
> --
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
> b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
> index 4db07b2..082ab72 100644
> --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
> +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
> @@ -576,11 +576,14 @@ IfConfigShowInterfaceInfo (
>      //
>      // Get Media State.
>      //
> -    NetLibDetectMedia (IfCb->NicHandle, &MediaPresent);
> -    if (!MediaPresent) {
> -      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media
> disconnected");
> +    if (EFI_SUCCESS == NetLibDetectMedia (IfCb->NicHandle,
> &MediaPresent)) {
> +      if (!MediaPresent) {
> +        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media
> disconnected");
> +      } else {
> +        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media
> present");
> +      }
>      } else {
> -      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media
> present");
> +      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_IFCONFIG_INFO_MEDIA_STATE), gShellNetwork1HiiHandle, L"Media
> state unknown");
>      }
> 
>      //
> --
> 2.7.4
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel