- Use MAXUINT, MAXULONG, MAXDWORD, MAXULONGLONG and MAXULONGLONG instead of ~0 or casting -1 to unsigned.

- 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
This commit is contained in:
Stefan Ginsberg 2009-09-27 20:07:43 +00:00
parent d9fe1b8579
commit e7e6699ae1
46 changed files with 109 additions and 111 deletions

View 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;

View 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';

View 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;

View 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;

View 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))

View 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);

View 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;

View 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;

View 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))))
{

View 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

View 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);

View 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);
}

View 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,

View 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 *****************************************************************/

View 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)
{

View file

@ -2078,6 +2078,6 @@ KsGetNodeIdFromIrp(
IN PIRP Irp)
{
UNIMPLEMENTED
return (ULONG)-1;
return KSFILTER_NODE;
}

View 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);

View 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

View 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) {

View 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

View 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);

View 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;

View file

@ -210,7 +210,7 @@ GetNodeTypeIndex(
}
Guid++;
}
return (ULONG)-1;
return MAXULONG;
}
ULONG

View 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,

View 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,

View 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))

View file

@ -48,6 +48,10 @@
#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" {

View 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

View 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;
}

View 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';

View 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
{

View 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,

View 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) ?

View 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))
{

View 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;

View 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;

View 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);

View 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);
}

View file

@ -447,9 +447,9 @@ KdbpCmdFilter(
else
{
if (*p == '-')
clear = ~0;
clear = MAXULONG;
else
set = ~0;
set = MAXULONG;
}
if (*p == '+' || *p == '-')
p++;

View 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++)

View 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)

View 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();
}

View file

@ -16,10 +16,6 @@
#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))

View 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;

View 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);

View 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)