Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix index overflow issue in examples #9

Merged
merged 3 commits into from
Jun 7, 2014
Merged

Conversation

rallyemax
Copy link
Contributor

All three examples contained a bug where the reg_position index overflows too early due to a greater-than-or-equal comparison to reg_size_lessone. One solution is to replace the greater-than-or-equal comparison operator with a greater-than operator. The better solution is to retain the >= operator, but to remove entirely the reg_size_lessone variable. It is somewhat clumsy to store as a separate variable another variable that has been decremented by one.

In both receiveEvent and requestEvent, reg_position overflows one unit early due to a greater-than-or-equal comparison with reg_size_lessone. The solution is either to retain the comparison operator but eliminate reg_size_lessone, or to change the comparison to greater-than and retain reg_size_lessone. I have chosen to eliminate reg_size_lessone, as it is clumsy to store a (variable - 1) in a separate variable.
In both receiveEvent and requestEvent, reg_position overflows one unit early due to a greater-than-or-equal comparison with reg_size_lessone. The solution is either to retain the comparison operator but eliminate reg_size_lessone, or to change the comparison to greater-than and retain reg_size_lessone. I have chosen to eliminate reg_size_lessone, as it is clumsy to store a (variable - 1) in a separate variable.
In both receiveEvent and requestEvent, reg_position overflows one unit early due to a greater-than-or-equal comparison with reg_size_lessone. The solution is either to retain the comparison operator but eliminate reg_size_lessone, or to change the comparison to greater-than and retain reg_size_lessone. I have chosen to eliminate reg_size_lessone, as it is clumsy to store a (variable - 1) in a separate variable.
@rambo
Copy link
Owner

rambo commented Jun 7, 2014

Yeah, I got this nasty feeling that the modulo I was using earlier would be expensive and then obviously had some brainfart when fixing that...

rambo added a commit that referenced this pull request Jun 7, 2014
Fix index overflow issue in examples
@rambo rambo merged commit 765f41a into rambo:master Jun 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants