Fixed sign-compare warnings

This commit is contained in:
Armin Novak 2019-02-07 14:35:40 +01:00
parent 279a5fe39f
commit b5a7e4d9b9
2 changed files with 36 additions and 16 deletions

View File

@ -78,8 +78,14 @@ WINPR_PSLIST_ENTRY InterlockedPushEntrySList(WINPR_PSLIST_HEADER ListHead, WINPR
ListEntry->Next = old.s.Next.Next;
newHeader.s.Depth = old.s.Depth + 1;
newHeader.s.Sequence = old.s.Sequence + 1;
if (old.Alignment > INT64_MAX)
return NULL;
if (newHeader.Alignment > INT64_MAX)
return NULL;
if (ListHead->Alignment > INT64_MAX)
return NULL;
}
while(InterlockedCompareExchange64((LONGLONG*) &ListHead->Alignment, newHeader.Alignment, old.Alignment) != old.Alignment);
while(InterlockedCompareExchange64((LONGLONG*) &ListHead->Alignment, (LONGLONG)newHeader.Alignment, (LONGLONG)old.Alignment) != (LONGLONG)old.Alignment);
return old.s.Next.Next;
#endif
@ -134,8 +140,15 @@ WINPR_PSLIST_ENTRY InterlockedPopEntrySList(WINPR_PSLIST_HEADER ListHead)
newHeader.s.Next.Next = entry->Next;
newHeader.s.Depth = old.s.Depth - 1;
newHeader.s.Sequence = old.s.Sequence + 1;
if (old.Alignment > INT64_MAX)
return NULL;
if (newHeader.Alignment > INT64_MAX)
return NULL;
if (ListHead->Alignment > INT64_MAX)
return NULL;
}
while(InterlockedCompareExchange64((LONGLONG*) &ListHead->Alignment, newHeader.Alignment, old.Alignment) != old.Alignment);
while(InterlockedCompareExchange64((LONGLONG*) &ListHead->Alignment, (LONGLONG)newHeader.Alignment, (LONGLONG)old.Alignment) != (LONGLONG)old.Alignment);
#endif
return entry;
}
@ -173,8 +186,15 @@ WINPR_PSLIST_ENTRY InterlockedFlushSList(WINPR_PSLIST_HEADER ListHead)
{
old = *ListHead;
newHeader.s.Sequence = old.s.Sequence + 1;
if (old.Alignment > INT64_MAX)
return NULL;
if (newHeader.Alignment > INT64_MAX)
return NULL;
if (ListHead->Alignment > INT64_MAX)
return NULL;
}
while(InterlockedCompareExchange64((LONGLONG*) &ListHead->Alignment, newHeader.Alignment, old.Alignment) != old.Alignment);
while(InterlockedCompareExchange64((LONGLONG*) &ListHead->Alignment, (LONGLONG)newHeader.Alignment, (LONGLONG)old.Alignment) != (LONGLONG)old.Alignment);
return old.s.Next.Next;
#endif

View File

@ -97,17 +97,17 @@ int TestInterlockedAccess(int argc, char* argv[])
return -1;
}
*Destination = 0xAABBCCDD;
*Destination = (LONG)0xAABBCCDDL;
oldValue = InterlockedCompareExchange(Destination, 0xCCDDEEFF, 0xAABBCCDD);
oldValue = InterlockedCompareExchange(Destination, (LONG)0xCCDDEEFFL, (LONG)0xAABBCCDDL);
if (oldValue != 0xAABBCCDD)
if (oldValue != (LONG)0xAABBCCDDL)
{
printf("InterlockedCompareExchange failure: Actual: 0x%08"PRIX32", Expected: 0xAABBCCDD\n", oldValue);
return -1;
}
if (*Destination != 0xCCDDEEFF)
if ((*Destination) != (LONG)0xCCDDEEFFL)
{
printf("InterlockedCompareExchange failure: Actual: 0x%08"PRIX32", Expected: 0xCCDDEEFF\n", *Destination);
return -1;
@ -115,17 +115,17 @@ int TestInterlockedAccess(int argc, char* argv[])
/* InterlockedCompareExchange (*Destination != Comparand) */
*Destination = 0xAABBCCDD;
*Destination = (LONG)0xAABBCCDDL;
oldValue = InterlockedCompareExchange(Destination, 0xCCDDEEFF, 0x66778899);
oldValue = InterlockedCompareExchange(Destination, 0xCCDDEEFFL, 0x66778899);
if (oldValue != 0xAABBCCDD)
if (oldValue != (LONG)0xAABBCCDDL)
{
printf("InterlockedCompareExchange failure: Actual: 0x%08"PRIX32", Expected: 0xAABBCCDD\n", oldValue);
return -1;
}
if (*Destination != 0xAABBCCDD)
if ((*Destination) != (LONG)0xAABBCCDDL)
{
printf("InterlockedCompareExchange failure: Actual: 0x%08"PRIX32", Expected: 0xAABBCCDD\n", *Destination);
return -1;
@ -150,7 +150,7 @@ int TestInterlockedAccess(int argc, char* argv[])
return -1;
}
if (*Destination64 != 0x8899AABBCCDDEEFF)
if ((*Destination64) != (LONGLONG)0x8899AABBCCDDEEFFLL)
{
printf("InterlockedCompareExchange failure: Actual: 0x%016"PRIX64", Expected: 0x8899AABBCCDDEEFF\n", *Destination64);
return -1;
@ -158,17 +158,17 @@ int TestInterlockedAccess(int argc, char* argv[])
/* InterlockedCompareExchange64 (*Destination != Comparand) */
*Destination64 = 0x66778899AABBCCDD;
*Destination64 = 0x66778899AABBCCDDLL;
oldValue64 = InterlockedCompareExchange64(Destination64, 0x8899AABBCCDDEEFF, 12345);
oldValue64 = InterlockedCompareExchange64(Destination64, 0x8899AABBCCDDEEFFLL, 12345);
if (oldValue64 != 0x66778899AABBCCDD)
if (oldValue64 != 0x66778899AABBCCDDLL)
{
printf("InterlockedCompareExchange failure: Actual: 0x%016"PRIX64", Expected: 0x66778899AABBCCDD\n", oldValue64);
return -1;
}
if (*Destination64 != 0x66778899AABBCCDD)
if (*Destination64 != 0x66778899AABBCCDDLL)
{
printf("InterlockedCompareExchange failure: Actual: 0x%016"PRIX64", Expected: 0x66778899AABBCCDD\n", *Destination64);
return -1;