]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c
ShellPkg/comp: return NOT_EQUAL when compared files are different
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / Comp.c
index 62b59d7973701250cbc1a1cef82e8769fb5a47e3..7c232d01c7487be30dab4bbfd53a16f7b0c6cbb3 100644 (file)
@@ -2,7 +2,7 @@
   Main file for Comp shell Debug1 function.\r
 \r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2018, 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
@@ -30,7 +30,8 @@ typedef enum {
 /**\r
   Function to print differnt point data.\r
 \r
-  @param[in]  FileName        File name\r
+  @param[in]  FileName        File name.\r
+  @param[in]  FileTag         File tag name.\r
   @param[in]  Buffer          Data buffer to be printed.\r
   @param[in]  BufferSize      Size of the data to be printed.\r
   @param[in]  Address         Address of the differnt point.\r
@@ -40,24 +41,25 @@ typedef enum {
 VOID\r
 PrintDifferentPoint(\r
   CONST CHAR16  *FileName,\r
+  CHAR16        *FileTag,\r
   UINT8         *Buffer,\r
-  UINT64        DataSize,\r
+  UINT64        BufferSize,\r
   UINTN         Address,\r
-  UINT64        BufferSize\r
+  UINT64        DifferentBytes\r
   )\r
 {\r
   UINTN Index;\r
 \r
-  ShellPrintEx (-1, -1, L"%s: %s\r\n  %08x:", L"File1", FileName, Address);\r
+  ShellPrintEx (-1, -1, L"%s: %s\r\n  %08x:", FileTag, FileName, Address);\r
 \r
   //\r
   // Print data in hex-format.\r
   //\r
-  for (Index = 0; Index < DataSize; Index++) {\r
+  for (Index = 0; Index < BufferSize; Index++) {\r
     ShellPrintEx (-1, -1, L" %02x", Buffer[Index]);\r
   }\r
 \r
-  if (DataSize < BufferSize) {\r
+  if (BufferSize < DifferentBytes) {\r
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_COMP_END_OF_FILE), gShellDebug1HiiHandle);\r
   }\r
 \r
@@ -66,7 +68,7 @@ PrintDifferentPoint(
   //\r
   // Print data in char-format.\r
   //\r
-  for (Index = 0; Index < DataSize; Index++) {\r
+  for (Index = 0; Index < BufferSize; Index++) {\r
     if (Buffer[Index] >= 0x20 && Buffer[Index] <= 0x7E) {\r
       ShellPrintEx (-1, -1, L"%c", Buffer[Index]);\r
     } else {\r
@@ -135,6 +137,7 @@ ShellCommandRunComp (
   InsertPosition1     = 0;\r
   InsertPosition2     = 0;\r
   TempAddress         = 0;\r
+  DiffPointAddress    = 0;\r
 \r
   //\r
   // initialize the shell lib (we must be in non-auto-init...)\r
@@ -301,8 +304,8 @@ ShellCommandRunComp (
              ) {\r
 \r
             ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_COMP_DIFFERENCE_POINT), gShellDebug1HiiHandle, ++DiffPointNumber);\r
-            PrintDifferentPoint (FileName1, DataFromFile1, InsertPosition1, DiffPointAddress, DifferentBytes);\r
-            PrintDifferentPoint (FileName2, DataFromFile2, InsertPosition2, DiffPointAddress, DifferentBytes);\r
+            PrintDifferentPoint (FileName1, L"File1", DataFromFile1, InsertPosition1, DiffPointAddress, DifferentBytes);\r
+            PrintDifferentPoint (FileName2, L"File2", DataFromFile2, InsertPosition2, DiffPointAddress, DifferentBytes);\r
 \r
             //\r
             // One of two buffuers is empty, it means this is the last different point.\r
@@ -353,6 +356,7 @@ ShellCommandRunComp (
         if (DiffPointNumber == 0) {\r
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_PASS), gShellDebug1HiiHandle);\r
         } else {\r
+          ShellStatus = SHELL_NOT_EQUAL;\r
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_COMP_FOOTER_FAIL), gShellDebug1HiiHandle);\r
         }\r
       }\r