diff options
-rw-r--r-- | toys/other/base64.c | 6 | ||||
-rw-r--r-- | toys/other/free.c | 2 | ||||
-rw-r--r-- | toys/other/ionice.c | 31 |
3 files changed, 18 insertions, 21 deletions
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<len; i++) { - if (toys.optflags & FLAG_d) { + if (FLAG(d)) { if (buf[i] == '=') return; if ((x = stridx(toybuf, buf[i])) != -1) { @@ -72,7 +72,7 @@ static void do_base64(int fd, char *name) continue; } - if (buf[i] == '\n' || (toys.optflags & FLAG_i)) continue; + if (buf[i] == '\n' || FLAG(i)) continue; break; } else { diff --git a/toys/other/free.c b/toys/other/free.c index ce0df020..d76e050d 100644 --- a/toys/other/free.c +++ b/toys/other/free.c @@ -31,7 +31,7 @@ static char *convert(unsigned long d) long long ll = d*TT.units; char *s = TT.buf; - if (toys.optflags & FLAG_h) human_readable(s, ll, 0); + if (FLAG(h)) human_readable(s, ll, 0); else sprintf(s, "%llu",ll>>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 <sys/syscall.h> 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"); } |