diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-28 15:18:53 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-28 15:18:53 +0100 |
commit | e992bae6f9adf3718c6263a36c004ead1c7272a8 (patch) | |
tree | f0bc9e4fa145f58ab3f9838902e09f9cfba29648 | |
parent | 86cfb70ca5f2bde11f2d071bc59db75291d8552f (diff) | |
download | busybox-w32-e992bae6f9adf3718c6263a36c004ead1c7272a8.tar.gz busybox-w32-e992bae6f9adf3718c6263a36c004ead1c7272a8.tar.bz2 busybox-w32-e992bae6f9adf3718c6263a36c004ead1c7272a8.zip |
*: remove a few more cases of argc usage. -89 bytes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | console-tools/chvt.c | 11 | ||||
-rw-r--r-- | coreutils/chroot.c | 10 | ||||
-rw-r--r-- | coreutils/df.c | 4 | ||||
-rw-r--r-- | coreutils/dirname.c | 9 | ||||
-rw-r--r-- | coreutils/dos2unix.c | 8 | ||||
-rw-r--r-- | coreutils/ln.c | 19 | ||||
-rw-r--r-- | coreutils/mkdir.c | 8 | ||||
-rw-r--r-- | coreutils/nohup.c | 4 | ||||
-rw-r--r-- | coreutils/stat.c | 22 | ||||
-rw-r--r-- | coreutils/stty.c | 8 | ||||
-rw-r--r-- | coreutils/yes.c | 5 | ||||
-rw-r--r-- | include/libbb.h | 1 | ||||
-rw-r--r-- | libbb/Kbuild | 1 | ||||
-rw-r--r-- | libbb/single_argv.c | 16 | ||||
-rw-r--r-- | miscutils/adjtimex.c | 8 | ||||
-rw-r--r-- | miscutils/raidautorun.c | 8 | ||||
-rw-r--r-- | miscutils/rx.c | 7 | ||||
-rw-r--r-- | runit/runsv.c | 4 | ||||
-rw-r--r-- | util-linux/fdisk.c | 11 | ||||
-rw-r--r-- | util-linux/freeramdisk.c | 8 |
20 files changed, 79 insertions, 93 deletions
diff --git a/console-tools/chvt.c b/console-tools/chvt.c index 302ffb4f9..977c26905 100644 --- a/console-tools/chvt.c +++ b/console-tools/chvt.c | |||
@@ -6,19 +6,12 @@ | |||
6 | * | 6 | * |
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | */ | 8 | */ |
9 | |||
10 | #include "libbb.h" | 9 | #include "libbb.h" |
11 | 10 | ||
12 | int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 11 | int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
13 | int chvt_main(int argc, char **argv) | 12 | int chvt_main(int argc UNUSED_PARAM, char **argv) |
14 | { | 13 | { |
15 | int num; | 14 | int num = xatou_range(single_argv(argv), 1, 63); |
16 | |||
17 | if (argc != 2) { | ||
18 | bb_show_usage(); | ||
19 | } | ||
20 | |||
21 | num = xatou_range(argv[1], 1, 63); | ||
22 | console_make_active(get_console_fd_or_die(), num); | 15 | console_make_active(get_console_fd_or_die(), num); |
23 | return EXIT_SUCCESS; | 16 | return EXIT_SUCCESS; |
24 | } | 17 | } |
diff --git a/coreutils/chroot.c b/coreutils/chroot.c index 9b3d70044..f7228a61a 100644 --- a/coreutils/chroot.c +++ b/coreutils/chroot.c | |||
@@ -12,18 +12,16 @@ | |||
12 | #include "libbb.h" | 12 | #include "libbb.h" |
13 | 13 | ||
14 | int chroot_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 14 | int chroot_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
15 | int chroot_main(int argc, char **argv) | 15 | int chroot_main(int argc UNUSED_PARAM, char **argv) |
16 | { | 16 | { |
17 | if (argc < 2) { | ||
18 | bb_show_usage(); | ||
19 | } | ||
20 | |||
21 | ++argv; | 17 | ++argv; |
18 | if (!*argv) | ||
19 | bb_show_usage(); | ||
22 | xchroot(*argv); | 20 | xchroot(*argv); |
23 | xchdir("/"); | 21 | xchdir("/"); |
24 | 22 | ||
25 | ++argv; | 23 | ++argv; |
26 | if (argc == 2) { | 24 | if (!*argv) { /* no 2nd param (PROG), use shell */ |
27 | argv -= 2; | 25 | argv -= 2; |
28 | argv[0] = getenv("SHELL"); | 26 | argv[0] = getenv("SHELL"); |
29 | if (!argv[0]) { | 27 | if (!argv[0]) { |
diff --git a/coreutils/df.c b/coreutils/df.c index a0e6fe070..11a739816 100644 --- a/coreutils/df.c +++ b/coreutils/df.c | |||
@@ -35,7 +35,7 @@ static unsigned long kscale(unsigned long b, unsigned long bs) | |||
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | int df_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 37 | int df_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
38 | int df_main(int argc, char **argv) | 38 | int df_main(int argc UNUSED_PARAM, char **argv) |
39 | { | 39 | { |
40 | unsigned long blocks_used; | 40 | unsigned long blocks_used; |
41 | unsigned blocks_percent_used; | 41 | unsigned blocks_percent_used; |
@@ -105,7 +105,7 @@ int df_main(int argc, char **argv) | |||
105 | 105 | ||
106 | mount_table = NULL; | 106 | mount_table = NULL; |
107 | argv += optind; | 107 | argv += optind; |
108 | if (optind >= argc) { | 108 | if (!argv[0]) { |
109 | mount_table = setmntent(bb_path_mtab_file, "r"); | 109 | mount_table = setmntent(bb_path_mtab_file, "r"); |
110 | if (!mount_table) | 110 | if (!mount_table) |
111 | bb_perror_msg_and_die(bb_path_mtab_file); | 111 | bb_perror_msg_and_die(bb_path_mtab_file); |
diff --git a/coreutils/dirname.c b/coreutils/dirname.c index 1f5f70dfd..94c22a7ee 100644 --- a/coreutils/dirname.c +++ b/coreutils/dirname.c | |||
@@ -15,13 +15,8 @@ | |||
15 | /* This is a NOFORK applet. Be very careful! */ | 15 | /* This is a NOFORK applet. Be very careful! */ |
16 | 16 | ||
17 | int dirname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 17 | int dirname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
18 | int dirname_main(int argc, char **argv) | 18 | int dirname_main(int argc UNUSED_PARAM, char **argv) |
19 | { | 19 | { |
20 | if (argc != 2) { | 20 | puts(dirname(single_argv(argv))); |
21 | bb_show_usage(); | ||
22 | } | ||
23 | |||
24 | puts(dirname(argv[1])); | ||
25 | |||
26 | return fflush_all(); | 21 | return fflush_all(); |
27 | } | 22 | } |
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c index baf879e54..1911f5319 100644 --- a/coreutils/dos2unix.c +++ b/coreutils/dos2unix.c | |||
@@ -69,7 +69,7 @@ static void convert(char *fn, int conv_type) | |||
69 | } | 69 | } |
70 | 70 | ||
71 | int dos2unix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 71 | int dos2unix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
72 | int dos2unix_main(int argc, char **argv) | 72 | int dos2unix_main(int argc UNUSED_PARAM, char **argv) |
73 | { | 73 | { |
74 | int o, conv_type; | 74 | int o, conv_type; |
75 | 75 | ||
@@ -88,11 +88,11 @@ int dos2unix_main(int argc, char **argv) | |||
88 | if (o) | 88 | if (o) |
89 | conv_type = o; | 89 | conv_type = o; |
90 | 90 | ||
91 | argv += optind; | ||
91 | do { | 92 | do { |
92 | /* might be convert(NULL) if there is no filename given */ | 93 | /* might be convert(NULL) if there is no filename given */ |
93 | convert(argv[optind], conv_type); | 94 | convert(*argv, conv_type); |
94 | optind++; | 95 | } while (*++argv); |
95 | } while (optind < argc); | ||
96 | 96 | ||
97 | return 0; | 97 | return 0; |
98 | } | 98 | } |
diff --git a/coreutils/ln.c b/coreutils/ln.c index eb7171959..f977aa177 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c | |||
@@ -26,7 +26,7 @@ int ln_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | |||
26 | int ln_main(int argc, char **argv) | 26 | int ln_main(int argc, char **argv) |
27 | { | 27 | { |
28 | int status = EXIT_SUCCESS; | 28 | int status = EXIT_SUCCESS; |
29 | int flag; | 29 | int opts; |
30 | char *last; | 30 | char *last; |
31 | char *src_name; | 31 | char *src_name; |
32 | char *src; | 32 | char *src; |
@@ -34,11 +34,8 @@ int ln_main(int argc, char **argv) | |||
34 | struct stat statbuf; | 34 | struct stat statbuf; |
35 | int (*link_func)(const char *, const char *); | 35 | int (*link_func)(const char *, const char *); |
36 | 36 | ||
37 | flag = getopt32(argv, "sfnbS:", &suffix); | 37 | opt_complementary = "-1"; /* min one arg */ |
38 | 38 | opts = getopt32(argv, "sfnbS:", &suffix); | |
39 | if (argc == optind) { | ||
40 | bb_show_usage(); | ||
41 | } | ||
42 | 39 | ||
43 | last = argv[argc - 1]; | 40 | last = argv[argc - 1]; |
44 | argv += optind; | 41 | argv += optind; |
@@ -53,7 +50,7 @@ int ln_main(int argc, char **argv) | |||
53 | src = last; | 50 | src = last; |
54 | 51 | ||
55 | if (is_directory(src, | 52 | if (is_directory(src, |
56 | (flag & LN_NODEREFERENCE) ^ LN_NODEREFERENCE, | 53 | (opts & LN_NODEREFERENCE) ^ LN_NODEREFERENCE, |
57 | NULL) | 54 | NULL) |
58 | ) { | 55 | ) { |
59 | src_name = xstrdup(*argv); | 56 | src_name = xstrdup(*argv); |
@@ -61,7 +58,7 @@ int ln_main(int argc, char **argv) | |||
61 | free(src_name); | 58 | free(src_name); |
62 | src_name = src; | 59 | src_name = src; |
63 | } | 60 | } |
64 | if (!(flag & LN_SYMLINK) && stat(*argv, &statbuf)) { | 61 | if (!(opts & LN_SYMLINK) && stat(*argv, &statbuf)) { |
65 | // coreutils: "ln dangling_symlink new_hardlink" works | 62 | // coreutils: "ln dangling_symlink new_hardlink" works |
66 | if (lstat(*argv, &statbuf) || !S_ISLNK(statbuf.st_mode)) { | 63 | if (lstat(*argv, &statbuf) || !S_ISLNK(statbuf.st_mode)) { |
67 | bb_simple_perror_msg(*argv); | 64 | bb_simple_perror_msg(*argv); |
@@ -71,7 +68,7 @@ int ln_main(int argc, char **argv) | |||
71 | } | 68 | } |
72 | } | 69 | } |
73 | 70 | ||
74 | if (flag & LN_BACKUP) { | 71 | if (opts & LN_BACKUP) { |
75 | char *backup; | 72 | char *backup; |
76 | backup = xasprintf("%s%s", src, suffix); | 73 | backup = xasprintf("%s%s", src, suffix); |
77 | if (rename(src, backup) < 0 && errno != ENOENT) { | 74 | if (rename(src, backup) < 0 && errno != ENOENT) { |
@@ -87,12 +84,12 @@ int ln_main(int argc, char **argv) | |||
87 | * Therefore, always unlink(). | 84 | * Therefore, always unlink(). |
88 | */ | 85 | */ |
89 | unlink(src); | 86 | unlink(src); |
90 | } else if (flag & LN_FORCE) { | 87 | } else if (opts & LN_FORCE) { |
91 | unlink(src); | 88 | unlink(src); |
92 | } | 89 | } |
93 | 90 | ||
94 | link_func = link; | 91 | link_func = link; |
95 | if (flag & LN_SYMLINK) { | 92 | if (opts & LN_SYMLINK) { |
96 | link_func = symlink; | 93 | link_func = symlink; |
97 | } | 94 | } |
98 | 95 | ||
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c index a110165db..c837e9726 100644 --- a/coreutils/mkdir.c +++ b/coreutils/mkdir.c | |||
@@ -34,7 +34,7 @@ static const char mkdir_longopts[] ALIGN1 = | |||
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | int mkdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 36 | int mkdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
37 | int mkdir_main(int argc, char **argv) | 37 | int mkdir_main(int argc UNUSED_PARAM, char **argv) |
38 | { | 38 | { |
39 | mode_t mode = (mode_t)(-1); | 39 | mode_t mode = (mode_t)(-1); |
40 | int status = EXIT_SUCCESS; | 40 | int status = EXIT_SUCCESS; |
@@ -64,11 +64,9 @@ int mkdir_main(int argc, char **argv) | |||
64 | } | 64 | } |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | if (optind == argc) { | ||
68 | bb_show_usage(); | ||
69 | } | ||
70 | |||
71 | argv += optind; | 67 | argv += optind; |
68 | if (!argv[0]) | ||
69 | bb_show_usage(); | ||
72 | 70 | ||
73 | do { | 71 | do { |
74 | if (bb_make_directory(*argv, mode, flags)) { | 72 | if (bb_make_directory(*argv, mode, flags)) { |
diff --git a/coreutils/nohup.c b/coreutils/nohup.c index f44e2af61..c9e65d2ba 100644 --- a/coreutils/nohup.c +++ b/coreutils/nohup.c | |||
@@ -32,14 +32,14 @@ nohup: redirecting stderr to stdout | |||
32 | */ | 32 | */ |
33 | 33 | ||
34 | int nohup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 34 | int nohup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
35 | int nohup_main(int argc, char **argv) | 35 | int nohup_main(int argc UNUSED_PARAM, char **argv) |
36 | { | 36 | { |
37 | const char *nohupout; | 37 | const char *nohupout; |
38 | char *home; | 38 | char *home; |
39 | 39 | ||
40 | xfunc_error_retval = 127; | 40 | xfunc_error_retval = 127; |
41 | 41 | ||
42 | if (argc < 2) bb_show_usage(); | 42 | if (!argv[1]) bb_show_usage(); |
43 | 43 | ||
44 | /* If stdin is a tty, detach from it. */ | 44 | /* If stdin is a tty, detach from it. */ |
45 | if (isatty(STDIN_FILENO)) { | 45 | if (isatty(STDIN_FILENO)) { |
diff --git a/coreutils/stat.c b/coreutils/stat.c index 2bc9a086c..bbd2e6a7c 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c | |||
@@ -640,29 +640,29 @@ static bool do_stat(const char *filename, const char *format) | |||
640 | } | 640 | } |
641 | 641 | ||
642 | int stat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 642 | int stat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
643 | int stat_main(int argc, char **argv) | 643 | int stat_main(int argc UNUSED_PARAM, char **argv) |
644 | { | 644 | { |
645 | IF_FEATURE_STAT_FORMAT(char *format = NULL;) | 645 | IF_FEATURE_STAT_FORMAT(char *format = NULL;) |
646 | int i; | 646 | int i; |
647 | int ok = 1; | 647 | int ok; |
648 | unsigned opts; | ||
648 | statfunc_ptr statfunc = do_stat; | 649 | statfunc_ptr statfunc = do_stat; |
649 | 650 | ||
650 | getopt32(argv, "ftL" | 651 | opt_complementary = "-1"; /* min one arg */ |
652 | opts = getopt32(argv, "ftL" | ||
651 | IF_SELINUX("Z") | 653 | IF_SELINUX("Z") |
652 | IF_FEATURE_STAT_FORMAT("c:", &format) | 654 | IF_FEATURE_STAT_FORMAT("c:", &format) |
653 | ); | 655 | ); |
654 | 656 | if (opts & OPT_FILESYS) /* -f */ | |
655 | if (option_mask32 & OPT_FILESYS) /* -f */ | ||
656 | statfunc = do_statfs; | 657 | statfunc = do_statfs; |
657 | if (argc == optind) /* files */ | ||
658 | bb_show_usage(); | ||
659 | |||
660 | #if ENABLE_SELINUX | 658 | #if ENABLE_SELINUX |
661 | if (option_mask32 & OPT_SELINUX) { | 659 | if (opts & OPT_SELINUX) { |
662 | selinux_or_die(); | 660 | selinux_or_die(); |
663 | } | 661 | } |
664 | #endif /* ENABLE_SELINUX */ | 662 | #endif |
665 | for (i = optind; i < argc; ++i) | 663 | ok = 1; |
664 | argv += optind; | ||
665 | for (i = 0; argv[i]; ++i) | ||
666 | ok &= statfunc(argv[i] IF_FEATURE_STAT_FORMAT(, format)); | 666 | ok &= statfunc(argv[i] IF_FEATURE_STAT_FORMAT(, format)); |
667 | 667 | ||
668 | return (ok ? EXIT_SUCCESS : EXIT_FAILURE); | 668 | return (ok ? EXIT_SUCCESS : EXIT_FAILURE); |
diff --git a/coreutils/stty.c b/coreutils/stty.c index f29fa64f7..0485b8011 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c | |||
@@ -1156,7 +1156,7 @@ static void set_control_char_or_die(const struct control_info *info, | |||
1156 | #define STTY_noargs (1 << 4) | 1156 | #define STTY_noargs (1 << 4) |
1157 | 1157 | ||
1158 | int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 1158 | int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
1159 | int stty_main(int argc, char **argv) | 1159 | int stty_main(int argc UNUSED_PARAM, char **argv) |
1160 | { | 1160 | { |
1161 | struct termios mode; | 1161 | struct termios mode; |
1162 | void (*output_func)(const struct termios *, const int); | 1162 | void (*output_func)(const struct termios *, const int); |
@@ -1211,8 +1211,10 @@ int stty_main(int argc, char **argv) | |||
1211 | if (!file_name) | 1211 | if (!file_name) |
1212 | bb_error_msg_and_die(bb_msg_requires_arg, "-F"); | 1212 | bb_error_msg_and_die(bb_msg_requires_arg, "-F"); |
1213 | /* remove -F param from arg[vc] */ | 1213 | /* remove -F param from arg[vc] */ |
1214 | --argc; | 1214 | while (argv[p]) { |
1215 | while (argv[p]) { argv[p] = argv[p+1]; ++p; } | 1215 | argv[p] = argv[p+1]; |
1216 | ++p; | ||
1217 | } | ||
1216 | } | 1218 | } |
1217 | goto end_option; | 1219 | goto end_option; |
1218 | default: | 1220 | default: |
diff --git a/coreutils/yes.c b/coreutils/yes.c index 9d3f67550..d757a4504 100644 --- a/coreutils/yes.c +++ b/coreutils/yes.c | |||
@@ -19,14 +19,13 @@ | |||
19 | /* This is a NOFORK applet. Be very careful! */ | 19 | /* This is a NOFORK applet. Be very careful! */ |
20 | 20 | ||
21 | int yes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 21 | int yes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
22 | int yes_main(int argc, char **argv) | 22 | int yes_main(int argc UNUSED_PARAM, char **argv) |
23 | { | 23 | { |
24 | char **pp; | 24 | char **pp; |
25 | 25 | ||
26 | argv[0] = (char*)"y"; | 26 | argv[0] = (char*)"y"; |
27 | if (argc != 1) { | 27 | if (argv[1]) |
28 | ++argv; | 28 | ++argv; |
29 | } | ||
30 | 29 | ||
31 | do { | 30 | do { |
32 | pp = argv; | 31 | pp = argv; |
diff --git a/include/libbb.h b/include/libbb.h index 1f39c95e1..8d3df6191 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -869,6 +869,7 @@ void bb_sanitize_stdio(void) FAST_FUNC; | |||
869 | int sanitize_env_if_suid(void) FAST_FUNC; | 869 | int sanitize_env_if_suid(void) FAST_FUNC; |
870 | 870 | ||
871 | 871 | ||
872 | char* single_argv(char **argv) FAST_FUNC; | ||
872 | extern const char *const bb_argv_dash[]; /* "-", NULL */ | 873 | extern const char *const bb_argv_dash[]; /* "-", NULL */ |
873 | extern const char *opt_complementary; | 874 | extern const char *opt_complementary; |
874 | #if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG | 875 | #if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG |
diff --git a/libbb/Kbuild b/libbb/Kbuild index d9d5ad793..130ad25de 100644 --- a/libbb/Kbuild +++ b/libbb/Kbuild | |||
@@ -92,6 +92,7 @@ lib-y += setup_environment.o | |||
92 | lib-y += sha1.o | 92 | lib-y += sha1.o |
93 | lib-y += signals.o | 93 | lib-y += signals.o |
94 | lib-y += simplify_path.o | 94 | lib-y += simplify_path.o |
95 | lib-y += single_argv.o | ||
95 | lib-y += skip_whitespace.o | 96 | lib-y += skip_whitespace.o |
96 | lib-y += speed_table.o | 97 | lib-y += speed_table.o |
97 | lib-y += str_tolower.o | 98 | lib-y += str_tolower.o |
diff --git a/libbb/single_argv.c b/libbb/single_argv.c new file mode 100644 index 000000000..6173c884e --- /dev/null +++ b/libbb/single_argv.c | |||
@@ -0,0 +1,16 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Utility routines. | ||
4 | * | ||
5 | * Copyright (C) 2009 Denys Vlasenko | ||
6 | * | ||
7 | * Licensed under GPLv2, see file LICENSE in this tarball for details. | ||
8 | */ | ||
9 | #include "libbb.h" | ||
10 | |||
11 | char* FAST_FUNC single_argv(char **argv) | ||
12 | { | ||
13 | if (!argv[1] || argv[2]) | ||
14 | bb_show_usage(); | ||
15 | return argv[1]; | ||
16 | } | ||
diff --git a/miscutils/adjtimex.c b/miscutils/adjtimex.c index 07f083428..c12a10b25 100644 --- a/miscutils/adjtimex.c +++ b/miscutils/adjtimex.c | |||
@@ -56,7 +56,7 @@ static const char ret_code_descript[] = | |||
56 | ; | 56 | ; |
57 | 57 | ||
58 | int adjtimex_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 58 | int adjtimex_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
59 | int adjtimex_main(int argc, char **argv) | 59 | int adjtimex_main(int argc UNUSED_PARAM, char **argv) |
60 | { | 60 | { |
61 | enum { | 61 | enum { |
62 | OPT_quiet = 0x1 | 62 | OPT_quiet = 0x1 |
@@ -66,10 +66,11 @@ int adjtimex_main(int argc, char **argv) | |||
66 | struct timex txc; | 66 | struct timex txc; |
67 | int i, ret; | 67 | int i, ret; |
68 | const char *descript; | 68 | const char *descript; |
69 | txc.modes=0; | ||
70 | 69 | ||
70 | opt_complementary = "=0"; /* no valid non-option parameters */ | ||
71 | opt = getopt32(argv, "qo:f:p:t:", | 71 | opt = getopt32(argv, "qo:f:p:t:", |
72 | &opt_o, &opt_f, &opt_p, &opt_t); | 72 | &opt_o, &opt_f, &opt_p, &opt_t); |
73 | txc.modes = 0; | ||
73 | //if (opt & 0x1) // -q | 74 | //if (opt & 0x1) // -q |
74 | if (opt & 0x2) { // -o | 75 | if (opt & 0x2) { // -o |
75 | txc.offset = xatol(opt_o); | 76 | txc.offset = xatol(opt_o); |
@@ -87,9 +88,6 @@ int adjtimex_main(int argc, char **argv) | |||
87 | txc.tick = xatol(opt_t); | 88 | txc.tick = xatol(opt_t); |
88 | txc.modes |= ADJ_TICK; | 89 | txc.modes |= ADJ_TICK; |
89 | } | 90 | } |
90 | if (argc != optind) { /* no valid non-option parameters */ | ||
91 | bb_show_usage(); | ||
92 | } | ||
93 | 91 | ||
94 | ret = adjtimex(&txc); | 92 | ret = adjtimex(&txc); |
95 | 93 | ||
diff --git a/miscutils/raidautorun.c b/miscutils/raidautorun.c index a2a852bbf..113e49ff2 100644 --- a/miscutils/raidautorun.c +++ b/miscutils/raidautorun.c | |||
@@ -14,12 +14,8 @@ | |||
14 | #include <linux/raid/md_u.h> | 14 | #include <linux/raid/md_u.h> |
15 | 15 | ||
16 | int raidautorun_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 16 | int raidautorun_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
17 | int raidautorun_main(int argc, char **argv) | 17 | int raidautorun_main(int argc UNUSED_PARAM, char **argv) |
18 | { | 18 | { |
19 | if (argc != 2) | 19 | xioctl(xopen(single_argv(argv), O_RDONLY), RAID_AUTORUN, NULL); |
20 | bb_show_usage(); | ||
21 | |||
22 | xioctl(xopen(argv[1], O_RDONLY), RAID_AUTORUN, NULL); | ||
23 | |||
24 | return EXIT_SUCCESS; | 20 | return EXIT_SUCCESS; |
25 | } | 21 | } |
diff --git a/miscutils/rx.c b/miscutils/rx.c index 3a8b6a8fe..4c5d5a19c 100644 --- a/miscutils/rx.c +++ b/miscutils/rx.c | |||
@@ -234,21 +234,18 @@ static void sigalrm_handler(int UNUSED_PARAM signum) | |||
234 | } | 234 | } |
235 | 235 | ||
236 | int rx_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 236 | int rx_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
237 | int rx_main(int argc, char **argv) | 237 | int rx_main(int argc UNUSED_PARAM, char **argv) |
238 | { | 238 | { |
239 | struct termios tty, orig_tty; | 239 | struct termios tty, orig_tty; |
240 | int termios_err; | 240 | int termios_err; |
241 | int file_fd; | 241 | int file_fd; |
242 | int n; | 242 | int n; |
243 | 243 | ||
244 | if (argc != 2) | ||
245 | bb_show_usage(); | ||
246 | |||
247 | /* Disabled by vda: | 244 | /* Disabled by vda: |
248 | * why we can't receive from stdin? Why we *require* | 245 | * why we can't receive from stdin? Why we *require* |
249 | * controlling tty?? */ | 246 | * controlling tty?? */ |
250 | /*read_fd = xopen(CURRENT_TTY, O_RDWR);*/ | 247 | /*read_fd = xopen(CURRENT_TTY, O_RDWR);*/ |
251 | file_fd = xopen(argv[1], O_RDWR|O_CREAT|O_TRUNC); | 248 | file_fd = xopen(single_argv(argv), O_RDWR|O_CREAT|O_TRUNC); |
252 | 249 | ||
253 | termios_err = tcgetattr(read_fd, &tty); | 250 | termios_err = tcgetattr(read_fd, &tty); |
254 | if (termios_err == 0) { | 251 | if (termios_err == 0) { |
diff --git a/runit/runsv.c b/runit/runsv.c index 8b787543f..48b83960d 100644 --- a/runit/runsv.c +++ b/runit/runsv.c | |||
@@ -463,9 +463,7 @@ int runsv_main(int argc UNUSED_PARAM, char **argv) | |||
463 | 463 | ||
464 | INIT_G(); | 464 | INIT_G(); |
465 | 465 | ||
466 | if (!argv[1] || argv[2]) | 466 | dir = single_argv(argv); |
467 | bb_show_usage(); | ||
468 | dir = argv[1]; | ||
469 | 467 | ||
470 | xpiped_pair(selfpipe); | 468 | xpiped_pair(selfpipe); |
471 | close_on_exec_on(selfpipe.rd); | 469 | close_on_exec_on(selfpipe.rd); |
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 6a194fd1a..c9f57c6d6 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c | |||
@@ -2821,7 +2821,7 @@ unknown_command(int c) | |||
2821 | #endif | 2821 | #endif |
2822 | 2822 | ||
2823 | int fdisk_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 2823 | int fdisk_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
2824 | int fdisk_main(int argc, char **argv) | 2824 | int fdisk_main(int argc UNUSED_PARAM, char **argv) |
2825 | { | 2825 | { |
2826 | unsigned opt; | 2826 | unsigned opt; |
2827 | /* | 2827 | /* |
@@ -2839,7 +2839,6 @@ int fdisk_main(int argc, char **argv) | |||
2839 | opt_complementary = "b+:C+:H+:S+"; /* numeric params */ | 2839 | opt_complementary = "b+:C+:H+:S+"; /* numeric params */ |
2840 | opt = getopt32(argv, "b:C:H:lS:u" IF_FEATURE_FDISK_BLKSIZE("s"), | 2840 | opt = getopt32(argv, "b:C:H:lS:u" IF_FEATURE_FDISK_BLKSIZE("s"), |
2841 | §or_size, &user_cylinders, &user_heads, &user_sectors); | 2841 | §or_size, &user_cylinders, &user_heads, &user_sectors); |
2842 | argc -= optind; | ||
2843 | argv += optind; | 2842 | argv += optind; |
2844 | if (opt & OPT_b) { // -b | 2843 | if (opt & OPT_b) { // -b |
2845 | /* Ugly: this sector size is really per device, | 2844 | /* Ugly: this sector size is really per device, |
@@ -2883,14 +2882,14 @@ int fdisk_main(int argc, char **argv) | |||
2883 | int j; | 2882 | int j; |
2884 | 2883 | ||
2885 | nowarn = 1; | 2884 | nowarn = 1; |
2886 | if (argc <= 0) | 2885 | if (!argv[0]) |
2887 | bb_show_usage(); | 2886 | bb_show_usage(); |
2888 | for (j = 0; j < argc; j++) { | 2887 | for (j = 0; argv[j]; j++) { |
2889 | unsigned long long size; | 2888 | unsigned long long size; |
2890 | fd = xopen(argv[j], O_RDONLY); | 2889 | fd = xopen(argv[j], O_RDONLY); |
2891 | size = bb_BLKGETSIZE_sectors(fd) / 2; | 2890 | size = bb_BLKGETSIZE_sectors(fd) / 2; |
2892 | close(fd); | 2891 | close(fd); |
2893 | if (argc == 1) | 2892 | if (argv[1]) |
2894 | printf("%llu\n", size); | 2893 | printf("%llu\n", size); |
2895 | else | 2894 | else |
2896 | printf("%s: %llu\n", argv[j], size); | 2895 | printf("%s: %llu\n", argv[j], size); |
@@ -2900,7 +2899,7 @@ int fdisk_main(int argc, char **argv) | |||
2900 | #endif | 2899 | #endif |
2901 | 2900 | ||
2902 | #if ENABLE_FEATURE_FDISK_WRITABLE | 2901 | #if ENABLE_FEATURE_FDISK_WRITABLE |
2903 | if (argc != 1) | 2902 | if (!argv[0] || argv[1]) |
2904 | bb_show_usage(); | 2903 | bb_show_usage(); |
2905 | 2904 | ||
2906 | disk_device = argv[0]; | 2905 | disk_device = argv[0]; |
diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c index 6b9d95e69..4949056a6 100644 --- a/util-linux/freeramdisk.c +++ b/util-linux/freeramdisk.c | |||
@@ -15,16 +15,14 @@ | |||
15 | #define FDFLUSH _IO(2,0x4b) | 15 | #define FDFLUSH _IO(2,0x4b) |
16 | 16 | ||
17 | int freeramdisk_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 17 | int freeramdisk_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
18 | int freeramdisk_main(int argc, char **argv) | 18 | int freeramdisk_main(int argc UNUSED_PARAM, char **argv) |
19 | { | 19 | { |
20 | int fd; | 20 | int fd; |
21 | 21 | ||
22 | if (argc != 2) bb_show_usage(); | 22 | fd = xopen(single_argv(argv), O_RDWR); |
23 | |||
24 | fd = xopen(argv[1], O_RDWR); | ||
25 | 23 | ||
26 | // Act like freeramdisk, fdflush, or both depending on configuration. | 24 | // Act like freeramdisk, fdflush, or both depending on configuration. |
27 | ioctl_or_perror_and_die(fd, (ENABLE_FREERAMDISK && applet_name[1]=='r') | 25 | ioctl_or_perror_and_die(fd, (ENABLE_FREERAMDISK && applet_name[1] == 'r') |
28 | || !ENABLE_FDFLUSH ? BLKFLSBUF : FDFLUSH, NULL, "%s", argv[1]); | 26 | || !ENABLE_FDFLUSH ? BLKFLSBUF : FDFLUSH, NULL, "%s", argv[1]); |
29 | 27 | ||
30 | if (ENABLE_FEATURE_CLEAN_UP) close(fd); | 28 | if (ENABLE_FEATURE_CLEAN_UP) close(fd); |