patch 8.2.0523: loops are repeated
Problem: Loops are repeated.
Solution: Use FOR_ALL_ macros. (Yegappan Lakshmanan, closes #5882)
diff --git a/src/time.c b/src/time.c
index 2706ac2..bf6801f 100644
--- a/src/time.c
+++ b/src/time.c
@@ -21,6 +21,9 @@
static char tz_cache[64];
#endif
+#define FOR_ALL_TIMERS(t) \
+ for ((t) = first_timer; (t) != NULL; (t) = (t)->tr_next)
+
/*
* Call either localtime(3) or localtime_r(3) from POSIX libc time.h, with the
* latter version preferred for reentrancy.
@@ -583,7 +586,7 @@
if (id >= 0)
{
- for (timer = first_timer; timer != NULL; timer = timer->tr_next)
+ FOR_ALL_TIMERS(timer)
if (timer->tr_id == id)
return timer;
}
@@ -659,7 +662,7 @@
{
timer_T *timer;
- for (timer = first_timer; timer != NULL; timer = timer->tr_next)
+ FOR_ALL_TIMERS(timer)
if (timer->tr_id != -1)
add_timer_info(rettv, timer);
}