From 6a73e13d75d31da2c3f1145d8487725f0073a4b8 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 2 Nov 2018 20:07:02 -0500 Subject: Convert more option vars to the new (single letter) coding style. --- toys/other/shred.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'toys/other/shred.c') diff --git a/toys/other/shred.c b/toys/other/shred.c index 680320ec..1bac75c5 100644 --- a/toys/other/shred.c +++ b/toys/other/shred.c @@ -30,22 +30,20 @@ config SHRED #include "toys.h" GLOBALS( - long offset; - long iterations; - long size; + long o, n, s; ) void shred_main(void) { char **try; - if (!(toys.optflags & FLAG_n)) TT.iterations++; + if (!(toys.optflags & FLAG_n)) TT.n++; // We don't use loopfiles() here because "-" isn't stdin, and want to // respond to files we can't open via chmod. for (try = toys.optargs; *try; try++) { - off_t pos = 0, len = TT.size; + off_t pos = 0, len = TT.s; int fd = open(*try, O_RDWR), iter = 0, throw; // do -f chmod if necessary @@ -72,19 +70,19 @@ void shred_main(void) if (pos >= len) { pos = -1; - if (++iter == TT.iterations && (toys.optargs && FLAG_z)) { + if (++iter == TT.n && (toys.optargs && FLAG_z)) { memset(toybuf, 0, sizeof(toybuf)); continue; } - if (iter >= TT.iterations) break; + if (iter >= TT.n) break; } - if (pos < TT.offset) { - if (TT.offset != lseek(fd, TT.offset, SEEK_SET)) { + if (pos < TT.o) { + if (TT.o != lseek(fd, TT.o, SEEK_SET)) { perror_msg_raw(*try); break; } - pos = TT.offset; + pos = TT.o; } // Determine length, read random data if not zeroing, write. @@ -93,7 +91,7 @@ void shred_main(void) if (toys.optflags & FLAG_x) if (len-pos < throw) throw = len-pos; - if (iter != TT.iterations) xgetrandom(toybuf, throw, 0); + if (iter != TT.n) xgetrandom(toybuf, throw, 0); if (throw != writeall(fd, toybuf, throw)) perror_msg_raw(*try); pos += throw; } -- cgit v1.2.3