Skip to content

Commit

Permalink
fix driver generator
Browse files Browse the repository at this point in the history
  • Loading branch information
EmixamPP committed Jun 20, 2022
1 parent 6fceb8e commit e9c719b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sources/driver/driver-generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,10 @@ inline int get_next_curCtrl(uint8_t *curCtrl, const uint8_t *resCtrl, const uint

for (unsigned i = 0; i < ctrlSize; ++i)
{
curCtrl[i] = curCtrl[i] + resCtrl[i];
if (curCtrl[i] > maxCtrl[i]) // resCtrl does not allow to reach maxCtrl
{
int nextCtrl = curCtrl[i] + resCtrl[i]; // int to avoid overflow
curCtrl[i] = (uint8_t) nextCtrl;
if (nextCtrl > maxCtrl[i]) // resCtrl does not allow to reach maxCtrl
{
memcpy(curCtrl, maxCtrl, ctrlSize * sizeof(uint8_t)); // set maxCtrl
return 0;
}
Expand Down

0 comments on commit e9c719b

Please sign in to comment.