https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f5c5426924c25df4c1601…
commit f5c5426924c25df4c16018cfca752963e982f485
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Thu Nov 25 09:30:03 2021 -0500
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Thu Feb 17 22:01:34 2022 -0500
[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.
---
drivers/usb/usbport/usb2.c | 4 ++--
drivers/usb/usbport/usbport.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/usbport/usb2.c b/drivers/usb/usbport/usb2.c
index 1d609addaa7..9d7a6548bc1 100644
--- a/drivers/usb/usbport/usb2.c
+++ b/drivers/usb/usbport/usb2.c
@@ -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)
{
diff --git a/drivers/usb/usbport/usbport.h b/drivers/usb/usbport/usbport.h
index 04936bfe304..02726fea48c 100644
--- a/drivers/usb/usbport/usbport.h
+++ b/drivers/usb/usbport/usbport.h
@@ -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;