From 7ecf0302a925987e708e028cb4bd731592ff7c65 Mon Sep 17 00:00:00 2001 From: Amit Levy Date: Fri, 20 Sep 2024 11:02:36 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Pat Pannuto Co-authored-by: Branden Ghena --- examples/tests/multi_alarm_simple_overflow_test/README.md | 4 ++-- libtock/services/alarm.c | 4 ++-- libtock/services/alarm.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/tests/multi_alarm_simple_overflow_test/README.md b/examples/tests/multi_alarm_simple_overflow_test/README.md index 34b41cec1..4375d00eb 100644 --- a/examples/tests/multi_alarm_simple_overflow_test/README.md +++ b/examples/tests/multi_alarm_simple_overflow_test/README.md @@ -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). diff --git a/libtock/services/alarm.c b/libtock/services/alarm.c index e86fb10bb..5bce5b4a9 100644 --- a/libtock/services/alarm.c +++ b/libtock/services/alarm.c @@ -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; @@ -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 diff --git a/libtock/services/alarm.h b/libtock/services/alarm.h index 285abca7e..6487e3140 100644 --- a/libtock/services/alarm.h +++ b/libtock/services/alarm.h @@ -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);