Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Pat Pannuto <[email protected]>
Co-authored-by: Branden Ghena <[email protected]>
  • Loading branch information
3 people committed Sep 20, 2024
1 parent 3237e14 commit 7ecf030
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/tests/multi_alarm_simple_overflow_test/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Test Multiple Alarms (With Overflow)

This tests the virtual alarms available to userspace. It sets two
alarms, first one that overflows the alarm, such that it's expiration
alarms, first one that overflows the alarm, such that its expiration
is small in absolute value (but should shouldn't fire until after the
clock overflows) and one after 1s. When successful, the second (1s)
alarm should fire after 1 second, while the second alarm should fire
alarm should fire after 1 second, while the first alarm should wait to fire until
after the clock overflows (approximately 7 minutes if the clock is at
32kHz).

Expand Down
4 changes: 2 additions & 2 deletions libtock/services/alarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static void root_insert(libtock_alarm_ticks_t* alarm) {
// Determine whether the clock overflows before the new alarm
// expires. Because ticks are 32-bit, a clock can overflow at most
// once before a 32-bit alarm fires.
bool new_overflows = alarm->reference > UINT32_MAX - alarm->dt;
bool new_overflows = alarm->reference > (UINT32_MAX - alarm->dt);

libtock_alarm_ticks_t** cur = &root;
libtock_alarm_ticks_t* prev = NULL;
Expand All @@ -98,7 +98,7 @@ static void root_insert(libtock_alarm_ticks_t* alarm) {
uint32_t cur_expiration = (*cur)->reference + (*cur)->dt;
// Determine whether the clock overflows before this alarm
// expires.
bool cur_overflows = (*cur)->reference > UINT32_MAX - (*cur)->dt;
bool cur_overflows = (*cur)->reference > (UINT32_MAX - (*cur)->dt);

// This alarm happens after the new alarm if:
// - neither expirations overflow and this expiration value is larger than the new expiration
Expand Down
2 changes: 1 addition & 1 deletion libtock/services/alarm.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern "C" {
// - `arg3` (`opaque`): An arbitrary user pointer passed back to the callback.
typedef void (*libtock_alarm_callback)(uint32_t, uint32_t, void*);

/** \brief Utility function for converting hardware-specific tics to milliseconds
/** \brief Utility function for converting hardware-specific ticks to milliseconds
*/
uint32_t libtock_alarm_ticks_to_ms(uint32_t);

Expand Down

0 comments on commit 7ecf030

Please sign in to comment.