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 timeout data type bugs. #131

Merged
merged 1 commit into from
Jan 22, 2024
Merged

Conversation

haydenroche5
Copy link
Collaborator

This commit resolves a couple problems.

First, it changes the return type of NoteGetMs. NoteGetMs is simply a wrapper around the user-supplied millisecond timer hook. The prototype for this hook specifies that it should return a uint32_t yet NoteGetMs's return type is long unsigned int. This commit changes the return type of NoteGetMs to uint32_t.

Second, there are many places in the code where we are comparing and assigning millisecond timer values (i.e. gotten via NoteGetMs) to size_t variables. This is a bug. On some platforms (e.g. the Arduino Uno), size_t is 16 bits, so assigning one of these 32-bit millisecond timer values to a 16-bit variable can lead to undefined behavior when the timer value is larger than what can fit into 16 bits. This commit fixes all these bugs by using uint32_t instead of size_t.

This commit resolves a couple problems.

First, it changes the return type of NoteGetMs. NoteGetMs is simply a wrapper
around the user-supplied millisecond timer hook. The prototype for this hook
specifies that it should return a uint32_t yet NoteGetMs's return type is long
unsigned int. This commit changes the return type of NoteGetMs to uint32_t.

Second, there are many places in the code where we are comparing and assigning
millisecond timer values (i.e. gotten via NoteGetMs) to size_t variables. This
is a bug. On some platforms (e.g. the Arduino Uno), size_t is 16 bits, so
assigning one of these 32-bit millisecond timer values to a 16-bit variable can
lead to undefined behavior when the timer value is larger than what can fit into
16 bits. This commit fixes all these bugs by using uint32_t instead of size_t.
@haydenroche5 haydenroche5 requested a review from zfields January 11, 2024 18:53
@haydenroche5 haydenroche5 self-assigned this Jan 11, 2024
@haydenroche5
Copy link
Collaborator Author

I'll have to dig into why the card.binary tests failed later. It looks like some part of my home HIL infrastructure is down.

@haydenroche5 haydenroche5 merged commit 9700000 into blues:master Jan 22, 2024
10 of 11 checks passed
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