From ff783628268470acc02e52126d6a357691723fba Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Mon, 30 Mar 2020 19:44:45 -0400 Subject: Replace some declaration; while loops with for loops I should have been using this for getopt loops already but the call here is slightly too long to fit on one line as a for loop. --- chat.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'chat.c') diff --git a/chat.c b/chat.c index 258dde2..b7bf91b 100644 --- a/chat.c +++ b/chat.c @@ -88,8 +88,7 @@ static void execRead(void) { if (len < 0) err(EX_IOERR, "read"); if (!len) return; buf[len] = '\0'; - char *ptr = buf; - while (ptr) { + for (char *ptr = buf; ptr;) { char *line = strsep(&ptr, "\n"); if (line[0]) command(execID, line); } @@ -101,8 +100,7 @@ static void utilRead(void) { if (len < 0) err(EX_IOERR, "read"); if (!len) return; buf[len] = '\0'; - char *ptr = buf; - while (ptr) { + for (char *ptr = buf; ptr;) { char *line = strsep(&ptr, "\n"); if (line[0]) uiFormat(Network, Warm, NULL, "%s", line); } @@ -287,8 +285,7 @@ int main(int argc, char *argv[]) { if (signals[SIGCHLD]) { signals[SIGCHLD] = 0; - int status; - while (0 < waitpid(-1, &status, WNOHANG)) { + for (int status; 0 < waitpid(-1, &status, WNOHANG);) { if (WIFEXITED(status) && WEXITSTATUS(status)) { uiFormat( Network, Warm, NULL, -- cgit 1.4.1