]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/Common/SimpleFileParsing.c
BaseTools/C/Common: Fix parameter format mismatch in scanf functions
[mirror_edk2.git] / BaseTools / Source / C / Common / SimpleFileParsing.c
index 52ec1291933c4cedc39adaf84cbe567893ec5f4d..868c6b794b99fa240a31e884131671b0e1b16f33 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
+Generic but simple file parsing routines.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2016, 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
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -9,14 +10,6 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
 \r
-Module Name:\r
-\r
-  SimpleFileParsing.c  \r
-\r
-Abstract:\r
-\r
-  Generic but simple file parsing routines.\r
-\r
 --*/\r
 \r
 #include <stdio.h>\r
@@ -24,6 +17,7 @@ Abstract:
 #include <stdlib.h>\r
 #include <ctype.h>\r
 \r
+#include "CommonLib.h"\r
 #include "EfiUtilityMsgs.h"\r
 #include "SimpleFileParsing.h"\r
 \r
@@ -328,7 +322,7 @@ Notes:
   }\r
 \r
   if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) {\r
-    if (isalnum (mGlobals.SourceFile.FileBufferPtr[Len])) {\r
+    if (isalnum ((int)mGlobals.SourceFile.FileBufferPtr[Len])) {\r
       return FALSE;\r
     }\r
 \r
@@ -536,33 +530,33 @@ Returns:
 \r
 --*/\r
 {\r
-  UINT32 Val;\r
+  int Val;\r
 \r
   SkipWhiteSpace (&mGlobals.SourceFile);\r
   if (EndOfFile (&mGlobals.SourceFile)) {\r
     return FALSE;\r
   }\r
 \r
-  if (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+  if (isdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {\r
     //\r
     // Check for hex value\r
     //\r
     if ((mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_0) && (mGlobals.SourceFile.FileBufferPtr[1] == T_CHAR_LC_X)) {\r
-      if (!isxdigit (mGlobals.SourceFile.FileBufferPtr[2])) {\r
+      if (!isxdigit ((int)mGlobals.SourceFile.FileBufferPtr[2])) {\r
         return FALSE;\r
       }\r
 \r
       mGlobals.SourceFile.FileBufferPtr += 2;\r
       sscanf (mGlobals.SourceFile.FileBufferPtr, "%x", &Val);\r
-      *Value = Val;\r
-      while (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+      *Value = (UINT32) Val;\r
+      while (isxdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {\r
         mGlobals.SourceFile.FileBufferPtr++;\r
       }\r
 \r
       return TRUE;\r
     } else {\r
       *Value = atoi (mGlobals.SourceFile.FileBufferPtr);\r
-      while (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+      while (isdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {\r
         mGlobals.SourceFile.FileBufferPtr++;\r
       }\r
 \r
@@ -634,7 +628,7 @@ Returns:
   // depth.\r
   //\r
   if (mGlobals.VerboseFile) {\r
-    fprintf (stdout, "%*cProcessing file '%s'\n", (INT32)NestDepth * 2, ' ', SourceFile->FileName);\r
+    fprintf (stdout, "%*cProcessing file '%s'\n", (int)NestDepth * 2, ' ', SourceFile->FileName);\r
     fprintf (stdout, "Parent source file = '%s'\n", ParentSourceFile->FileName);\r
   }\r
 \r
@@ -642,7 +636,7 @@ Returns:
   // Make sure we didn't exceed our maximum nesting depth\r
   //\r
   if (NestDepth > MAX_NEST_DEPTH) {\r
-    Error (NULL, 0, 3001, "Not Supported", "%s exceeeds max nesting depth (%d)", SourceFile->FileName, NestDepth);\r
+    Error (NULL, 0, 3001, "Not Supported", "%s exceeeds max nesting depth (%u)", SourceFile->FileName, (unsigned) NestDepth);\r
     Status = STATUS_ERROR;\r
     goto Finish;\r
   }\r
@@ -650,7 +644,7 @@ Returns:
   // Try to open the file locally, and if that fails try along our include paths.\r
   //\r
   strcpy (FoundFileName, SourceFile->FileName);\r
-  if ((SourceFile->Fptr = fopen (FoundFileName, "rb")) == NULL) {\r
+  if ((SourceFile->Fptr = fopen (LongFilePath (FoundFileName), "rb")) == NULL) {\r
     return STATUS_ERROR;\r
   }\r
   //\r
@@ -698,7 +692,7 @@ Returns:
   fseek (SourceFile->Fptr, 0, SEEK_END);\r
   SourceFile->FileSize = ftell (SourceFile->Fptr);\r
   if (mGlobals.VerboseFile) {\r
-    printf ("FileSize = %d (0x%X)\n", (INT32)SourceFile->FileSize, (UINT32)SourceFile->FileSize);\r
+    printf ("FileSize = %u (0x%X)\n", (unsigned) SourceFile->FileSize, (unsigned) SourceFile->FileSize);\r
   }\r
 \r
   fseek (SourceFile->Fptr, 0, SEEK_SET);\r
@@ -819,7 +813,7 @@ Returns:
     }\r
 \r
     printf ("'\n");\r
-    printf ("FileSize = %d (0x%X)\n", (INT32)SourceFile->FileSize, (UINT32)SourceFile->FileSize);\r
+    printf ("FileSize = %u (0x%X)\n", (unsigned)SourceFile->FileSize, (unsigned)SourceFile->FileSize);\r
     RewindFile (SourceFile);\r
   }\r
 }\r
@@ -1239,7 +1233,7 @@ GetHexChars (
   UINT32  Len;\r
   Len = 0;\r
   while (!EndOfFile (&mGlobals.SourceFile) && (BufferLen > 0)) {\r
-    if (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) {\r
+    if (isxdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {\r
       *Buffer = mGlobals.SourceFile.FileBufferPtr[0];\r
       Buffer++;\r
       Len++;\r
@@ -1282,7 +1276,7 @@ Returns:
 \r
 --*/\r
 {\r
-  UINT32        Value32;\r
+  INT32         Value32;\r
   UINT32        Index;\r
   FILE_POSITION FPos;\r
   CHAR8         TempString[20];\r