summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-05-13 15:05:42 -0400
committerJune McEnroe <june@causal.agency>2018-05-13 15:05:42 -0400
commit46ca1b2c2d97e015e5adbb987aece10da0c5d917 (patch)
tree08f3003fe5a338de3a64ad9fa19d8e875410a8e8
parentAdd modem (diff)
downloadsrc-46ca1b2c2d97e015e5adbb987aece10da0c5d917.tar.gz
src-46ca1b2c2d97e015e5adbb987aece10da0c5d917.zip
Clean up modem loop
-rw-r--r--bin/modem.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/bin/modem.c b/bin/modem.c
index 11b447ea..c099119a 100644
--- a/bin/modem.c
+++ b/bin/modem.c
@@ -65,30 +65,22 @@ int main(int argc, char *argv[]) {
 		err(EX_NOINPUT, "%s", argv[1]);
 	}
 
-	for (;;) {
-		usleep(8 * 1000000 / BAUD_RATE);
-
-		struct pollfd fds[2] = {
-			{ .events = POLLIN, .fd = STDIN_FILENO },
-			{ .events = POLLIN, .fd = pty },
-		};
-		int n = poll(fds, 2, -1);
-		if (n < 0) err(EX_IOERR, "poll");
-
+	char c;
+	struct pollfd fds[2] = {
+		{ .events = POLLIN, .fd = STDIN_FILENO },
+		{ .events = POLLIN, .fd = pty },
+	};
+	while (usleep(8 * 1000000 / BAUD_RATE), 0 < poll(fds, 2, -1)) {
 		if (fds[0].revents) {
-			char c;
 			ssize_t size = read(STDIN_FILENO, &c, 1);
 			if (size < 0) err(EX_IOERR, "read(%d)", STDIN_FILENO);
-
 			size = write(pty, &c, 1);
 			if (size < 0) err(EX_IOERR, "write(%d)", pty);
 		}
 
 		if (fds[1].revents) {
-			char c;
 			ssize_t size = read(pty, &c, 1);
 			if (size < 0) err(EX_IOERR, "read(%d)", pty);
-
 			size = write(STDOUT_FILENO, &c, 1);
 			if (size < 0) err(EX_IOERR, "write(%d)", STDOUT_FILENO);
 		}
@@ -98,4 +90,5 @@ int main(int argc, char *argv[]) {
 		if (dead < 0) err(EX_OSERR, "waitpid");
 		if (dead) return WIFEXITED(status) ? WEXITSTATUS(status) : EX_SOFTWARE;
 	}
+	err(EX_IOERR, "poll");
 }
n>parsing: ban sprintf()Christian Hesse Git upstream bans sprintf() with commit: banned.h: mark sprintf() as banned cc8fdaee1eeaf05d8dd55ff11f111b815f673c58 Signed-off-by: Christian Hesse <mail@eworm.de> 2018-09-11parsing: ban strncpy()Christian Hesse Git upstream bans strncpy() with commit: banned.h: mark strncpy() as banned e488b7aba743d23b830d239dcc33d9ca0745a9ad Signed-off-by: Christian Hesse <mail@eworm.de> 2018-08-28filters: generate anchor links from markdownChristian Hesse This makes the markdown filter generate anchor links for headings. Signed-off-by: Christian Hesse <mail@eworm.de> Tested-by: jean-christophe manciot <actionmystique@gmail.com> 2018-08-03Bump version.Jason A. Donenfeld Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2018-08-03clone: fix directory traversalJason A. Donenfeld This was introduced in the initial version of this code, way back when in 2008. $ curl http://127.0.0.1/cgit/repo/objects/?path=../../../../../../../../../etc/passwd root:x:0:0:root:/root:/bin/sh ... Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Reported-by: Jann Horn <jannh@google.com> 2018-08-03config: record repo.snapshot-prefix in the per-repo configKonstantin Ryabitsev