-
Notifications
You must be signed in to change notification settings - Fork 1
Description
The USB Host driver can be improved. Following suggestions have been proposed by Copilot:
The available() method calls uxQueueMessagesWaiting() which returns UBaseType_t (unsigned). However, this method returns an int which is signed. While the cast is implicit, there's a potential for overflow if the queue has more messages than INT_MAX, though this is unlikely with a queue size of 1024. Consider returning size_t or ensuring the queue size cannot exceed INT_MAX to maintain consistency with the Stream interface contract.
Originally posted by @Copilot in #210 (comment)
The getByte() method checks available() which calls uxQueueMessagesWaiting(), but then calls xQueueReceive() which already handles the case when the queue is empty. The available() check is redundant since xQueueReceive() with timeout 0 will immediately return pdFALSE if no data is available. Consider removing the available() check for better performance.
Originally posted by @Copilot in #210 (comment)