commit 16ace04d459b77fc14ca5b14125ac955769ed72c from: Omar Polo date: Fri Jan 08 16:59:50 2021 UTC simplify loop todo was initially there for an optimization: don't loop to MAX_USERS when you know the upper limit is todo. commit - 4c4167393a95834cdd3af280136c3a0a60752648 commit + 16ace04d459b77fc14ca5b14125ac955769ed72c blob - 6da052ae5219e4a7e46f498edd6cf3576e27a35f blob + 346333c39c7b984387caa49b05982a45eac18a26 --- gmid.c +++ gmid.c @@ -702,7 +702,7 @@ goodbye(struct pollfd *pfd, struct client *c) void loop(struct tls *ctx, int sock) { - int i, todo; + int i; struct client clients[MAX_USERS]; struct pollfd fds[MAX_USERS]; @@ -715,7 +715,7 @@ loop(struct tls *ctx, int sock) fds[0].fd = sock; for (;;) { - if ((todo = poll(fds, MAX_USERS, INFTIM)) == -1) { + if (poll(fds, MAX_USERS, INFTIM) == -1) { if (errno == EINTR) { warnx("connected clients: %d", connected_clients); @@ -725,8 +725,6 @@ loop(struct tls *ctx, int sock) } for (i = 0; i < MAX_USERS; i++) { - assert(i < MAX_USERS); - if (fds[i].revents == 0) continue; @@ -743,8 +741,6 @@ loop(struct tls *ctx, int sock) } } - todo--; - if (i == 0) { /* new client */ do_accept(sock, ctx, fds, clients); continue;