diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-15 10:39:33 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-15 10:39:33 +0200 |
commit | e47000490c30109db1d571bcab12f385cd0139e5 (patch) | |
tree | a2cd5ab7bdc26920a8f2b20ae7d8e57c7aa8bf3c | |
parent | 1f60d88cf6f5ad3efcad6e7ef1501ce334046e40 (diff) | |
download | busybox-w32-e47000490c30109db1d571bcab12f385cd0139e5.tar.gz busybox-w32-e47000490c30109db1d571bcab12f385cd0139e5.tar.bz2 busybox-w32-e47000490c30109db1d571bcab12f385cd0139e5.zip |
shuf: simplify check that we have at least one FILE
function old new delta
.rodata 103190 103194 +4
packed_usage 33541 33537 -4
shred_main 354 337 -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 4/-21) Total: -17 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/shred.c | 7 | ||||
-rw-r--r-- | miscutils/strings.c | 4 |
2 files changed, 4 insertions, 7 deletions
diff --git a/coreutils/shred.c b/coreutils/shred.c index 8f3d9c5c9..69fb3e8cc 100644 --- a/coreutils/shred.c +++ b/coreutils/shred.c | |||
@@ -15,7 +15,7 @@ | |||
15 | //kbuild:lib-$(CONFIG_SHRED) += shred.o | 15 | //kbuild:lib-$(CONFIG_SHRED) += shred.o |
16 | 16 | ||
17 | //usage:#define shred_trivial_usage | 17 | //usage:#define shred_trivial_usage |
18 | //usage: "FILE..." | 18 | //usage: "[-fuz] [-n N] FILE..." |
19 | //usage:#define shred_full_usage "\n\n" | 19 | //usage:#define shred_full_usage "\n\n" |
20 | //usage: "Overwrite/delete FILEs\n" | 20 | //usage: "Overwrite/delete FILEs\n" |
21 | //usage: "\n -f Chmod to ensure writability" | 21 | //usage: "\n -f Chmod to ensure writability" |
@@ -54,16 +54,13 @@ int shred_main(int argc UNUSED_PARAM, char **argv) | |||
54 | OPT_x = (1 << 5), | 54 | OPT_x = (1 << 5), |
55 | }; | 55 | }; |
56 | 56 | ||
57 | opt = getopt32(argv, "fuzn:+vx", &num_iter); | 57 | opt = getopt32(argv, "^" "fuzn:+vx" "\0" "-1"/*min 1 arg*/, &num_iter); |
58 | argv += optind; | 58 | argv += optind; |
59 | 59 | ||
60 | zero_fd = xopen("/dev/zero", O_RDONLY); | 60 | zero_fd = xopen("/dev/zero", O_RDONLY); |
61 | if (num_iter != 0) | 61 | if (num_iter != 0) |
62 | rand_fd = xopen("/dev/urandom", O_RDONLY); | 62 | rand_fd = xopen("/dev/urandom", O_RDONLY); |
63 | 63 | ||
64 | if (!*argv) | ||
65 | bb_show_usage(); | ||
66 | |||
67 | for (;;) { | 64 | for (;;) { |
68 | struct stat sb; | 65 | struct stat sb; |
69 | const char *fname; | 66 | const char *fname; |
diff --git a/miscutils/strings.c b/miscutils/strings.c index e4a68227e..b01884968 100644 --- a/miscutils/strings.c +++ b/miscutils/strings.c | |||
@@ -18,7 +18,7 @@ | |||
18 | //kbuild:lib-$(CONFIG_STRINGS) += strings.o | 18 | //kbuild:lib-$(CONFIG_STRINGS) += strings.o |
19 | 19 | ||
20 | //usage:#define strings_trivial_usage | 20 | //usage:#define strings_trivial_usage |
21 | //usage: "[-fo] [-t o/d/x] [-n LEN] [FILE]..." | 21 | //usage: "[-fo] [-t o|d|x] [-n LEN] [FILE]..." |
22 | //usage:#define strings_full_usage "\n\n" | 22 | //usage:#define strings_full_usage "\n\n" |
23 | //usage: "Display printable strings in a binary file\n" | 23 | //usage: "Display printable strings in a binary file\n" |
24 | //We usually don't bother user with "nop" options. They work, but are not shown: | 24 | //We usually don't bother user with "nop" options. They work, but are not shown: |
@@ -26,7 +26,7 @@ | |||
26 | //unimplemented alternative is -d: Only strings from initialized, loaded data sections | 26 | //unimplemented alternative is -d: Only strings from initialized, loaded data sections |
27 | //usage: "\n -f Precede strings with filenames" | 27 | //usage: "\n -f Precede strings with filenames" |
28 | //usage: "\n -o Precede strings with octal offsets" | 28 | //usage: "\n -o Precede strings with octal offsets" |
29 | //usage: "\n -t o/d/x Precede strings with offsets in base 8/10/16" | 29 | //usage: "\n -t o|d|x Precede strings with offsets in base 8/10/16" |
30 | //usage: "\n -n LEN At least LEN characters form a string (default 4)" | 30 | //usage: "\n -n LEN At least LEN characters form a string (default 4)" |
31 | 31 | ||
32 | #include "libbb.h" | 32 | #include "libbb.h" |