kernel/timer: Rename "last" to "previous".

It points to the previous list item, not the last (final) one.
No functional change intended, but improves code readability.
This commit is contained in:
Augustin Cavalier
2024-07-17 13:41:04 -04:00
parent 2b916f6121
commit 911f99e2d6
+9 -10
View File
@@ -72,17 +72,17 @@ static void
add_event_to_list(timer* event, timer* volatile* list)
{
timer* next;
timer* last = NULL;
timer* previous = NULL;
// stick it in the event list
for (next = *list; next; last = next, next = (timer*)next->next) {
for (next = *list; next != NULL; previous = next, next = (timer*)next->next) {
if ((bigtime_t)next->schedule_time >= (bigtime_t)event->schedule_time)
break;
}
if (last != NULL) {
event->next = last->next;
last->next = event;
if (previous != NULL) {
event->next = previous->next;
previous->next = event;
} else {
event->next = next;
*list = event;
@@ -299,7 +299,6 @@ timer_interrupt()
}
cpuData.current_event = NULL;
event = cpuData.events;
}
@@ -400,20 +399,20 @@ cancel_timer(timer* event)
if (event != cpuData.current_event) {
// The timer hook is not yet being executed.
timer* current = cpuData.events;
timer* last = NULL;
timer* previous = NULL;
while (current != NULL) {
if (current == event) {
// we found it
if (last == NULL)
if (previous == NULL)
cpuData.events = current->next;
else
last->next = current->next;
previous->next = current->next;
current->next = NULL;
// break out of the whole thing
break;
}
last = current;
previous = current;
current = current->next;
}