-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issuse found using default CodeQL settings.
When relying projects enable CodeQL, they will by default see ten (10x) issues of the following type: `Comparison of narrow type with wide type in loop condition` The type of `TOTAL_DRIVER_COUNT` is `int` (`uint8_t` + `size_t` --> `int`) The type of the loop variable was `uint8_t`. The loop is gated by a check of `(uint8_t)i < TOTAL_DRIVER_COUNT`. As a result, a high severity alert is generated by CodeQL. This fix does the following: 1. Fix the CodeQL alert by changing the loop variable type to use `int`. 2. Explicitly limiting the loop to MAXIMUM_TOTAL_DRIVER_COUNT. 3. Sets the originally named variable to the loop variable (but c-style cast to type `uint8_t`). In addition, because there was not previously any code to ensure that `TOTAL_DRIVER_COUNT` would be in the expected range of `[0x01..0xFF]`, added a `TU_ASSERT()` at the appropriate location to ensure this condition.
- Loading branch information
Showing
1 changed file
with
24 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters