Refactor, use LIST_FOREACH_SAFE() instead of while() in uev_exit()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2018-09-01 18:55:22 +02:00
1 parent 2ff15101ae
commit d3e5900f73
1 file changed
+4 -3
+4 -3
View File
@@ -203,14 +203,14 @@ int uev_init(uev_ctx_t *ctx)
*/
int uev_exit(uev_ctx_t *ctx)
{
uev_t *w, *next;
if (!ctx) {
errno = EINVAL;
return -1;
}
while (!LIST_EMPTY(&ctx->watchers)) {
uev_t *w = LIST_FIRST(&ctx->watchers);
LIST_FOREACH_SAFE(w, &ctx->watchers, link, next) {
/* Remove from internal list */
LIST_REMOVE(w, link);
@@ -233,6 +233,7 @@ int uev_exit(uev_ctx_t *ctx)
}
}
LIST_INIT(&ctx->watchers);
ctx->running = 0;
close(ctx->fd);
ctx->fd = -1;