From: Jaben Carsey Date: Thu, 5 Jun 2014 22:02:12 +0000 (+0000) Subject: ShellPkg: fix Comp command output X-Git-Tag: edk2-stable201903~11432 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=33eb033f8609d960ccf6c3ad9abb0acab5e1a08f ShellPkg: fix Comp command output 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 Reviewed-by: Tapan Shah Reviewed-by: Erik Bjorge git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15558 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c index 01ef1997b2..f4e20a4e3a 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c @@ -1,7 +1,7 @@ /** @file Main file for Comp shell Debug1 function. - Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -50,6 +50,7 @@ ShellCommandRunComp ( CHAR16 *FileName1; CHAR16 *FileName2; CONST CHAR16 *TempParam; + UINTN ErrorAddress; ErrorCount = 0; ShellStatus = SHELL_SUCCESS; @@ -136,12 +137,18 @@ ShellCommandRunComp ( Status = gEfiShellProtocol->ReadFile(FileHandle2, &DataSizeFromFile2, &DataFromFile2); ASSERT_EFI_ERROR(Status); if (DataFromFile1 != DataFromFile2) { + ErrorAddress = LoopVar; ADF_File11 = 0; ADF_File12 = 0; ADF_File13 = 0; ADF_File21 = 0; ADF_File22 = 0; ADF_File23 = 0; + + // + // Now check the next 3 bytes if possible. This will make output + // cleaner when there are a sequence of differences. + // if (LoopVar + 1 < Size1) { LoopVar++; DataSizeFromFile1 = 1; @@ -169,6 +176,10 @@ ShellCommandRunComp ( } } } + + // + // Print out based on highest of the 4 bytes that are different. + // if (ADF_File13 != ADF_File23) { ShellPrintHiiEx( -1, @@ -178,11 +189,11 @@ ShellCommandRunComp ( gShellDebug1HiiHandle, ++ErrorCount, FileName1, - LoopVar, + ErrorAddress, DataFromFile1, ADF_File11, ADF_File12, ADF_File13, DataFromFile1, ADF_File11, ADF_File12, ADF_File13, FileName2, - LoopVar, + ErrorAddress, DataFromFile2, ADF_File21, ADF_File22, ADF_File23, DataFromFile2, ADF_File21, ADF_File22, ADF_File23 ); @@ -195,11 +206,11 @@ ShellCommandRunComp ( gShellDebug1HiiHandle, ++ErrorCount, FileName1, - LoopVar, + ErrorAddress, DataFromFile1, ADF_File11, ADF_File12, DataFromFile1, ADF_File11, ADF_File12, FileName2, - LoopVar, + ErrorAddress, DataFromFile2, ADF_File21, ADF_File22, DataFromFile2, ADF_File21, ADF_File22 ); @@ -212,11 +223,11 @@ ShellCommandRunComp ( gShellDebug1HiiHandle, ++ErrorCount, FileName1, - LoopVar, + ErrorAddress, DataFromFile1, ADF_File11, DataFromFile1, ADF_File11, FileName2, - LoopVar, + ErrorAddress, DataFromFile2, ADF_File21, DataFromFile2, ADF_File21 ); @@ -229,11 +240,11 @@ ShellCommandRunComp ( gShellDebug1HiiHandle, ++ErrorCount, FileName1, - LoopVar, + ErrorAddress, DataFromFile1, DataFromFile1, FileName2, - LoopVar, + ErrorAddress, DataFromFile2, DataFromFile2 );