[USBPORT] Fix incorrect use of bitfields.

EndpointMoved == TRUE could never be true, because BOOL is a signed type,
and the only two values in a signed one-bit type are 0 and -1.

Courtesy of VS analysis warning C6299:
Explicitly comparing a bit field to a Boolean type will yield unexpected results.
This commit is contained in:
Thomas Faber 2021-11-25 09:30:03 -05:00
parent fd28a69de6
commit f5c5426924
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
2 changed files with 4 additions and 4 deletions

View file

@ -644,7 +644,7 @@ USB2_MoveTtEndpoint(IN PUSB2_TT_ENDPOINT TtEndpoint,
TransferType = TtEndpoint->TtEndpointParams.TransferType;
if (Rebalance->RebalanceEndpoint[Num] &&
TtEndpoint->TtEndpointParams.EndpointMoved == TRUE &&
TtEndpoint->TtEndpointParams.EndpointMoved &&
((TransferType != USBPORT_TRANSFER_TYPE_INTERRUPT) || BusTime >= 0))
{
DPRINT("USB2_MoveTtEndpoint: result - FALSE\n");
@ -668,7 +668,7 @@ USB2_MoveTtEndpoint(IN PUSB2_TT_ENDPOINT TtEndpoint,
*OutResult = FALSE;
}
TtEndpoint->TtEndpointParams.EndpointMoved = TRUE;
TtEndpoint->TtEndpointParams.EndpointMoved = 1;
if (Rebalance->RebalanceEndpoint[Num] == NULL)
{

View file

@ -486,8 +486,8 @@ typedef union _USB2_TT_ENDPOINT_PARAMS {
struct {
ULONG TransferType : 4;
ULONG Direction : 1;
USB_DEVICE_SPEED DeviceSpeed : 2;
BOOL EndpointMoved : 1;
ULONG DeviceSpeed : 2;
ULONG EndpointMoved : 1;
ULONG Reserved : 24;
};
ULONG AsULONG;