]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FatPkg/EnhancedFatDxe/Hash.c
FatPkg: Refine casting expression result to bigger size
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / Hash.c
index c0fbab2f1e2653e30596a65ea404d9917dda57dd..5a9bbda754319644858ed8eb12afee98da94ad08 100644 (file)
@@ -1,7 +1,8 @@
-/*++\r
+/** @file\r
+  Hash table operations.\r
 \r
-Copyright (c) 2005 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials are licensed and made available\r
+Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available\r
 under the terms and conditions of the BSD License which accompanies this\r
 distribution. The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -9,97 +10,73 @@ 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
+**/\r
 \r
-Module Name:\r
-\r
-  Hash.c\r
-\r
-Abstract:\r
+#include "Fat.h"\r
 \r
-  Hash table operations\r
+/**\r
 \r
-Revision History\r
+  Get hash value for long name.\r
 \r
---*/\r
+  @param  LongNameString        - The long name string to be hashed.\r
 \r
-#include "Fat.h"\r
+  @return HashValue.\r
 \r
+**/\r
 STATIC\r
 UINT32\r
 FatHashLongName (\r
   IN CHAR16   *LongNameString\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get hash value for long name.\r
-\r
-Arguments:\r
-\r
-  LongNameString        - The long name string to be hashed.\r
-\r
-Returns:\r
-\r
-  HashValue.\r
-\r
---*/\r
 {\r
   UINT32  HashValue;\r
   CHAR16  UpCasedLongFileName[EFI_PATH_STRING_LENGTH];\r
-  StrCpy (UpCasedLongFileName, LongNameString);\r
+  StrnCpyS (\r
+    UpCasedLongFileName,\r
+    ARRAY_SIZE (UpCasedLongFileName),\r
+    LongNameString,\r
+    ARRAY_SIZE (UpCasedLongFileName) - 1\r
+    );\r
   FatStrUpr (UpCasedLongFileName);\r
   gBS->CalculateCrc32 (UpCasedLongFileName, StrSize (UpCasedLongFileName), &HashValue);\r
   return (HashValue & HASH_TABLE_MASK);\r
 }\r
 \r
-STATIC\r
-UINT32\r
-FatHashShortName (\r
-  IN CHAR8   *ShortNameString\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Get hash value for short name.\r
 \r
-Arguments:\r
+  @param  ShortNameString       - The short name string to be hashed.\r
 \r
-  ShortNameString       - The short name string to be hashed.\r
+  @return HashValue\r
 \r
-Returns:\r
-\r
-  HashValue\r
-\r
---*/\r
+**/\r
+STATIC\r
+UINT32\r
+FatHashShortName (\r
+  IN CHAR8   *ShortNameString\r
+  )\r
 {\r
   UINT32  HashValue;\r
   gBS->CalculateCrc32 (ShortNameString, FAT_NAME_LEN, &HashValue);\r
   return (HashValue & HASH_TABLE_MASK);\r
 }\r
 \r
-FAT_DIRENT **\r
-FatLongNameHashSearch (\r
-  IN FAT_ODIR       *ODir,\r
-  IN CHAR16         *LongNameString\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Search the long name hash table for the directory entry.\r
 \r
-Arguments:\r
-\r
-  ODir                  - The directory to be searched.\r
-  LongNameString        - The long name string to search.\r
-\r
-Returns:\r
+  @param  ODir                  - The directory to be searched.\r
+  @param  LongNameString        - The long name string to search.\r
 \r
-  The previous long name hash node of the directory entry.\r
+  @return The previous long name hash node of the directory entry.\r
 \r
---*/\r
+**/\r
+FAT_DIRENT **\r
+FatLongNameHashSearch (\r
+  IN FAT_ODIR       *ODir,\r
+  IN CHAR16         *LongNameString\r
+  )\r
 {\r
   FAT_DIRENT  **PreviousHashNode;\r
   for (PreviousHashNode   = &ODir->LongNameHashTable[FatHashLongName (LongNameString)];\r
@@ -114,27 +91,21 @@ Returns:
   return PreviousHashNode;\r
 }\r
 \r
-FAT_DIRENT **\r
-FatShortNameHashSearch (\r
-  IN FAT_ODIR      *ODir,\r
-  IN CHAR8         *ShortNameString\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Search the short name hash table for the directory entry.\r
 \r
-Arguments:\r
-\r
-  ODir                  - The directory to be searched.\r
-  ShortNameString       - The short name string to search.\r
+  @param  ODir                  - The directory to be searched.\r
+  @param  ShortNameString       - The short name string to search.\r
 \r
-Returns:\r
+  @return The previous short name hash node of the directory entry.\r
 \r
-  The previous short name hash node of the directory entry.\r
-\r
---*/\r
+**/\r
+FAT_DIRENT **\r
+FatShortNameHashSearch (\r
+  IN FAT_ODIR      *ODir,\r
+  IN CHAR8         *ShortNameString\r
+  )\r
 {\r
   FAT_DIRENT  **PreviousHashNode;\r
   for (PreviousHashNode   = &ODir->ShortNameHashTable[FatHashShortName (ShortNameString)];\r
@@ -149,27 +120,19 @@ Returns:
   return PreviousHashNode;\r
 }\r
 \r
+/**\r
+\r
+  Insert directory entry to hash table.\r
+\r
+  @param  ODir                  - The parent directory.\r
+  @param  DirEnt                - The directory entry node.\r
+\r
+**/\r
 VOID\r
 FatInsertToHashTable (\r
   IN FAT_ODIR     *ODir,\r
   IN FAT_DIRENT   *DirEnt\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Insert directory entry to hash table.\r
-\r
-Arguments:\r
-\r
-  ODir                  - The parent directory.\r
-  DirEnt                - The directory entry node.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   FAT_DIRENT  **HashTable;\r
   UINT32      HashTableIndex;\r
@@ -190,27 +153,19 @@ Returns:
   HashTable[HashTableIndex]     = DirEnt;\r
 }\r
 \r
+/**\r
+\r
+  Delete directory entry from hash table.\r
+\r
+  @param  ODir                  - The parent directory.\r
+  @param  DirEnt                - The directory entry node.\r
+\r
+**/\r
 VOID\r
 FatDeleteFromHashTable (\r
   IN FAT_ODIR     *ODir,\r
   IN FAT_DIRENT   *DirEnt\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Delete directory entry from hash table.\r
-\r
-Arguments:\r
-\r
-  ODir                  - The parent directory.\r
-  DirEnt                - The directory entry node.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   *FatShortNameHashSearch (ODir, DirEnt->Entry.FileName) = DirEnt->ShortNameForwardLink;\r
   *FatLongNameHashSearch (ODir, DirEnt->FileString)      = DirEnt->LongNameForwardLink;\r