From 1ea6e127d5a3f0fa4ef4e423505cd5552fee7092 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 11 Feb 2022 19:22:30 -0600 Subject: [PATCH] Minor cleanups. --- toys/other/fsync.c | 7 +++---- toys/other/ionice.c | 3 ++- toys/other/pmap.c | 6 +++--- toys/other/truncate.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/toys/other/fsync.c b/toys/other/fsync.c index d7812b90..e155b605 100644 --- a/toys/other/fsync.c +++ b/toys/other/fsync.c @@ -12,9 +12,9 @@ config FSYNC help usage: fsync [-d] [FILE...] - Synchronize a file's in-core state with storage device. + Flush disk cache for FILE(s), writing cached data to storage device. - -d Avoid syncing metadata + -d Skip directory info (sync file contents only). */ #define FOR_fsync @@ -22,8 +22,7 @@ config FSYNC static void do_fsync(int fd, char *name) { - if (((toys.optflags & FLAG_d) ? fdatasync(fd) : fsync(fd))) - perror_msg("can't sync '%s'", name); + if (FLAG(d) ? fdatasync(fd) : fsync(fd)) perror_msg("can't sync '%s'", name); } void fsync_main(void) diff --git a/toys/other/ionice.c b/toys/other/ionice.c index d313930e..07a212b2 100644 --- a/toys/other/ionice.c +++ b/toys/other/ionice.c @@ -59,11 +59,12 @@ void ionice_main(void) 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", (char *[]){"unknown", "Realtime", "Best-effort", "Idle"}[(p>>13)&3], p&7); } else { - if (-1 == ioprio_set() && !(toys.optflags&FLAG_t)) perror_exit("set"); + if (-1 == ioprio_set() && !FLAG(t)) perror_exit("set"); if (!TT.p) xexec(toys.optargs); } } diff --git a/toys/other/pmap.c b/toys/other/pmap.c index 5ccda4bb..d222f010 100644 --- a/toys/other/pmap.c +++ b/toys/other/pmap.c @@ -28,7 +28,7 @@ config PMAP void pmap_main(void) { char **optargs, *line = 0; - size_t allocated_length = 0; + size_t len = 0; for (optargs = toys.optargs; *optargs; optargs++) { long long start, end, pss, tpss=0, dirty, tdirty=0, swap, tswap=0, total=0; @@ -46,7 +46,7 @@ void pmap_main(void) free(name); // Only bother scanning the more verbose smaps file in -x mode. - sprintf(toybuf, "/proc/%u/%smaps", pid, FLAG(x) ? "s" : ""); + sprintf(toybuf, "/proc/%u/%smaps", pid, "s"+!FLAG(x)); if (!(fp = fopen(toybuf, "r"))) { error_msg("no %s", toybuf); continue; @@ -56,7 +56,7 @@ void pmap_main(void) xprintf("Address%*cKbytes PSS Dirty Swap Mode Mapping\n", (int)(sizeof(long)*2)-5, ' '); - while (getline(&line, &allocated_length, fp) > 0) { + while (getline(&line, &len, fp) > 0) { count = sscanf(line, "%llx-%llx %4s %*s %*s %*s %n", &start, &end, mode, &off); if (count == 3) { diff --git a/toys/other/truncate.c b/toys/other/truncate.c index 40eb1e59..7adeb62d 100644 --- a/toys/other/truncate.c +++ b/toys/other/truncate.c @@ -53,7 +53,7 @@ static void do_truncate(int fd, char *name) void truncate_main(void) { - int cr = !(toys.optflags&FLAG_c); + int cr = !FLAG(c); if (-1 != (TT.type = stridx("+-<>/%", *TT.s))) TT.s++; TT.size = atolx(TT.s); -- 2.39.2