C to C++ migration and refactoring #17
@@ -398,5 +398,5 @@ XTCDECL
|
|||||||
BOOLEAN
|
BOOLEAN
|
||||||
Debug::SerialPortReady()
|
Debug::SerialPortReady()
|
||||||
{
|
{
|
||||||
return (BOOLEAN)(SerialPort.Flags & COMPORT_FLAG_INIT);
|
return (SerialPort.Flags & COMPORT_FLAG_INIT);
|
||||||
belliash marked this conversation as resolved
Outdated
|
|||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ BOOLEAN
|
|||||||
KE::KUbsan::CheckReport(PKUBSAN_SOURCE_LOCATION Location)
|
KE::KUbsan::CheckReport(PKUBSAN_SOURCE_LOCATION Location)
|
||||||
{
|
{
|
||||||
/* Make sure, this error should be reported */
|
/* Make sure, this error should be reported */
|
||||||
return (BOOLEAN)!ActiveFrame;
|
return !ActiveFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -126,8 +126,8 @@ XTAPI
|
|||||||
BOOLEAN
|
BOOLEAN
|
||||||
MM::Init::VerifyMemoryTypeFree(LOADER_MEMORY_TYPE MemoryType)
|
MM::Init::VerifyMemoryTypeFree(LOADER_MEMORY_TYPE MemoryType)
|
||||||
{
|
{
|
||||||
return (BOOLEAN)((MemoryType == LoaderFree) || (MemoryType == LoaderFirmwareTemporary) ||
|
return ((MemoryType == LoaderFree) || (MemoryType == LoaderFirmwareTemporary) ||
|
||||||
(MemoryType == LoaderLoadedProgram) || (MemoryType == LoaderOsloaderStack));
|
(MemoryType == LoaderLoadedProgram) || (MemoryType == LoaderOsloaderStack));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,7 +144,7 @@ XTAPI
|
|||||||
BOOLEAN
|
BOOLEAN
|
||||||
MM::Init::VerifyMemoryTypeInvisible(LOADER_MEMORY_TYPE MemoryType)
|
MM::Init::VerifyMemoryTypeInvisible(LOADER_MEMORY_TYPE MemoryType)
|
||||||
{
|
{
|
||||||
return (BOOLEAN)((MemoryType == LoaderFirmwarePermanent) ||
|
return ((MemoryType == LoaderFirmwarePermanent) ||
|
||||||
(MemoryType == LoaderSpecialMemory) ||
|
(MemoryType == LoaderSpecialMemory) ||
|
||||||
(MemoryType == LoaderBBTMemory));
|
(MemoryType == LoaderBBTMemory));
|
||||||
}
|
}
|
||||||
|
@@ -313,7 +313,7 @@ RTL::BitMap::FindBits(IN PRTL_BITMAP BitMap,
|
|||||||
while(BitOffset + Length < BitMapEnd)
|
while(BitOffset + Length < BitMapEnd)
|
||||||
{
|
{
|
||||||
/* Increment offset */
|
/* Increment offset */
|
||||||
BitOffset += CountBits(BitMap, BitMap->Size - BitOffset, BitOffset, (BOOLEAN)!SetBits);
|
BitOffset += CountBits(BitMap, BitMap->Size - BitOffset, BitOffset, !SetBits);
|
||||||
if(BitOffset + Length > BitMapEnd)
|
if(BitOffset + Length > BitMapEnd)
|
||||||
{
|
{
|
||||||
/* No match found, break loop execution */
|
/* No match found, break loop execution */
|
||||||
|
@@ -34,6 +34,6 @@ RTL::Guid::CompareGuids(IN PGUID Guid1,
|
|||||||
Guid2Ptr = (PUINT)Guid2;
|
Guid2Ptr = (PUINT)Guid2;
|
||||||
|
|
||||||
/* Compare GUIDs */
|
/* Compare GUIDs */
|
||||||
return (BOOLEAN)(Guid1Ptr[0] == Guid2Ptr[0] && Guid1Ptr[1] == Guid2Ptr[1] &&
|
return (Guid1Ptr[0] == Guid2Ptr[0] && Guid1Ptr[1] == Guid2Ptr[1] &&
|
||||||
Guid1Ptr[2] == Guid2Ptr[2] && Guid1Ptr[3] == Guid2Ptr[3]);
|
Guid1Ptr[2] == Guid2Ptr[2] && Guid1Ptr[3] == Guid2Ptr[3]);
|
||||||
}
|
}
|
||||||
|
@@ -107,7 +107,7 @@ XTCDECL
|
|||||||
BOOLEAN
|
BOOLEAN
|
||||||
RTL::LinkedList::ListEmpty(IN PLIST_ENTRY ListHead)
|
RTL::LinkedList::ListEmpty(IN PLIST_ENTRY ListHead)
|
||||||
{
|
{
|
||||||
return (BOOLEAN)(((ListHead->Flink == NULLPTR) && (ListHead->Blink == NULLPTR)) || (ListHead->Flink == ListHead));
|
return (((ListHead->Flink == NULLPTR) && (ListHead->Blink == NULLPTR)) || (ListHead->Flink == ListHead));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -631,7 +631,7 @@ RTL::Math::InfiniteDouble(IN DOUBLE Value)
|
|||||||
Var.Double = &Value;
|
Var.Double = &Value;
|
||||||
|
|
||||||
/* Return TRUE if it is infinite, or FALSE otherwise */
|
/* Return TRUE if it is infinite, or FALSE otherwise */
|
||||||
return (BOOLEAN)((Var.DoubleS->Exponent & 0x7FF) == 0x7FF);
|
return ((Var.DoubleS->Exponent & 0x7FF) == 0x7FF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -690,5 +690,5 @@ RTL::Math::NanDouble(IN DOUBLE Value)
|
|||||||
Var.Double = &Value;
|
Var.Double = &Value;
|
||||||
|
|
||||||
/* Return TRUE if it is NaN, or FALSE otherwise */
|
/* Return TRUE if it is NaN, or FALSE otherwise */
|
||||||
return (BOOLEAN)(Var.DoubleS->Exponent == 0x7FF && (Var.DoubleS->MantissaHigh != 0 || Var.DoubleS->MantissaLow != 0));
|
return (Var.DoubleS->Exponent == 0x7FF && (Var.DoubleS->MantissaHigh != 0 || Var.DoubleS->MantissaLow != 0));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user
Do we need to typecast each bool operation? In C this returned integer value and compiler knew how to cast it into our BOOLEAN enum. In C++, result value is of bool type that cannot be automatically typecasted into enum.
No, we do not have to. Alternatively, I can suggest moving the BOOLEAN type definition from xttypes.h to xtcompat.h:
This will allow us to maintain backward compatibility with C and get rid of explicit typecasts at the same time.
This should also work in the case of the quoted fragment, even though the result of the operation is not of type bool but int. The result of the expression will be 0 if the flag is not set, or the value of COMPORT_FLAG_INIT if it is. It is only the comparison of this result, for example (SerialPort.Flags & COMPORT_FLAG_INIT) != 0, that actually yields a bool type.
Please let me know if you accept this, then I will commit the proposed change.
You are right, this results in int, not bool. There are more such changes like this in the diff, and I added a comment to the first one, as its the only one that fits on first page. unfortunately. Never mind, I think the proposed solution will be OK.