From 906a6caa1367ca981ddc1c3fdf905bdd03fb39e2 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Tue, 6 Sep 2016 21:36:05 +0800 Subject: [PATCH] Main goto loop to for loop Thanks to quinq http://lists.suckless.org/hackers/1609/12073.html --- spt.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/spt.c b/spt.c index abbcc47..b251db0 100644 --- a/spt.c +++ b/spt.c @@ -129,14 +129,11 @@ main(int argc, char *argv[]) if (signal(SIGUSR2, SIG_IGN) != SIG_IGN) signal(SIGUSR2, toggle); -run: - notify_send(timers[i].cmt); - - for (timecount = 0; timecount < timers[i].tmr; timecount += inc) - sleep(1); - - if (++i >= LEN(timers)) i = 0; /* i infinal loop */ - goto run; + for (i = 0; ; i = (i + 1) % LEN(timers)) { + notify_send(timers[i].cmt); + for (timecount = 0; timecount < timers[i].tmr; timecount += inc) + sleep(1); + } return 0; }