diff options
author | Mattias Andrée <maandree@kth.se> | 2021-09-16 18:52:54 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-09-16 18:52:54 +0200 |
commit | 1eb2f48c275a7e5f572b86c615dffb64bdfab1e8 (patch) | |
tree | a0efeb2638733473c84f21e493668b87e5a84ecb /yes.c | |
parent | Add limit.c: get the highest rate possible (diff) | |
download | yes-silly-1eb2f48c275a7e5f572b86c615dffb64bdfab1e8.tar.gz yes-silly-1eb2f48c275a7e5f572b86c615dffb64bdfab1e8.tar.bz2 yes-silly-1eb2f48c275a7e5f572b86c615dffb64bdfab1e8.tar.xz |
Add makefile and gitignore + update copyright year + m style fix + fix warnings + fix limit which had stopped working
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | yes.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -1,6 +1,4 @@ /* See LICENSE file for copyright and license details. */ - -#define _GNU_SOURCE #include <sys/ioctl.h> #include <sys/uio.h> #include <alloca.h> @@ -17,7 +15,7 @@ #endif -static char *argv0; +static const char *argv0; static void (*writeall)(char *, size_t); @@ -55,8 +53,9 @@ writeall_vmsplice(char *buf, size_t n) #endif int -main(int argc, char *argv[]) +main(int argc, const char **argv) { + const char *argvbuf[3] = {NULL, "y", NULL}; size_t n, len, m = 0, p, cap = 0; char *buf, *b; int i, sz, fds[2], flags; @@ -67,7 +66,8 @@ main(int argc, char *argv[]) argv0 = argv[0] ? argv[0] : "yes"; if (argc == 1) { argc = 2; - argv = (char *[]){argv0, "y"}; + argvbuf[0] = argv0; + argv = argvbuf; } n = (size_t)(argc - 1); @@ -141,10 +141,9 @@ main(int argc, char *argv[]) } fallback: - for (p = 0;; p = (p + (size_t)r) % len) { + for (p = 0;; p = (p + (size_t)r) % len) if ((r = write(STDOUT_FILENO, buf + p, len - p)) < 0) goto fail; - } return 0; |