Revision: 14337
          http://edk2.svn.sourceforge.net/edk2/?rev=14337&view=rev
Author:   jcarsey
Date:     2013-05-09 16:18:58 +0000 (Thu, 09 May 2013)
Log Message:
-----------
ShellPkg: Update behavior for GetTime() errors.

Please find the attached patch that fixes the ShellPkg when gRT->GetTime() 
returns an error (eg: early UEFI platform bringup with a RTC controller that is 
not supported).
On some platforms, gRT->GetTime() might not return EFI_SUCCESS. The Shell must 
check the return status before to assume the returned time is valid.


Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <[email protected]>
Reviewed-by: Jaben Carsey <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
    trunk/edk2/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c

Modified: trunk/edk2/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c
===================================================================
--- trunk/edk2/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c   
2013-05-09 16:16:21 UTC (rev 14336)
+++ trunk/edk2/ShellPkg/Library/UefiShellLevel2CommandsLib/TimeDate.c   
2013-05-09 16:18:58 UTC (rev 14337)
@@ -221,7 +221,10 @@
         // get the current date
         //
         Status = gRT->GetTime(&TheTime, NULL);
-        ASSERT_EFI_ERROR(Status);
+        if (EFI_ERROR(Status)) {
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), 
gShellLevel2HiiHandle, L"gRT->GetTime", Status);
+          return (SHELL_DEVICE_ERROR);
+        }
 
         //
         // ShellPrintEx the date in SFO or regular format
@@ -312,7 +315,10 @@
   }
 
   Status = gRT->GetTime(&TheTime, NULL);
-  ASSERT_EFI_ERROR(Status);
+  if (EFI_ERROR(Status)) {
+    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), 
gShellLevel2HiiHandle, L"gRT->GetTime", Status);
+    return (SHELL_DEVICE_ERROR);
+  }
 
   if (TimeString != NULL) {
     TimeStringCopy = NULL;
@@ -420,7 +426,11 @@
     // check for "-?"
     //
     Status = gRT->GetTime(&TheTime, NULL);
-    ASSERT_EFI_ERROR(Status);
+    if (EFI_ERROR(Status)) {
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), 
gShellLevel2HiiHandle, L"gRT->GetTime", Status);
+      return (SHELL_DEVICE_ERROR);
+    }
+
     if (ShellCommandLineGetFlag(Package, L"-?")) {
       ASSERT(FALSE);
     } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
@@ -640,6 +650,7 @@
 
   Status = gRT->GetTime(&TheTime, NULL);
   if (EFI_ERROR(Status)) {
+    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), 
gShellLevel2HiiHandle, L"gRT->GetTime", Status);
     return (SHELL_DEVICE_ERROR);
   }
 
@@ -785,7 +796,10 @@
       // Get Current Time Zone Info
       //
       Status = gRT->GetTime(&TheTime, NULL);
-      ASSERT_EFI_ERROR(Status);
+      if (EFI_ERROR(Status)) {
+        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), 
gShellLevel2HiiHandle, L"gRT->GetTime", Status);
+        return (SHELL_DEVICE_ERROR);
+      }
 
       if (TheTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) {
         Found = FALSE;

Modified: trunk/edk2/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c
===================================================================
--- trunk/edk2/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c      
2013-05-09 16:16:21 UTC (rev 14336)
+++ trunk/edk2/ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c      
2013-05-09 16:18:58 UTC (rev 14337)
@@ -38,7 +38,11 @@
     return (EFI_ACCESS_DENIED);
   }
   Status = gRT->GetTime(&FileInfo->ModificationTime, NULL);
-  ASSERT_EFI_ERROR(Status);
+  if (EFI_ERROR(Status)) {
+    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), 
gShellLevel3HiiHandle, L"gRT->GetTime", Status);
+    return (SHELL_DEVICE_ERROR);
+  }
+
   CopyMem(&FileInfo->LastAccessTime, &FileInfo->ModificationTime, 
sizeof(EFI_TIME));
 
   Status = gEfiShellProtocol->SetFileInfo(Handle, FileInfo);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to