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:
@@ -72,17 +72,17 @@ static void
|
|||||||
add_event_to_list(timer* event, timer* volatile* list)
|
add_event_to_list(timer* event, timer* volatile* list)
|
||||||
{
|
{
|
||||||
timer* next;
|
timer* next;
|
||||||
timer* last = NULL;
|
timer* previous = NULL;
|
||||||
|
|
||||||
// stick it in the event list
|
// 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)
|
if ((bigtime_t)next->schedule_time >= (bigtime_t)event->schedule_time)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last != NULL) {
|
if (previous != NULL) {
|
||||||
event->next = last->next;
|
event->next = previous->next;
|
||||||
last->next = event;
|
previous->next = event;
|
||||||
} else {
|
} else {
|
||||||
event->next = next;
|
event->next = next;
|
||||||
*list = event;
|
*list = event;
|
||||||
@@ -299,7 +299,6 @@ timer_interrupt()
|
|||||||
}
|
}
|
||||||
|
|
||||||
cpuData.current_event = NULL;
|
cpuData.current_event = NULL;
|
||||||
|
|
||||||
event = cpuData.events;
|
event = cpuData.events;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,20 +399,20 @@ cancel_timer(timer* event)
|
|||||||
if (event != cpuData.current_event) {
|
if (event != cpuData.current_event) {
|
||||||
// The timer hook is not yet being executed.
|
// The timer hook is not yet being executed.
|
||||||
timer* current = cpuData.events;
|
timer* current = cpuData.events;
|
||||||
timer* last = NULL;
|
timer* previous = NULL;
|
||||||
|
|
||||||
while (current != NULL) {
|
while (current != NULL) {
|
||||||
if (current == event) {
|
if (current == event) {
|
||||||
// we found it
|
// we found it
|
||||||
if (last == NULL)
|
if (previous == NULL)
|
||||||
cpuData.events = current->next;
|
cpuData.events = current->next;
|
||||||
else
|
else
|
||||||
last->next = current->next;
|
previous->next = current->next;
|
||||||
current->next = NULL;
|
current->next = NULL;
|
||||||
// break out of the whole thing
|
// break out of the whole thing
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
last = current;
|
previous = current;
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user