]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Refine code.
authorsfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 13 Aug 2010 02:47:22 +0000 (02:47 +0000)
committersfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 13 Aug 2010 02:47:22 +0000 (02:47 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10793 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/BaseLib/Ia32/DivS64x64Remainder.c
MdePkg/Library/BaseLib/String.c
MdePkg/Library/BaseSynchronizationLib/SynchronizationMsc.c
MdePkg/Library/PeiHobLib/HobLib.c

index e7fe9e28b65e40b2a450088d0f4a84be14598eb8..cca08ed3f62e80ceffa0dce2ca2121a303169158 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Integer division worker functions for Ia32.\r
 \r
-  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2010, 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
@@ -42,8 +42,8 @@ InternalMathDivRemS64x64 (
   INT64                             Quot;\r
 \r
   Quot = InternalMathDivRemU64x64 (\r
-           Dividend >= 0 ? Dividend : -Dividend,\r
-           Divisor >= 0 ? Divisor : -Divisor,\r
+           (UINT64) (Dividend >= 0 ? Dividend : -Dividend),\r
+           (UINT64) (Divisor >= 0 ? Divisor : -Divisor),\r
            (UINT64 *) Remainder\r
            );\r
   if (Remainder != NULL && Dividend < 0) {\r
index 7821520d2e860dc2f4bf3c6faba0cb6b5366fc7a..0b6a1957472fc169a59a741239cf7fe5c3372860 100644 (file)
 \r
 #include "BaseLibInternals.h"\r
 \r
-#define QUOTIENT_MAX_UINTN_DIVIDED_BY_10      ((UINTN) -1 / 10U)\r
-#define REMAINDER_MAX_UINTN_DIVIDED_BY_10    ((UINTN) -1 % 10U)\r
+#define QUOTIENT_MAX_UINTN_DIVIDED_BY_10      ((~((UINTN) 0)) / 10U)\r
+#define REMAINDER_MAX_UINTN_DIVIDED_BY_10    ((~((UINTN) 0)) % 10U)\r
 \r
-#define QUOTIENT_MAX_UINTN_DIVIDED_BY_16       ((UINTN) -1 / 16U)\r
-#define REMAINDER_MAX_UINTN_DIVIDED_BY_16     ((UINTN) -1 % 16U)\r
 \r
-#define QUOTIENT_MAX_UINT64_DIVIDED_BY_10      ((UINT64) -1 / 10U)\r
-#define REMAINDER_MAX_UINT64_DIVIDED_BY_10    ((UINT64) -1 % 10U)\r
+#define QUOTIENT_MAX_UINTN_DIVIDED_BY_16       ((~((UINTN) 0)) / 16U)\r
+#define REMAINDER_MAX_UINTN_DIVIDED_BY_16     ((~((UINTN) 0)) % 16U)\r
 \r
-#define QUOTIENT_MAX_UINT64_DIVIDED_BY_16      ((UINT64) -1 / 16U)\r
-#define REMAINDER_MAX_UINT64_DIVIDED_BY_16    ((UINT64) -1 % 16U)\r
+#define QUOTIENT_MAX_UINT64_DIVIDED_BY_10      ((~((UINT64) 0)) / 10U)\r
+#define REMAINDER_MAX_UINT64_DIVIDED_BY_10    ((~((UINT64) 0)) % 10U)\r
+\r
+#define QUOTIENT_MAX_UINT64_DIVIDED_BY_16      ((~((UINT64) 0)) / 16U)\r
+#define REMAINDER_MAX_UINT64_DIVIDED_BY_16    ((~((UINT64) 0)) % 16U)\r
 \r
 /**\r
   Copies one Null-terminated Unicode string to another Null-terminated Unicode\r
index 90524a1017ae7c927f9893c73ecb1bf296f42611..895acdc39fac47012e599f25b2c9cd667c857075 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implementation of synchronization functions.\r
 \r
-  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2010, 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
@@ -383,7 +383,7 @@ InterlockedCompareExchangePointer (
 {\r
   UINT8  SizeOfValue;\r
 \r
-  SizeOfValue = sizeof (*Value);\r
+  SizeOfValue = (UINT8) sizeof (*Value);\r
 \r
   switch (SizeOfValue) {\r
     case sizeof (UINT32):\r
index 8e1eddcce6fcfcddf628dccf8f4006c7d2033437..604cee996c8622f904f7f3cf6b8ce6de267ca98a 100644 (file)
@@ -277,7 +277,7 @@ BuildModuleHob (
   ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&\r
           ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));\r
 \r
   CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);\r
   Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;\r
@@ -319,7 +319,7 @@ BuildResourceDescriptorHob (
 {\r
   EFI_HOB_RESOURCE_DESCRIPTOR  *Hob;\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, (UINT16) sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));\r
 \r
   Hob->ResourceType      = ResourceType;\r
   Hob->ResourceAttribute = ResourceAttribute;\r
@@ -428,7 +428,7 @@ BuildFvHob (
 {\r
   EFI_HOB_FIRMWARE_VOLUME  *Hob;\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, (UINT16) sizeof (EFI_HOB_FIRMWARE_VOLUME));\r
 \r
   Hob->BaseAddress = BaseAddress;\r
   Hob->Length      = Length;\r
@@ -460,7 +460,7 @@ BuildFv2Hob (
 {\r
   EFI_HOB_FIRMWARE_VOLUME2  *Hob;\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV2, sizeof (EFI_HOB_FIRMWARE_VOLUME2));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV2, (UINT16) sizeof (EFI_HOB_FIRMWARE_VOLUME2));\r
 \r
   Hob->BaseAddress = BaseAddress;\r
   Hob->Length      = Length;\r
@@ -491,7 +491,7 @@ BuildCvHob (
 {\r
   EFI_HOB_UEFI_CAPSULE  *Hob;\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_UEFI_CAPSULE, sizeof (EFI_HOB_UEFI_CAPSULE));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_UEFI_CAPSULE, (UINT16) sizeof (EFI_HOB_UEFI_CAPSULE));\r
 \r
   Hob->BaseAddress  = BaseAddress;\r
   Hob->Length       = Length;\r
@@ -519,7 +519,7 @@ BuildCpuHob (
 {\r
   EFI_HOB_CPU  *Hob;\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, (UINT16) sizeof (EFI_HOB_CPU));\r
 \r
   Hob->SizeOfMemorySpace = SizeOfMemorySpace;\r
   Hob->SizeOfIoSpace     = SizeOfIoSpace;\r
@@ -555,7 +555,7 @@ BuildStackHob (
   ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r
           ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));\r
 \r
   CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid);\r
   Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
@@ -595,7 +595,7 @@ BuildBspStoreHob (
   ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r
           ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r
 \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE));\r
 \r
   CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocBspStoreGuid);\r
   Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r
@@ -635,7 +635,7 @@ BuildMemoryAllocationHob (
   ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&\r
           ((Length & (EFI_PAGE_SIZE - 1)) == 0));\r
   \r
-  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));\r
+  Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION));\r
   \r
   ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));\r
   Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;\r