]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: fix Comp command output
authorJaben Carsey <Jaben.carsey@intel.com>
Thu, 5 Jun 2014 22:02:12 +0000 (22:02 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 5 Jun 2014 22:02:12 +0000 (22:02 +0000)
The comp command was potentially displaying the incorrect offset into the file due to comparing 3 extra bytes for difference groups.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <Jaben.carsey@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hp.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15558 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c

index 01ef1997b2dfe577c483f3599f0e8ef9d35239dc..f4e20a4e3a902b93336b84ceb8965713d56619fa 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for Comp shell Debug1 function.\r
 \r
-  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -50,6 +50,7 @@ ShellCommandRunComp (
   CHAR16              *FileName1;\r
   CHAR16              *FileName2;\r
   CONST CHAR16        *TempParam;\r
+  UINTN               ErrorAddress;\r
 \r
   ErrorCount          = 0;\r
   ShellStatus         = SHELL_SUCCESS;\r
@@ -136,12 +137,18 @@ ShellCommandRunComp (
           Status = gEfiShellProtocol->ReadFile(FileHandle2, &DataSizeFromFile2, &DataFromFile2);\r
           ASSERT_EFI_ERROR(Status);\r
           if (DataFromFile1 != DataFromFile2) {\r
+            ErrorAddress = LoopVar;\r
             ADF_File11 = 0;\r
             ADF_File12 = 0;\r
             ADF_File13 = 0;\r
             ADF_File21 = 0;\r
             ADF_File22 = 0;\r
             ADF_File23 = 0;\r
+\r
+            //\r
+            // Now check the next 3 bytes if possible.  This will make output\r
+            // cleaner when there are a sequence of differences.\r
+            //\r
             if (LoopVar + 1 < Size1) {\r
               LoopVar++;\r
               DataSizeFromFile1 = 1;\r
@@ -169,6 +176,10 @@ ShellCommandRunComp (
                 }\r
               }\r
             }\r
+\r
+            //\r
+            // Print out based on highest of the 4 bytes that are different.\r
+            //\r
             if (ADF_File13 != ADF_File23) {\r
               ShellPrintHiiEx(\r
                 -1,\r
@@ -178,11 +189,11 @@ ShellCommandRunComp (
                 gShellDebug1HiiHandle,\r
                 ++ErrorCount,\r
                 FileName1,\r
-                LoopVar,\r
+                ErrorAddress,\r
                 DataFromFile1, ADF_File11, ADF_File12, ADF_File13,\r
                 DataFromFile1, ADF_File11, ADF_File12, ADF_File13,\r
                 FileName2,\r
-                LoopVar,\r
+                ErrorAddress,\r
                 DataFromFile2, ADF_File21, ADF_File22, ADF_File23,\r
                 DataFromFile2, ADF_File21, ADF_File22, ADF_File23\r
                );\r
@@ -195,11 +206,11 @@ ShellCommandRunComp (
                 gShellDebug1HiiHandle,\r
                 ++ErrorCount,\r
                 FileName1,\r
-                LoopVar,\r
+                ErrorAddress,\r
                 DataFromFile1, ADF_File11, ADF_File12,\r
                 DataFromFile1, ADF_File11, ADF_File12,\r
                 FileName2,\r
-                LoopVar,\r
+                ErrorAddress,\r
                 DataFromFile2, ADF_File21, ADF_File22,\r
                 DataFromFile2, ADF_File21, ADF_File22\r
                );\r
@@ -212,11 +223,11 @@ ShellCommandRunComp (
                 gShellDebug1HiiHandle,\r
                 ++ErrorCount,\r
                 FileName1,\r
-                LoopVar,\r
+                ErrorAddress,\r
                 DataFromFile1, ADF_File11,\r
                 DataFromFile1, ADF_File11,\r
                 FileName2,\r
-                LoopVar,\r
+                ErrorAddress,\r
                 DataFromFile2, ADF_File21,\r
                 DataFromFile2, ADF_File21\r
                );\r
@@ -229,11 +240,11 @@ ShellCommandRunComp (
                 gShellDebug1HiiHandle,\r
                 ++ErrorCount,\r
                 FileName1,\r
-                LoopVar,\r
+                ErrorAddress,\r
                 DataFromFile1,\r
                 DataFromFile1,\r
                 FileName2,\r
-                LoopVar,\r
+                ErrorAddress,\r
                 DataFromFile2,\r
                 DataFromFile2\r
                );\r