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:
+11
-12
@@ -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;
|
||||||
@@ -282,13 +282,13 @@ timer_interrupt()
|
|||||||
acquire_spinlock(spinlock);
|
acquire_spinlock(spinlock);
|
||||||
|
|
||||||
if ((mode & ~B_TIMER_FLAGS) == B_PERIODIC_TIMER
|
if ((mode & ~B_TIMER_FLAGS) == B_PERIODIC_TIMER
|
||||||
&& cpuData.current_event != NULL) {
|
&& cpuData.current_event != NULL) {
|
||||||
// we need to adjust it and add it back to the list
|
// we need to adjust it and add it back to the list
|
||||||
event->schedule_time += event->period;
|
event->schedule_time += event->period;
|
||||||
|
|
||||||
// If the new schedule time is a full interval or more in the past,
|
// If the new schedule time is a full interval or more in the past,
|
||||||
// skip ticks.
|
// skip ticks.
|
||||||
bigtime_t now = system_time();
|
bigtime_t now = system_time();
|
||||||
if (now >= event->schedule_time + event->period) {
|
if (now >= event->schedule_time + event->period) {
|
||||||
// pick the closest tick in the past
|
// pick the closest tick in the past
|
||||||
event->schedule_time = now
|
event->schedule_time = now
|
||||||
@@ -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