From 120fd64781d2c0810ce41c0d4a6ecd348ff7bc49 Mon Sep 17 00:00:00 2001 From: Meenakshi Aggarwal Date: Thu, 5 Oct 2017 11:54:45 +0530 Subject: [PATCH] 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 Reviewed-by: Ruiyu Ni Reviewed-by: Jaben Carsey --- .../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 4db07b207d..082ab72fed 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.39.2