From a22594e2af9643570be0bbacc1e0b89d8316c9a7 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 28 Dec 2019 16:06:41 -0600 Subject: Cleanup: use FLAG() macros and new argument variable names. --- toys/other/base64.c | 6 +++--- toys/other/free.c | 2 +- toys/other/ionice.c | 31 ++++++++++++++----------------- 3 files changed, 18 insertions(+), 21 deletions(-) (limited to 'toys/other') diff --git a/toys/other/base64.c b/toys/other/base64.c index f1b617d6..ef7854a1 100644 --- a/toys/other/base64.c +++ b/toys/other/base64.c @@ -48,7 +48,7 @@ static void do_base64(int fd, char *name) for (;;) { // If no more data, flush buffer if (!(len = xread(fd, buf, sizeof(toybuf)-128))) { - if (!(toys.optflags & FLAG_d)) { + if (!FLAG(d)) { if (bits) wraputchar(toybuf[out<<(6-bits)], &x); while (TT.total&3) wraputchar('=', &x); if (x) xputc('\n'); @@ -58,7 +58,7 @@ static void do_base64(int fd, char *name) } for (i=0; i>TT.bits); TT.buf += strlen(TT.buf)+1; diff --git a/toys/other/ionice.c b/toys/other/ionice.c index 37d35456..f356c5fe 100644 --- a/toys/other/ionice.c +++ b/toys/other/ionice.c @@ -40,26 +40,24 @@ config IORENICE #include GLOBALS( - long pid; - long level; - long class; + long p, n, c; ) static int ioprio_get(void) { - return syscall(__NR_ioprio_get, 1, (int)TT.pid); + return syscall(__NR_ioprio_get, 1, (int)TT.p); } static int ioprio_set(void) { - int prio = ((int)TT.class << 13) | (int)TT.level; + int prio = ((int)TT.c << 13) | (int)TT.n; - return syscall(__NR_ioprio_set, 1, (int)TT.pid, prio); + return syscall(__NR_ioprio_set, 1, (int)TT.p, prio); } void ionice_main(void) { - if (!TT.pid && !toys.optc) error_exit("Need -p or COMMAND"); + if (!TT.p && !toys.optc) error_exit("Need -p or COMMAND"); if (toys.optflags == FLAG_p) { int p = ioprio_get(); xprintf("%s: prio %d\n", @@ -67,7 +65,7 @@ void ionice_main(void) p&7); } else { if (-1 == ioprio_set() && !(toys.optflags&FLAG_t)) perror_exit("set"); - if (!TT.pid) xexec(toys.optargs); + if (!TT.p) xexec(toys.optargs); } } @@ -75,23 +73,22 @@ void iorenice_main(void) { char *classes[] = {"none", "rt", "be", "idle"}; - TT.pid = atolx(*toys.optargs); + TT.p = atolx(*toys.optargs); if (toys.optc == 1) { int p = ioprio_get(); if (p == -1) perror_exit("read priority"); - TT.class = (p>>13)&3; + TT.c = (p>>13)&3; p &= 7; - xprintf("Pid %ld, class %s (%ld), prio %d\n", - TT.pid, classes[TT.class], TT.class, p); + xprintf("Pid %ld, class %s (%ld), prio %d\n", TT.p, classes[TT.c], TT.c, p); return; } - for (TT.class = 0; TT.class<4; TT.class++) - if (!strcmp(toys.optargs[toys.optc-1], classes[TT.class])) break; - if (toys.optc == 3 || TT.class == 4) TT.level = atolx(toys.optargs[1]); - else TT.level = 4; - TT.class &= 3; + for (TT.c = 0; TT.c<4; TT.c++) + if (!strcmp(toys.optargs[toys.optc-1], classes[TT.c])) break; + if (toys.optc == 3 || TT.c == 4) TT.n = atolx(toys.optargs[1]); + else TT.n = 4; + TT.c &= 3; if (-1 == ioprio_set()) perror_exit("set"); } -- cgit v1.2.3