- Use MAXUINT, MAXULONG, MAXDWORD, MAXULONGLONG and MAXULONGLONG instead of ~0 or...
authorStefan Ginsberg <stefanginsberg@gmail.com>
Sun, 27 Sep 2009 20:07:43 +0000 (20:07 +0000)
committerStefan Ginsberg <stefanginsberg@gmail.com>
Sun, 27 Sep 2009 20:07:43 +0000 (20:07 +0000)
- bintype.c: Use INVALID_SET_FILE_POINTER instead of (DWORD)-1.
- irp.c: KsGetNodeIdFromIrp returns KSFILTER_NODE (which is -1).
- basetsd.h: Add missing MAXUINT and MAXULONGLONG.
- typedefs.h: Add MAXULONG for mkhive.
- elf.inc.h and pe.c: Remove incorrect and unneeded MAXULONG define.

svn path=/trunk/; revision=43192

46 files changed:
reactos/boot/freeldr/freeldr/arch/powerpc/mboot.c
reactos/boot/freeldr/freeldr/debug.c
reactos/boot/freeldr/freeldr/fs/ntfs.c
reactos/boot/freeldr/freeldr/reactos/imageldr.c
reactos/dll/cpl/console/colors.c
reactos/dll/cpl/console/layout.c
reactos/dll/cpl/main/mouse.c
reactos/dll/win32/kernel32/debug/debugger.c
reactos/dll/win32/kernel32/file/bintype.c
reactos/dll/win32/kernel32/file/file.c
reactos/dll/win32/kernel32/misc/error.c
reactos/dll/win32/opengl32/opengl32.c
reactos/drivers/bus/pci/pdo.c
reactos/drivers/filesystems/msfs/finfo.c
reactos/drivers/ksfilter/ks/allocators.c
reactos/drivers/ksfilter/ks/irp.c
reactos/drivers/ksfilter/ks/topology.c
reactos/drivers/serial/serial/serial.h
reactos/drivers/wdm/audio/drivers/CMIDriver/mintopo.cpp
reactos/drivers/wdm/audio/filters/splitter/splitter.c
reactos/drivers/wdm/audio/legacy/stream/pnp.c
reactos/drivers/wdm/audio/legacy/wdmaud/control.c
reactos/drivers/wdm/audio/legacy/wdmaud/mixer.c
reactos/hal/halppc/generic/dma.c
reactos/hal/halx86/generic/dma.c
reactos/include/host/typedefs.h
reactos/include/psdk/basetsd.h
reactos/lib/cmlib/hivedata.h
reactos/lib/rtl/bitmap.c
reactos/lib/rtl/debug.c
reactos/lib/rtl/heap.c
reactos/lib/rtl/rangelist.c
reactos/lib/rtl/registry.c
reactos/lib/rtl/unicode.c
reactos/ntoskrnl/ex/init.c
reactos/ntoskrnl/fstub/disksup.c
reactos/ntoskrnl/io/iomgr/drvrlist.c
reactos/ntoskrnl/kdbg/kdb.c
reactos/ntoskrnl/kdbg/kdb_cli.c
reactos/ntoskrnl/ke/i386/irqobj.c
reactos/ntoskrnl/mm/elf.inc.h
reactos/ntoskrnl/mm/i386/pagepae.c
reactos/ntoskrnl/mm/pe.c
reactos/ntoskrnl/po/power.c
reactos/ntoskrnl/ps/psmgr.c
reactos/ntoskrnl/ps/query.c

index feef98a..a7c2f39 100644 (file)
@@ -815,7 +815,7 @@ FrLdrCloseModule(ULONG_PTR ModuleBase,
     if (ModuleData) {
 
         /* Make sure this is the right module and that it hasn't been closed */
-        if ((ModuleBase == ModuleData->ModStart) && (ModuleData->ModEnd == (ULONG_PTR)-1)) {
+        if ((ModuleBase == ModuleData->ModStart) && (ModuleData->ModEnd == MAXULONG_PTR)) {
 
             /* Close the Module */
             ModuleData->ModEnd = ModuleData->ModStart + ModuleSize;
index e0088d1..f0bb431 100644 (file)
@@ -311,7 +311,7 @@ MsgBoxPrint(const char *Format, ...)
        Length = _vsnprintf(Buffer, 512, Format, ap);
 
        /* Check if we went past the buffer */
-       if (Length == (ULONG)-1)
+       if (Length == MAXULONG)
        {
                /* Terminate it if we went over-board */
                Buffer[sizeof(Buffer) - 1] = '\n';
index b961794..8373e42 100644 (file)
@@ -292,7 +292,7 @@ static ULONGLONG NtfsReadAttribute(PNTFS_VOLUME_INFO Volume, PNTFS_ATTR_CONTEXT
         {
             CurrentOffset += DataRunLength * Volume->ClusterSize;
             DataRun = NtfsDecodeRun(DataRun, &DataRunOffset, &DataRunLength);
-            if (DataRunLength != (ULONGLONG)-1)
+            if (DataRunLength != MAXULONGLONG)
             {
                 DataRunStartLCN = LastLCN + DataRunOffset;
                 LastLCN = DataRunStartLCN;
index 1a3af5e..1e50115 100644 (file)
@@ -177,7 +177,7 @@ FrLdrCloseModule(ULONG_PTR ModuleBase,
     if (ModuleData) {
         
         /* Make sure this is the right module and that it hasn't been closed */
-        if ((ModuleBase == ModuleData->ModStart) && (ModuleData->ModEnd == (ULONG_PTR)-1)) {
+        if ((ModuleBase == ModuleData->ModStart) && (ModuleData->ModEnd == MAXULONG_PTR)) {
             
             /* Close the Module */
             ModuleData->ModEnd = ModuleData->ModStart + ModuleSize;
index 81587a0..f7dde52 100644 (file)
@@ -44,9 +44,9 @@ ColorsProc(
        LPNMUPDOWN lpnmud;
     LPPSHNOTIFY lppsn;
        LPDRAWITEMSTRUCT drawItem;
-       DWORD red = -1;
-       DWORD green = -1;
-       DWORD blue = -1;
+       DWORD red = MAXDWORD;
+       DWORD green = MAXDWORD;
+       DWORD blue = MAXDWORD;
 
        pConInfo = (PConsoleInfo) GetWindowLongPtr(hwndDlg, DWLP_USER);
 
@@ -116,7 +116,7 @@ ColorsProc(
                                break;
                        }
 
-                       if (red == (DWORD)-1)
+                       if (red == MAXDWORD)
                        {
                                red = SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_COLOR_RED), UDM_GETPOS, 0, 0);
                                if (HIWORD(red))
@@ -127,7 +127,7 @@ ColorsProc(
                                red = LOBYTE(red);
                        }
 
-                       if (green == (DWORD)-1)
+                       if (green == MAXDWORD)
                        {
                                green = SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_COLOR_GREEN), UDM_GETPOS, 0, 0);
                                if (HIWORD(green))
@@ -138,7 +138,7 @@ ColorsProc(
                                green = LOBYTE(green);
                        }
 
-                       if (blue == (DWORD)-1)
+                       if (blue == MAXDWORD)
                        {
                                blue = SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_COLOR_BLUE), UDM_GETPOS, 0, 0);
                                if (HIWORD(blue))
index 3d6df8b..592ba61 100644 (file)
@@ -160,7 +160,7 @@ LayoutProc(
                        SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_LEFT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(xres, 0));
                        SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_TOP), UDM_SETRANGE, 0, (LPARAM)MAKELONG(yres, 0));
 
-                       if (pConInfo->WindowPosition != (DWORD)-1)
+                       if (pConInfo->WindowPosition != MAXDWORD)
                        {
                                SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT, LOWORD(pConInfo->WindowPosition), FALSE);
                                SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_TOP, HIWORD(pConInfo->WindowPosition), FALSE);
index 684ccee..0c4f76d 100644 (file)
@@ -968,7 +968,7 @@ OnDrawItem(UINT idCtl,
                    GetSysColor(COLOR_WINDOWTEXT));
     }
 
-    if (lpdis->itemID != (UINT)-1)
+    if (lpdis->itemID != MAXUINT)
     {
         CopyRect(&rc, &lpdis->rcItem);
         rc.left += 5;
index 07e7ce7..83c8a8d 100644 (file)
@@ -232,7 +232,7 @@ ProcessIdToHandle(IN DWORD dwProcessId)
     CLIENT_ID ClientId;
 
     /* If we don't have a PID, look it up */
-    if (dwProcessId == (DWORD)-1) dwProcessId = (DWORD)CsrGetProcessId();
+    if (dwProcessId == MAXDWORD) dwProcessId = (DWORD)CsrGetProcessId();
 
     /* Open a handle to the process */
     ClientId.UniqueThread = NULL;
index ac992e2..98d8f67 100644 (file)
@@ -38,7 +38,7 @@ InternalIsOS2OrOldWin(HANDLE hFile, IMAGE_DOS_HEADER *mz, IMAGE_OS2_HEADER *ne)
   CurPos = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
 
   /* read modref table */
-  if((SetFilePointer(hFile, mz->e_lfanew + ne->ne_modtab, NULL, FILE_BEGIN) == (DWORD)-1) ||
+  if((SetFilePointer(hFile, mz->e_lfanew + ne->ne_modtab, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) ||
      (!(modtab = HeapAlloc(GetProcessHeap(), 0, ne->ne_cmod * sizeof(WORD)))) ||
      (!(ReadFile(hFile, modtab, ne->ne_cmod * sizeof(WORD), &Read, NULL))) ||
      (Read != (DWORD)ne->ne_cmod * sizeof(WORD)))
@@ -47,7 +47,7 @@ InternalIsOS2OrOldWin(HANDLE hFile, IMAGE_DOS_HEADER *mz, IMAGE_OS2_HEADER *ne)
   }
 
   /* read imported names table */
-  if((SetFilePointer(hFile, mz->e_lfanew + ne->ne_imptab, NULL, FILE_BEGIN) == (DWORD)-1) ||
+  if((SetFilePointer(hFile, mz->e_lfanew + ne->ne_imptab, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) ||
      (!(nametab = HeapAlloc(GetProcessHeap(), 0, ne->ne_enttab - ne->ne_imptab))) ||
      (!(ReadFile(hFile, nametab, ne->ne_enttab - ne->ne_imptab, &Read, NULL))) ||
      (Read != (DWORD)ne->ne_enttab - ne->ne_imptab))
@@ -100,7 +100,7 @@ InternalGetBinaryType(HANDLE hFile)
   char magic[4];
   DWORD Read;
 
-  if((SetFilePointer(hFile, 0, NULL, FILE_BEGIN) == (DWORD)-1) ||
+  if((SetFilePointer(hFile, 0, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) ||
      (!ReadFile(hFile, &Header, sizeof(Header), &Read, NULL) ||
       (Read != sizeof(Header))))
   {
@@ -143,7 +143,7 @@ InternalGetBinaryType(HANDLE hFile)
      * This will tell us if there is more header information
      * to read or not.
      */
-    if((SetFilePointer(hFile, Header.mz.e_lfanew, NULL, FILE_BEGIN) == (DWORD)-1) ||
+    if((SetFilePointer(hFile, Header.mz.e_lfanew, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) ||
        (!ReadFile(hFile, magic, sizeof(magic), &Read, NULL) ||
         (Read != sizeof(magic))))
     {
index b19b2ac..86ef5ad 100644 (file)
@@ -534,7 +534,7 @@ SetFilePointer(HANDLE hFile,
         *lpDistanceToMoveHigh = FilePosition.CurrentByteOffset.u.HighPart;
      }
 
-   if (FilePosition.CurrentByteOffset.u.LowPart == (DWORD)-1)
+   if (FilePosition.CurrentByteOffset.u.LowPart == MAXDWORD)
      {
        /* The value of -1 is valid here, especially when the new
           file position is greater than 4 GB. Since NtSetInformationFile
index ce8eca6..9149953 100644 (file)
@@ -75,7 +75,7 @@ Beep (DWORD dwFreq, DWORD dwDuration)
 
             /* do an alertable wait if necessary */
             if (NT_SUCCESS(Status) &&
-                (dwFreq != 0x0 || dwDuration != 0x0) && dwDuration != (DWORD)-1)
+                (dwFreq != 0x0 || dwDuration != 0x0) && dwDuration != MAXDWORD)
             {
                 SleepEx(dwDuration,
                         TRUE);
index 49f4cc5..2dd3312 100644 (file)
@@ -20,8 +20,8 @@ static DWORD OPENGL32_RegGetDriverInfo( LPCWSTR driver, GLDRIVERDATA *icd );
 
 
 /* global vars */
-/* Do not assume it have the free value -1 set, any value can be in here */
-DWORD OPENGL32_tls = -1;
+/* Do not assume it have the free value MAXDWORD set, any value can be in here */
+DWORD OPENGL32_tls = MAXDWORD;
 GLPROCESSDATA OPENGL32_processdata;
 
 
@@ -103,7 +103,7 @@ OPENGL32_ProcessAttach( void )
                                    TRUE /* bInheritHandle */ };
 
     OPENGL32_tls = TlsAlloc();
-    if ((DWORD)-1 == OPENGL32_tls)
+    if (OPENGL32_tls == MAXDWORD)
         return FALSE;
 
     memset( &OPENGL32_processdata, 0, sizeof (OPENGL32_processdata) );
@@ -179,7 +179,7 @@ OPENGL32_ProcessDetach( void )
         CloseHandle( OPENGL32_processdata.dcdata_mutex );
 
     /* free TLS */
-    if (OPENGL32_tls != (DWORD)-1)
+    if (OPENGL32_tls != MAXDWORD)
         TlsFree(OPENGL32_tls);
 }
 
index fb571c3..f19e45c 100644 (file)
@@ -176,7 +176,7 @@ PdoQueryCapabilities(
 
   DeviceCapabilities->UniqueID = FALSE;
   DeviceCapabilities->Address = ((DeviceNumber << 16) & 0xFFFF0000) + (FunctionNumber & 0xFFFF);
-  DeviceCapabilities->UINumber = (ULONG)-1; /* FIXME */
+  DeviceCapabilities->UINumber = MAXULONG; /* FIXME */
 
   return STATUS_SUCCESS;
 }
@@ -213,7 +213,7 @@ PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension,
   *Base = BaseValue;
 
   /* Set magic value */
-  NewValue = (ULONG)-1;
+  NewValue = MAXULONG;
   Size= HalSetBusDataByOffset(PCIConfiguration,
                               DeviceExtension->PciDevice->BusNumber,
                               DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
index 751afdc..2084395 100644 (file)
@@ -16,8 +16,8 @@
 
 #undef MAILSLOT_NO_MESSAGE
 #undef MAILSLOT_WAIT_FOREVER
-#define MAILSLOT_NO_MESSAGE    ((ULONG)-1)
-#define MAILSLOT_WAIT_FOREVER  ((ULONG)-1)
+#define MAILSLOT_NO_MESSAGE   MAXULONG
+#define MAILSLOT_WAIT_FOREVER MAXULONG
 
 
 /* FUNCTIONS *****************************************************************/
index d8c4ef3..3040a04 100644 (file)
@@ -668,7 +668,7 @@ KsValidateAllocatorFramingEx(
 
     /* verify framing */
     if ((Framing->FramingItem[0].Flags & KSALLOCATOR_FLAG_PARTIAL_READ_SUPPORT) &&
-         Framing->OutputCompression.RatioNumerator != (ULONG)-1 &&
+         Framing->OutputCompression.RatioNumerator != MAXULONG &&
          Framing->OutputCompression.RatioDenominator != 0 &&
          Framing->OutputCompression.RatioDenominator < Framing->OutputCompression.RatioNumerator)
     {
index be844ba..8b975a2 100644 (file)
@@ -2078,6 +2078,6 @@ KsGetNodeIdFromIrp(
     IN PIRP Irp)
 {
     UNIMPLEMENTED
-    return (ULONG)-1;
+    return KSFILTER_NODE;
 }
 
index 861413a..362465d 100644 (file)
@@ -122,7 +122,7 @@ KsValidateTopologyNodeCreateRequest(
     if (!NT_SUCCESS(Status))
         return Status;
 
-    if (NodeCreate->CreateFlags != 0 || (NodeCreate->Node >= Topology->TopologyNodesCount && NodeCreate->Node != (ULONG)-1))
+    if (NodeCreate->CreateFlags != 0 || (NodeCreate->Node >= Topology->TopologyNodesCount && NodeCreate->Node != MAXULONG))
     {
         /* invalid node create */
         FreeItem(NodeCreate);
index e9c6360..de94b29 100644 (file)
@@ -108,7 +108,7 @@ typedef struct _WORKITEM_DATA
 
 #define SERIAL_TAG 'lreS'
 
-#define INFINITE ((ULONG)-1)
+#define INFINITE MAXULONG
 
 /* Baud master clock */
 #define BAUD_CLOCK      1843200
index 5085227..364e508 100644 (file)
@@ -1226,7 +1226,7 @@ NTSTATUS NTAPI PropertyHandler_CpuResources(PPCPROPERTY_REQUEST PropertyRequest)
 
        NTSTATUS ntStatus = STATUS_INVALID_DEVICE_REQUEST;
 
-       if (PropertyRequest->Node == (ULONG)-1) {
+       if (PropertyRequest->Node == MAXULONG) {
                return ntStatus;
        }
        if (PropertyRequest->Node >= KSNODE_TOPO_INVALID) {
index 7496815..0aed799 100644 (file)
@@ -133,7 +133,7 @@ AllocatorFraming =
         0,
         {
             0,
-            (ULONG)-1,
+            MAXULONG,
             1
         },
         {
@@ -173,7 +173,7 @@ PinDescriptors[] =
         },
         KSPIN_FLAG_DISPATCH_LEVEL_PROCESSING | KSPIN_FLAG_INITIATE_PROCESSING_ON_EVERY_ARRIVAL |
         KSPIN_FLAG_FRAMES_NOT_REQUIRED_FOR_PROCESSING | KSPIN_FLAG_PROCESS_IF_ANY_IN_RUN_STATE,
-        (ULONG)-1,
+        MAXULONG,
         1,
         NULL, //&AllocatorFraming,
         PinIntersectHandler
index 37c5a75..2c9ae93 100644 (file)
@@ -315,7 +315,7 @@ StreamClassStartDevice(
         DeviceDesc.InterfaceType = Config->AdapterInterfaceType;
         DeviceDesc.DmaWidth = Width32Bits;
         DeviceDesc.DmaSpeed = Compatible;
-        DeviceDesc.MaximumLength = (ULONG)-1;
+        DeviceDesc.MaximumLength = MAXULONG;
         DeviceDesc.Dma32BitAddresses = DriverObjectExtension->Data.Dma24BitAddresses;
 
         Adapter = IoGetDmaAdapter(DeviceExtension->PhysicalDeviceObject, &DeviceDesc, &MapRegisters);
index ada2f2d..b6f6474 100644 (file)
@@ -173,7 +173,7 @@ WdmAudControlOpen(
     }
 
     /* close pin handle which uses same virtual audio device id and pin id */
-    FreeIndex = (ULONG)-1;
+    FreeIndex = MAXULONG;
     for(Index = 0; Index < ClientInfo->NumPins; Index++)
     {
         if (ClientInfo->hPins[Index].FilterId == FilterId && ClientInfo->hPins[Index].PinId == PinId && ClientInfo->hPins[Index].Handle && ClientInfo->hPins[Index].Type == DeviceInfo->DeviceType)
@@ -266,7 +266,7 @@ WdmAudControlOpen(
     {
         PWDMAUD_HANDLE Handels;
 
-        if (FreeIndex != (ULONG)-1)
+        if (FreeIndex != MAXULONG)
         {
             /* re-use a free index */
             ClientInfo->hPins[Index].Handle = PinHandle;
index 5d5953f..2c83c52 100644 (file)
@@ -210,7 +210,7 @@ GetNodeTypeIndex(
         }
         Guid++;
     }
-    return (ULONG)-1;
+    return MAXULONG;
 }
 
 ULONG
index a886e13..aaaef91 100644 (file)
@@ -1073,7 +1073,7 @@ HalAllocateAdapterChannel(
 {
    PADAPTER_OBJECT MasterAdapter;
    PGROW_WORK_ITEM WorkItem;
-   ULONG Index = ~0;
+   ULONG Index = MAXULONG;
    ULONG Result;
    KIRQL OldIrql;
 
@@ -1129,7 +1129,7 @@ HalAllocateAdapterChannel(
       {
          Index = RtlFindClearBitsAndSet(
             MasterAdapter->MapRegisters, NumberOfMapRegisters, 0);
-         if (Index != ~0)
+         if (Index != MAXULONG)
          {
             AdapterObject->MapRegisterBase =
                MasterAdapter->MapRegisterBase + Index;
@@ -1143,7 +1143,7 @@ HalAllocateAdapterChannel(
          }
       }
 
-      if (Index == ~0)
+      if (Index == MAXULONG)
       {
          WorkItem = ExAllocatePoolWithTag(
             NonPagedPool, sizeof(GROW_WORK_ITEM), TAG_DMA);
@@ -1242,7 +1242,7 @@ IoFreeAdapterChannel(
    PADAPTER_OBJECT MasterAdapter;
    PKDEVICE_QUEUE_ENTRY DeviceQueueEntry;
    PWAIT_CONTEXT_BLOCK WaitContextBlock;
-   ULONG Index = ~0;
+   ULONG Index = MAXULONG;
    ULONG Result;
    KIRQL OldIrql;
 
@@ -1287,7 +1287,7 @@ IoFreeAdapterChannel(
             Index = RtlFindClearBitsAndSet(
                MasterAdapter->MapRegisters,
                WaitContextBlock->NumberOfMapRegisters, 0);
-            if (Index != ~0)
+            if (Index != MAXULONG)
             {
                AdapterObject->MapRegisterBase =
                   MasterAdapter->MapRegisterBase + Index;
@@ -1301,7 +1301,7 @@ IoFreeAdapterChannel(
             }
          }
 
-         if (Index == ~0)
+         if (Index == MAXULONG)
          {
             InsertTailList(&MasterAdapter->AdapterQueue, &AdapterObject->AdapterQueue);
             KfReleaseSpinLock(&MasterAdapter->SpinLock, OldIrql);
@@ -1404,7 +1404,7 @@ IoFreeMapRegisters(
          MasterAdapter->MapRegisters,
          AdapterObject->NumberOfMapRegisters,
          MasterAdapter->NumberOfMapRegisters);
-      if (Index == ~0)
+      if (Index == MAXULONG)
       {
          InsertHeadList(&MasterAdapter->AdapterQueue, ListEntry);
          break;
@@ -1600,7 +1600,7 @@ IoFlushAdapterBuffers(
    {
       if ((ULONG_PTR)MapRegisterBase & MAP_BASE_SW_SG)
       {
-         if (RealMapRegisterBase->Counter != ~0)
+         if (RealMapRegisterBase->Counter != MAXULONG)
          {
             if (SlaveDma && !AdapterObject->IgnoreCount)
                Length -= HalReadDmaCounter(AdapterObject);
@@ -1779,7 +1779,7 @@ IoMapTransfer(
       PhysicalAddress = RealMapRegisterBase->PhysicalAddress;
       PhysicalAddress.QuadPart += ByteOffset;
       TransferLength = *Length;
-      RealMapRegisterBase->Counter = ~0;
+      RealMapRegisterBase->Counter = MAXULONG;
       Counter = 0;
    }
    else
@@ -1809,7 +1809,7 @@ IoMapTransfer(
          PhysicalAddress.QuadPart += ByteOffset;
          if ((ULONG_PTR)MapRegisterBase & MAP_BASE_SW_SG)
          {
-            RealMapRegisterBase->Counter = ~0;
+            RealMapRegisterBase->Counter = MAXULONG;
             Counter = 0;
          }
       }
@@ -1982,13 +1982,13 @@ HalAllocateCrashDumpRegisters(IN PADAPTER_OBJECT AdapterObject,
         }
 
         /* Try to find free map registers */
-        MapRegisterNumber = -1;
+        MapRegisterNumber = MAXULONG;
         MapRegisterNumber = RtlFindClearBitsAndSet(MasterAdapter->MapRegisters,
                                                    *NumberOfMapRegisters,
                                                    0);
 
         /* Check if nothing was found */
-        if (MapRegisterNumber == -1)
+        if (MapRegisterNumber == MAXULONG)
         {
             /* No free registers found, so use the base registers */
             RtlSetBits(MasterAdapter->MapRegisters,
index 9dbc817..0f060f4 100644 (file)
@@ -1075,7 +1075,7 @@ HalAllocateAdapterChannel(
 {
    PADAPTER_OBJECT MasterAdapter;
    PGROW_WORK_ITEM WorkItem;
-   ULONG Index = ~0U;
+   ULONG Index = MAXULONG;
    ULONG Result;
    KIRQL OldIrql;
 
@@ -1131,7 +1131,7 @@ HalAllocateAdapterChannel(
       {
          Index = RtlFindClearBitsAndSet(
             MasterAdapter->MapRegisters, NumberOfMapRegisters, 0);
-         if (Index != ~0U)
+         if (Index != MAXULONG)
          {
             AdapterObject->MapRegisterBase =
                MasterAdapter->MapRegisterBase + Index;
@@ -1145,7 +1145,7 @@ HalAllocateAdapterChannel(
          }
       }
 
-      if (Index == ~0U)
+      if (Index == MAXULONG)
       {
          WorkItem = ExAllocatePoolWithTag(
             NonPagedPool, sizeof(GROW_WORK_ITEM), TAG_DMA);
@@ -1244,7 +1244,7 @@ IoFreeAdapterChannel(
    PADAPTER_OBJECT MasterAdapter;
    PKDEVICE_QUEUE_ENTRY DeviceQueueEntry;
    PWAIT_CONTEXT_BLOCK WaitContextBlock;
-   ULONG Index = ~0;
+   ULONG Index = MAXULONG;
    ULONG Result;
    KIRQL OldIrql;
 
@@ -1289,7 +1289,7 @@ IoFreeAdapterChannel(
             Index = RtlFindClearBitsAndSet(
                MasterAdapter->MapRegisters,
                WaitContextBlock->NumberOfMapRegisters, 0);
-            if (Index != ~0U)
+            if (Index != MAXULONG)
             {
                AdapterObject->MapRegisterBase =
                   MasterAdapter->MapRegisterBase + Index;
@@ -1303,7 +1303,7 @@ IoFreeAdapterChannel(
             }
          }
 
-         if (Index == ~0U)
+         if (Index == MAXULONG)
          {
             InsertTailList(&MasterAdapter->AdapterQueue, &AdapterObject->AdapterQueue);
             KfReleaseSpinLock(&MasterAdapter->SpinLock, OldIrql);
@@ -1406,7 +1406,7 @@ IoFreeMapRegisters(
          MasterAdapter->MapRegisters,
          AdapterObject->NumberOfMapRegisters,
          MasterAdapter->NumberOfMapRegisters);
-      if (Index == ~0U)
+      if (Index == MAXULONG)
       {
          InsertHeadList(&MasterAdapter->AdapterQueue, ListEntry);
          break;
@@ -1604,7 +1604,7 @@ IoFlushAdapterBuffers(
    {
       if ((ULONG_PTR)MapRegisterBase & MAP_BASE_SW_SG)
       {
-         if (RealMapRegisterBase->Counter != ~0U)
+         if (RealMapRegisterBase->Counter != MAXULONG)
          {
             if (SlaveDma && !AdapterObject->IgnoreCount)
                Length -= HalReadDmaCounter(AdapterObject);
@@ -1783,7 +1783,7 @@ IoMapTransfer(
       PhysicalAddress = RealMapRegisterBase->PhysicalAddress;
       PhysicalAddress.QuadPart += ByteOffset;
       TransferLength = *Length;
-      RealMapRegisterBase->Counter = ~0;
+      RealMapRegisterBase->Counter = MAXULONG;
       Counter = 0;
    }
    else
@@ -1813,7 +1813,7 @@ IoMapTransfer(
          PhysicalAddress.QuadPart += ByteOffset;
          if ((ULONG_PTR)MapRegisterBase & MAP_BASE_SW_SG)
          {
-            RealMapRegisterBase->Counter = ~0;
+            RealMapRegisterBase->Counter = MAXULONG;
             Counter = 0;
          }
       }
@@ -1991,7 +1991,7 @@ HalAllocateCrashDumpRegisters(IN PADAPTER_OBJECT AdapterObject,
                                                    0);
 
         /* Check if nothing was found */
-        if (MapRegisterNumber == (ULONG)-1)
+        if (MapRegisterNumber == MAXULONG)
         {
             /* No free registers found, so use the base registers */
             RtlSetBits(MasterAdapter->MapRegisters,
index a1feea8..42f30ed 100644 (file)
@@ -217,6 +217,8 @@ typedef const UNICODE_STRING *PCUNICODE_STRING;
 #define MAKEWORD(a,b)           ((WORD)(((BYTE)(a))|(((WORD)((BYTE)(b)))<<8)))
 #define MAKELONG(a,b)           ((LONG)(((WORD)(a))|(((DWORD)((WORD)(b)))<<16)))
 
+#define MAXULONG 0xFFFFFFFF
+
 #define NT_SUCCESS(x)           ((x)>=0)
 #if !defined(__GNUC__)
 #define FIELD_OFFSET(t,f)       ((LONG)(LONG_PTR)&(((t*) 0)->f))
index e3b8907..00b0eb8 100644 (file)
 #define MAXHALF_PTR  ((HALF_PTR)(MAXUHALF_PTR >> 1))
 #define MINHALF_PTR  (~MAXHALF_PTR)
 
+#define MAXUINT      ((UINT)~((UINT)0))
+
+#define MAXULONGLONG ((ULONGLONG)~((ULONGLONG)0))
+
 #ifndef RC_INVOKED
 #ifdef __cplusplus
 extern "C" {
index 34b992d..3501a8a 100644 (file)
@@ -80,7 +80,7 @@ typedef ULONG HCELL_INDEX, *PHCELL_INDEX;
 //
 // Cell Magic Values
 //
-#define HCELL_NIL                                       (ULONG)-1
+#define HCELL_NIL                                       MAXULONG
 #define HCELL_CACHED                                    1
 
 #define HCELL_TYPE_MASK                0x80000000
index 69f0687..f460659 100644 (file)
@@ -58,14 +58,14 @@ NTDLL_FindRuns(PRTL_BITMAP lpBits,
   ULONG ulPos = 0, ulRuns = 0;
 
   if (!ulCount)
-    return ~0U;
+    return MAXULONG;
 
   while (ulPos < lpBits->SizeOfBitMap)
   {
     /* Find next set/clear run */
     ULONG ulSize, ulNextPos = fn(lpBits, ulPos, &ulSize);
 
-    if (ulNextPos == ~0U)
+    if (ulNextPos == MAXULONG)
       break;
 
     if (bLongest && ulRuns == ulCount)
@@ -158,7 +158,7 @@ NTDLL_FindSetRun(PRTL_BITMAP lpBits,
     ulStart = (ulStart & ~7u) + 8;
     lpOut++;
     if (ulStart >= lpBits->SizeOfBitMap)
-      return ~0U;
+      return MAXULONG;
   }
 
   /* Count blocks of 8 set bits */
@@ -248,7 +248,7 @@ NTDLL_FindClearRun(PRTL_BITMAP lpBits,
     ulStart = (ulStart & ~7u) + 8;
     lpOut++;
     if (ulStart >= lpBits->SizeOfBitMap)
-      return ~0U;
+      return MAXULONG;
   }
 
   /* Count blocks of 8 clear bits */
@@ -513,7 +513,7 @@ RtlFindClearBits(PRTL_BITMAP BitMapHeader,
   ULONG ulPos, ulEnd;
 
   if (!BitMapHeader || !NumberToFind || NumberToFind > BitMapHeader->SizeOfBitMap)
-    return ~0U;
+    return MAXULONG;
 
   ulEnd = BitMapHeader->SizeOfBitMap;
 
@@ -537,7 +537,7 @@ RtlFindClearBits(PRTL_BITMAP BitMapHeader,
     else
       ulPos++;
   }
-  return ~0U;
+  return MAXULONG;
 }
 
 /*
@@ -596,7 +596,7 @@ RtlFindFirstRunSet(IN PRTL_BITMAP BitMapHeader,
   Size = BitMapHeader->SizeOfBitMap;
   if (*StartingIndex > Size)
   {
-    *StartingIndex = (ULONG)-1;
+    *StartingIndex = MAXULONG;
     return 0;
   }
 
@@ -619,7 +619,7 @@ RtlFindFirstRunSet(IN PRTL_BITMAP BitMapHeader,
   /* Return index of first set bit */
   if (Index >= Size)
   {
-    *StartingIndex = (ULONG)-1;
+    *StartingIndex = MAXULONG;
     return 0;
   }
   else
@@ -695,7 +695,7 @@ RtlFindSetBits(PRTL_BITMAP BitMapHeader,
   ULONG ulPos, ulEnd;
 
   if (!BitMapHeader || !NumberToFind || NumberToFind > BitMapHeader->SizeOfBitMap)
-    return ~0U;
+    return MAXULONG;
 
   ulEnd = BitMapHeader->SizeOfBitMap;
 
@@ -719,7 +719,7 @@ RtlFindSetBits(PRTL_BITMAP BitMapHeader,
     else
       ulPos++;
   }
-  return ~0U;
+  return MAXULONG;
 }
 
 
@@ -734,7 +734,7 @@ RtlFindSetBitsAndClear(PRTL_BITMAP BitMapHeader,
   ULONG ulPos;
 
   ulPos = RtlFindSetBits(BitMapHeader, NumberToFind, HintIndex);
-  if (ulPos != ~0U)
+  if (ulPos != MAXULONG)
     RtlClearBits(BitMapHeader, ulPos, NumberToFind);
   return ulPos;
 }
@@ -906,7 +906,7 @@ RtlFindClearBitsAndSet(PRTL_BITMAP BitMapHeader,
   ULONG ulPos;
 
   ulPos = RtlFindClearBits(BitMapHeader, NumberToFind, HintIndex);
-  if (ulPos != ~0U)
+  if (ulPos != MAXULONG)
     RtlSetBits(BitMapHeader, ulPos, NumberToFind);
   return ulPos;
 }
index 630ca2e..4988758 100644 (file)
@@ -61,7 +61,7 @@ vDbgPrintExWithPrefixInternal(IN LPCSTR Prefix,
     EXCEPTION_RECORD ExceptionRecord;
 
     /* Check if we should print it or not */
-    if ((ComponentId != (ULONG)-1) &&
+    if ((ComponentId != MAXULONG) &&
         !(NtQueryDebugFilterState(ComponentId, Level)))
     {
         /* This message is masked */
@@ -96,7 +96,7 @@ vDbgPrintExWithPrefixInternal(IN LPCSTR Prefix,
     _SEH2_END;
 
     /* Check if we went past the buffer */
-    if (Length == (ULONG)-1)
+    if (Length == MAXULONG)
     {
         /* Terminate it if we went over-board */
         Buffer[sizeof(Buffer) - 1] = '\n';
index 72a5e32..a9a0896 100644 (file)
@@ -110,7 +110,7 @@ typedef struct tagARENA_FREE
 /* Max size of the blocks on the free lists */
 static const DWORD HEAP_freeListSizes[HEAP_NB_FREE_LISTS] =
 {
-    0x10, 0x20, 0x80, 0x200, ~0UL
+    0x10, 0x20, 0x80, 0x200, MAXULONG
 };
 
 typedef struct
@@ -1612,7 +1612,7 @@ RtlSizeHeap(
     if (!heapPtr)
     {
         RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_HANDLE );
-        return ~0UL;
+        return MAXULONG;
     }
     flags &= HEAP_NO_SERIALIZE;
     flags |= heapPtr->flags;
@@ -1620,7 +1620,7 @@ RtlSizeHeap(
     if (!HEAP_IsRealArena( heapPtr, HEAP_NO_SERIALIZE, ptr, QUIET ))
     {
         RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_PARAMETER );
-        ret = ~0UL;
+        ret = MAXULONG;
     }
     else
     {
index 4730bbb..446c296 100644 (file)
@@ -608,11 +608,11 @@ RtlInvertRangeList (OUT PRTL_RANGE_LIST InvertedRangeList,
     }
 
   /* Add trailing range */
-  if (Previous->Range.End + 1 != (ULONGLONG)-1)
+  if (Previous->Range.End + 1 != MAXULONGLONG)
     {
       Status = RtlAddRange (InvertedRangeList,
                            Previous->Range.End + 1,
-                           (ULONGLONG)-1,
+                           MAXULONGLONG,
                            0,
                            0,
                            NULL,
index a5e2276..e302590 100644 (file)
@@ -131,7 +131,7 @@ RtlpCallQueryRegistryRoutine(IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
     *InfoSize = 0;
 
     /* Check if there's no data */
-    if (KeyValueInfo->DataOffset == (ULONG)-1)
+    if (KeyValueInfo->DataOffset == MAXULONG)
     {
         /* Return proper status code */
         return (QueryTable->Flags & RTL_QUERY_REGISTRY_REQUIRED) ?
index fea55be..cd7927c 100644 (file)
@@ -1065,7 +1065,7 @@ RtlIsTextUnicode( PVOID buf, INT len, INT *pf )
     static const WCHAR byterev_control_chars[] = {0x0d00,0x0a00,0x0900,0x2000,0};
     const WCHAR *s = buf;
     int i;
-    unsigned int flags = ~0U, out_flags = 0;
+    unsigned int flags = MAXULONG, out_flags = 0;
 
     if (len < sizeof(WCHAR))
     {
index 4cacaca..e12b682 100644 (file)
@@ -466,7 +466,7 @@ ExpLoadInitialProcess(IN PINIT_BUFFER InitBuffer,
 
     /* Make sure the buffer is a valid string which within the given length */
     if ((NtInitialUserProcessBufferType != REG_SZ) ||
-        ((NtInitialUserProcessBufferLength != (ULONG)-1) &&
+        ((NtInitialUserProcessBufferLength != MAXULONG) &&
          ((NtInitialUserProcessBufferLength < sizeof(WCHAR)) ||
           (NtInitialUserProcessBufferLength >
            sizeof(NtInitialUserProcessBuffer) - sizeof(WCHAR)))))
@@ -1429,7 +1429,7 @@ Phase1InitializationDiscard(IN PVOID Context)
         if (!ExpRealTimeIsUniversal)
         {
             /* Check if we don't have a valid bias */
-            if (ExpLastTimeZoneBias == (ULONG)-1)
+            if (ExpLastTimeZoneBias == MAXULONG)
             {
                 /* Reset */
                 ResetBias = TRUE;
index d217122..f42bb01 100644 (file)
@@ -20,7 +20,7 @@
 #if 1
 const WCHAR DiskMountString[] = L"\\DosDevices\\%C:";
 
-#define AUTO_DRIVE         ((ULONG)-1)
+#define AUTO_DRIVE         MAXULONG
 
 #define PARTITION_MAGIC    0xaa55
 
@@ -135,7 +135,7 @@ HalpAssignDrive(IN PUNICODE_STRING PartitionName,
     if (RtlCompareUnicodeString(PartitionName, BootDevice, FALSE) == 0)
     {
         /* Set NtSystemPath to that partition's disk letter */
-        *NtSystemPath = 'A' + DriveNumber;
+        *NtSystemPath = (UCHAR)('A' + DriveNumber);
     }
 
     return TRUE;
index 366cbab..0706845 100644 (file)
@@ -152,7 +152,7 @@ IopCreateServiceListEntry(PUNICODE_STRING ServiceName)
   RTL_QUERY_REGISTRY_TABLE QueryTable[7];
   PSERVICE Service;
   NTSTATUS Status;
-  ULONG DefaultTag = ~0;
+  ULONG DefaultTag = MAXULONG;
 
   DPRINT("ServiceName: '%wZ'\n", ServiceName);
 
index e18e1d2..f0d5d26 100644 (file)
@@ -1008,7 +1008,7 @@ KdbpDisableBreakPoint(
             }
         }
 
-        if (i != (ULONG)-1) /* not found */
+        if (i != MAXULONG) /* not found */
             ASSERT(0);
     }
     else
@@ -1033,7 +1033,7 @@ KdbpDisableBreakPoint(
             }
         }
 
-        if (i != (ULONG)-1) /* not found */
+        if (i != MAXULONG) /* not found */
             ASSERT(0);
     }
 
index e61f2b6..a517f96 100644 (file)
@@ -447,9 +447,9 @@ KdbpCmdFilter(
         else
         {
             if (*p == '-')
-                clear = ~0;
+                clear = MAXULONG;
             else
-                set = ~0;
+                set = MAXULONG;
         }
         if (*p == '+' || *p == '-')
             p++;
index 84a2529..b22c381 100644 (file)
@@ -194,8 +194,8 @@ KeInitializeInterrupt(IN PKINTERRUPT Interrupt,
     Interrupt->ShareVector = ShareVector;
     Interrupt->Number = ProcessorNumber;
     Interrupt->FloatingSave = FloatingSave;
-    Interrupt->TickCount = (ULONG)-1;
-    Interrupt->DispatchCount = (ULONG)-1;
+    Interrupt->TickCount = MAXULONG;
+    Interrupt->DispatchCount = MAXULONG;
 
     /* Loop the template in memory */
     for (i = 0; i < KINTERRUPT_DISPATCH_CODES; i++)
index b5795d1..2360bff 100644 (file)
@@ -7,10 +7,6 @@
 #error __ELF_WORD_SIZE must be defined
 #endif
 
-#ifndef MAXULONG
-#define MAXULONG ((ULONG)(~1))
-#endif
-
 #include <elf/elf.h>
 
 /* TODO: Intsafe should be made into a library, as it's generally useful */
@@ -205,7 +201,7 @@ static __inline ULONG ElfFmtpReadULong
  }
 
  ASSERT(FALSE);
- return (ULONG)-1;
+ return MAXULONG;
 }
 
 static __inline USHORT ElfFmtpReadUShort
@@ -282,7 +278,7 @@ static __inline ULONG ElfFmtpSafeReadULong
  }
 
  ASSERT(FALSE);
- return (ULONG)-1;
+ return MAXULONG;
 }
 
 static __inline BOOLEAN ElfFmtpIsPowerOf2(IN Elf_Addr Number)
index 70744ba..0a7be92 100644 (file)
@@ -78,11 +78,11 @@ ULONG_PTR
 NTAPI
 MiFlushTlbIpiRoutine(ULONG_PTR Address)
 {
-   if (Address == (ULONG_PTR)-1)
+   if (Address == MAXULONGLONG)
    {
       KeFlushCurrentTb();
    }
-   else if (Address == (ULONG_PTR)-2)
+   else if (Address == MAXULONGLONG-1)
    {
       KeFlushCurrentTb();
    }
index 49b5b19..7b7e5d3 100644 (file)
 
 #include <reactos/exeformat.h>
 
-#ifndef MAXULONG
-#define MAXULONG ((ULONG)(~1))
-#endif
-
 static ULONG SectionCharacteristicsToProtect[16] =
 {
     PAGE_NOACCESS,          /* 0 = NONE */
@@ -453,7 +449,7 @@ l_ReadHeaderFromFile:
                if(pioh64OptHeader->ImageBase > MAXULONG_PTR)
                    DIE(("ImageBase exceeds the address space\n"));
 
-               ImageSectionObject->ImageBase = pioh64OptHeader->ImageBase;
+               ImageSectionObject->ImageBase = (ULONG_PTR)pioh64OptHeader->ImageBase;
            }
 
            if(RTL_CONTAINS_FIELD(pioh64OptHeader, cbOptHeaderSize, SizeOfImage))
index 0d5d10d..486b0fe 100644 (file)
@@ -526,7 +526,7 @@ NtPowerInformation(IN POWER_INFORMATION_LEVEL PowerInformationLevel,
 
             /* Just zero the struct (and thus set BatteryState->BatteryPresent = FALSE) */
             RtlZeroMemory(BatteryState, sizeof(SYSTEM_BATTERY_STATE));
-            BatteryState->EstimatedTime = (ULONG)-1;
+            BatteryState->EstimatedTime = MAXULONG;
 
             Status = STATUS_SUCCESS;
             break;
index b04284d..224cd12 100644 (file)
@@ -443,7 +443,7 @@ PspInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
     /* Now multiply limits by 1MB */
     PspDefaultPagedLimit <<= 20;
     PspDefaultNonPagedLimit <<= 20;
-    if (PspDefaultPagefileLimit != (ULONG)-1) PspDefaultPagefileLimit <<= 20;
+    if (PspDefaultPagefileLimit != MAXULONG) PspDefaultPagefileLimit <<= 20;
 
     /* Initialize the Active Process List */
     InitializeListHead(&PsActiveProcessHead);
index 6a340df..f9d70a9 100644 (file)
@@ -193,8 +193,8 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
                         Process->Vm.MinimumWorkingSetSize << PAGE_SHIFT;
 
                 /* Set default time limits */
-                QuotaLimits->TimeLimit.LowPart = (ULONG)-1;
-                QuotaLimits->TimeLimit.HighPart = (ULONG)-1;
+                QuotaLimits->TimeLimit.LowPart = MAXULONG;
+                QuotaLimits->TimeLimit.HighPart = MAXULONG;
 
                 /* Is quota block a default one? */
                 if (Process->QuotaBlock == &PspDefaultQuotaBlock)