diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-04 14:15:38 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-04 14:15:38 +0100 |
commit | 2ec91aead52d6ea6a42420005119ebb281a76cdc (patch) | |
tree | 115804c56ff172f96c0138bcabcc7d5e56e5dae0 | |
parent | a355da07756e529c112249653ed5af0e2d910728 (diff) | |
download | busybox-w32-2ec91aead52d6ea6a42420005119ebb281a76cdc.tar.gz busybox-w32-2ec91aead52d6ea6a42420005119ebb281a76cdc.tar.bz2 busybox-w32-2ec91aead52d6ea6a42420005119ebb281a76cdc.zip |
*: remove some uses of argc
function old new delta
whoami_main 34 37 +3
logname_main 60 63 +3
hostid_main 35 38 +3
ttysize_main 136 135 -1
nmeter_main 673 672 -1
logger_main 387 386 -1
uuencode_main 330 328 -2
ifupdown_main 2125 2123 -2
mesg_main 158 155 -3
free_main 333 330 -3
cal_main 902 899 -3
acpid_main 443 440 -3
ar_main 196 189 -7
find_main 476 467 -9
ifconfig_main 1235 1221 -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/12 up/down: 9/-49) Total: -40 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/ar.c | 7 | ||||
-rw-r--r-- | archival/rpm.c | 4 | ||||
-rw-r--r-- | coreutils/cal.c | 14 | ||||
-rw-r--r-- | coreutils/hostid.c | 4 | ||||
-rw-r--r-- | coreutils/logname.c | 4 | ||||
-rw-r--r-- | coreutils/nohup.c | 4 | ||||
-rw-r--r-- | coreutils/uuencode.c | 4 | ||||
-rw-r--r-- | coreutils/whoami.c | 4 | ||||
-rw-r--r-- | findutils/find.c | 4 | ||||
-rw-r--r-- | findutils/grep.c | 10 | ||||
-rw-r--r-- | init/mesg.c | 10 | ||||
-rw-r--r-- | miscutils/last.c | 4 | ||||
-rw-r--r-- | miscutils/readahead.c | 6 | ||||
-rw-r--r-- | miscutils/ttysize.c | 4 | ||||
-rw-r--r-- | networking/ifconfig.c | 10 | ||||
-rw-r--r-- | networking/ifupdown.c | 7 | ||||
-rw-r--r-- | networking/nc_bloaty.c | 3 | ||||
-rw-r--r-- | networking/zcip.c | 3 | ||||
-rw-r--r-- | procps/free.c | 4 | ||||
-rw-r--r-- | procps/nmeter.c | 4 | ||||
-rw-r--r-- | selinux/load_policy.c | 4 | ||||
-rw-r--r-- | selinux/setenforce.c | 4 | ||||
-rw-r--r-- | selinux/setfiles.c | 23 | ||||
-rw-r--r-- | shell/bbsh.c | 2 | ||||
-rw-r--r-- | sysklogd/logger.c | 5 | ||||
-rw-r--r-- | util-linux/acpid.c | 3 |
26 files changed, 77 insertions, 78 deletions
diff --git a/archival/ar.c b/archival/ar.c index a1bcb1f9c..1b43502ca 100644 --- a/archival/ar.c +++ b/archival/ar.c | |||
@@ -38,7 +38,7 @@ static void FAST_FUNC header_verbose_list_ar(const file_header_t *file_header) | |||
38 | #define AR_OPT_INSERT 0x40 | 38 | #define AR_OPT_INSERT 0x40 |
39 | 39 | ||
40 | int ar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 40 | int ar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
41 | int ar_main(int argc, char **argv) | 41 | int ar_main(int argc UNUSED_PARAM, char **argv) |
42 | { | 42 | { |
43 | static const char msg_unsupported_err[] ALIGN1 = | 43 | static const char msg_unsupported_err[] ALIGN1 = |
44 | "archive %s is not supported"; | 44 | "archive %s is not supported"; |
@@ -51,6 +51,7 @@ int ar_main(int argc, char **argv) | |||
51 | /* Prepend '-' to the first argument if required */ | 51 | /* Prepend '-' to the first argument if required */ |
52 | opt_complementary = "--:p:t:x:-1:p--tx:t--px:x--pt"; | 52 | opt_complementary = "--:p:t:x:-1:p--tx:t--px:x--pt"; |
53 | opt = getopt32(argv, "ptxovcr"); | 53 | opt = getopt32(argv, "ptxovcr"); |
54 | argv += optind; | ||
54 | 55 | ||
55 | if (opt & AR_CTX_PRINT) { | 56 | if (opt & AR_CTX_PRINT) { |
56 | archive_handle->action_data = data_extract_to_stdout; | 57 | archive_handle->action_data = data_extract_to_stdout; |
@@ -76,9 +77,9 @@ int ar_main(int argc, char **argv) | |||
76 | 77 | ||
77 | archive_handle->src_fd = xopen(argv[optind++], O_RDONLY); | 78 | archive_handle->src_fd = xopen(argv[optind++], O_RDONLY); |
78 | 79 | ||
79 | while (optind < argc) { | 80 | while (*argv) { |
80 | archive_handle->filter = filter_accept_list; | 81 | archive_handle->filter = filter_accept_list; |
81 | llist_add_to(&(archive_handle->accept), argv[optind++]); | 82 | llist_add_to(&archive_handle->accept, *argv++); |
82 | } | 83 | } |
83 | 84 | ||
84 | unpack_ar_archive(archive_handle); | 85 | unpack_ar_archive(archive_handle); |
diff --git a/archival/rpm.c b/archival/rpm.c index 27c6b78a1..cdaf50fa9 100644 --- a/archival/rpm.c +++ b/archival/rpm.c | |||
@@ -116,7 +116,9 @@ int rpm_main(int argc, char **argv) | |||
116 | } | 116 | } |
117 | argv += optind; | 117 | argv += optind; |
118 | //argc -= optind; | 118 | //argc -= optind; |
119 | if (!argv[0]) bb_show_usage(); | 119 | if (!argv[0]) { |
120 | bb_show_usage(); | ||
121 | } | ||
120 | 122 | ||
121 | while (*argv) { | 123 | while (*argv) { |
122 | rpm_fd = xopen(*argv++, O_RDONLY); | 124 | rpm_fd = xopen(*argv++, O_RDONLY); |
diff --git a/coreutils/cal.c b/coreutils/cal.c index 7973b82a1..1f498fb7f 100644 --- a/coreutils/cal.c +++ b/coreutils/cal.c | |||
@@ -77,7 +77,7 @@ static char *build_row(char *p, unsigned *dp); | |||
77 | #define HEAD_SEP 2 /* spaces between day headings */ | 77 | #define HEAD_SEP 2 /* spaces between day headings */ |
78 | 78 | ||
79 | int cal_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 79 | int cal_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
80 | int cal_main(int argc, char **argv) | 80 | int cal_main(int argc UNUSED_PARAM, char **argv) |
81 | { | 81 | { |
82 | struct tm *local_time; | 82 | struct tm *local_time; |
83 | struct tm zero_tm; | 83 | struct tm zero_tm; |
@@ -92,13 +92,8 @@ int cal_main(int argc, char **argv) | |||
92 | option_mask32 &= 1; | 92 | option_mask32 &= 1; |
93 | month = 0; | 93 | month = 0; |
94 | argv += optind; | 94 | argv += optind; |
95 | argc -= optind; | ||
96 | 95 | ||
97 | if (argc > 2) { | 96 | if (!argv[0]) { |
98 | bb_show_usage(); | ||
99 | } | ||
100 | |||
101 | if (!argc) { | ||
102 | time(&now); | 97 | time(&now); |
103 | local_time = localtime(&now); | 98 | local_time = localtime(&now); |
104 | year = local_time->tm_year + 1900; | 99 | year = local_time->tm_year + 1900; |
@@ -106,7 +101,10 @@ int cal_main(int argc, char **argv) | |||
106 | month = local_time->tm_mon + 1; | 101 | month = local_time->tm_mon + 1; |
107 | } | 102 | } |
108 | } else { | 103 | } else { |
109 | if (argc == 2) { | 104 | if (argv[1]) { |
105 | if (argv[2]) { | ||
106 | bb_show_usage(); | ||
107 | } | ||
110 | month = xatou_range(*argv++, 1, 12); | 108 | month = xatou_range(*argv++, 1, 12); |
111 | } | 109 | } |
112 | year = xatou_range(*argv, 1, 9999); | 110 | year = xatou_range(*argv, 1, 9999); |
diff --git a/coreutils/hostid.c b/coreutils/hostid.c index 6f007d847..a537e3ad6 100644 --- a/coreutils/hostid.c +++ b/coreutils/hostid.c | |||
@@ -14,9 +14,9 @@ | |||
14 | /* This is a NOFORK applet. Be very careful! */ | 14 | /* This is a NOFORK applet. Be very careful! */ |
15 | 15 | ||
16 | int hostid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 16 | int hostid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
17 | int hostid_main(int argc, char **argv UNUSED_PARAM) | 17 | int hostid_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
18 | { | 18 | { |
19 | if (argc > 1) { | 19 | if (argv[1]) { |
20 | bb_show_usage(); | 20 | bb_show_usage(); |
21 | } | 21 | } |
22 | 22 | ||
diff --git a/coreutils/logname.c b/coreutils/logname.c index 7e5013255..8357b9a33 100644 --- a/coreutils/logname.c +++ b/coreutils/logname.c | |||
@@ -25,11 +25,11 @@ | |||
25 | /* This is a NOFORK applet. Be very careful! */ | 25 | /* This is a NOFORK applet. Be very careful! */ |
26 | 26 | ||
27 | int logname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 27 | int logname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
28 | int logname_main(int argc, char **argv UNUSED_PARAM) | 28 | int logname_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
29 | { | 29 | { |
30 | char buf[64]; | 30 | char buf[64]; |
31 | 31 | ||
32 | if (argc > 1) { | 32 | if (argv[1]) { |
33 | bb_show_usage(); | 33 | bb_show_usage(); |
34 | } | 34 | } |
35 | 35 | ||
diff --git a/coreutils/nohup.c b/coreutils/nohup.c index c9e65d2ba..4f6385f8e 100644 --- a/coreutils/nohup.c +++ b/coreutils/nohup.c | |||
@@ -39,7 +39,9 @@ int nohup_main(int argc UNUSED_PARAM, char **argv) | |||
39 | 39 | ||
40 | xfunc_error_retval = 127; | 40 | xfunc_error_retval = 127; |
41 | 41 | ||
42 | if (!argv[1]) bb_show_usage(); | 42 | if (!argv[1]) { |
43 | bb_show_usage(); | ||
44 | } | ||
43 | 45 | ||
44 | /* If stdin is a tty, detach from it. */ | 46 | /* If stdin is a tty, detach from it. */ |
45 | if (isatty(STDIN_FILENO)) { | 47 | if (isatty(STDIN_FILENO)) { |
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c index e19f99676..bf661851d 100644 --- a/coreutils/uuencode.c +++ b/coreutils/uuencode.c | |||
@@ -16,7 +16,7 @@ enum { | |||
16 | }; | 16 | }; |
17 | 17 | ||
18 | int uuencode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 18 | int uuencode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
19 | int uuencode_main(int argc, char **argv) | 19 | int uuencode_main(int argc UNUSED_PARAM, char **argv) |
20 | { | 20 | { |
21 | struct stat stat_buf; | 21 | struct stat stat_buf; |
22 | int src_fd = STDIN_FILENO; | 22 | int src_fd = STDIN_FILENO; |
@@ -32,7 +32,7 @@ int uuencode_main(int argc, char **argv) | |||
32 | tbl = bb_uuenc_tbl_base64; | 32 | tbl = bb_uuenc_tbl_base64; |
33 | } | 33 | } |
34 | argv += optind; | 34 | argv += optind; |
35 | if (argc == optind + 2) { | 35 | if (argv[1]) { |
36 | src_fd = xopen(*argv, O_RDONLY); | 36 | src_fd = xopen(*argv, O_RDONLY); |
37 | fstat(src_fd, &stat_buf); | 37 | fstat(src_fd, &stat_buf); |
38 | mode = stat_buf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); | 38 | mode = stat_buf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); |
diff --git a/coreutils/whoami.c b/coreutils/whoami.c index 1031cdbf8..22d722ec7 100644 --- a/coreutils/whoami.c +++ b/coreutils/whoami.c | |||
@@ -14,9 +14,9 @@ | |||
14 | /* This is a NOFORK applet. Be very careful! */ | 14 | /* This is a NOFORK applet. Be very careful! */ |
15 | 15 | ||
16 | int whoami_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 16 | int whoami_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
17 | int whoami_main(int argc, char **argv UNUSED_PARAM) | 17 | int whoami_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
18 | { | 18 | { |
19 | if (argc > 1) | 19 | if (argv[1]) |
20 | bb_show_usage(); | 20 | bb_show_usage(); |
21 | 21 | ||
22 | /* Will complain and die if username not found */ | 22 | /* Will complain and die if username not found */ |
diff --git a/findutils/find.c b/findutils/find.c index 76cd18c1a..1b2466816 100644 --- a/findutils/find.c +++ b/findutils/find.c | |||
@@ -835,7 +835,7 @@ static action*** parse_params(char **argv) | |||
835 | 835 | ||
836 | 836 | ||
837 | int find_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 837 | int find_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
838 | int find_main(int argc, char **argv) | 838 | int find_main(int argc UNUSED_PARAM, char **argv) |
839 | { | 839 | { |
840 | static const char options[] ALIGN1 = | 840 | static const char options[] ALIGN1 = |
841 | "-follow\0" | 841 | "-follow\0" |
@@ -859,7 +859,7 @@ IF_FEATURE_FIND_MAXDEPTH(OPT_MINDEPTH,) | |||
859 | 859 | ||
860 | INIT_G(); | 860 | INIT_G(); |
861 | 861 | ||
862 | for (firstopt = 1; firstopt < argc; firstopt++) { | 862 | for (firstopt = 1; argv[firstopt]; firstopt++) { |
863 | if (argv[firstopt][0] == '-') | 863 | if (argv[firstopt][0] == '-') |
864 | break; | 864 | break; |
865 | if (ENABLE_FEATURE_FIND_NOT && LONE_CHAR(argv[firstopt], '!')) | 865 | if (ENABLE_FEATURE_FIND_NOT && LONE_CHAR(argv[firstopt], '!')) |
diff --git a/findutils/grep.c b/findutils/grep.c index 9dc2f1942..193b48c11 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -519,7 +519,7 @@ static int grep_dir(const char *dir) | |||
519 | } | 519 | } |
520 | 520 | ||
521 | int grep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 521 | int grep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
522 | int grep_main(int argc, char **argv) | 522 | int grep_main(int argc UNUSED_PARAM, char **argv) |
523 | { | 523 | { |
524 | FILE *file; | 524 | FILE *file; |
525 | int matched; | 525 | int matched; |
@@ -606,7 +606,6 @@ int grep_main(int argc, char **argv) | |||
606 | } | 606 | } |
607 | 607 | ||
608 | argv += optind; | 608 | argv += optind; |
609 | argc -= optind; | ||
610 | 609 | ||
611 | /* if we didn't get a pattern from -e and no command file was specified, | 610 | /* if we didn't get a pattern from -e and no command file was specified, |
612 | * first parameter should be the pattern. no pattern, no worky */ | 611 | * first parameter should be the pattern. no pattern, no worky */ |
@@ -616,12 +615,11 @@ int grep_main(int argc, char **argv) | |||
616 | bb_show_usage(); | 615 | bb_show_usage(); |
617 | pattern = new_grep_list_data(*argv++, 0); | 616 | pattern = new_grep_list_data(*argv++, 0); |
618 | llist_add_to(&pattern_head, pattern); | 617 | llist_add_to(&pattern_head, pattern); |
619 | argc--; | ||
620 | } | 618 | } |
621 | 619 | ||
622 | /* argv[0..(argc-1)] should be names of file to grep through. If | 620 | /* argv[0..(argc-1)] should be names of file to grep through. If |
623 | * there is more than one file to grep, we will print the filenames. */ | 621 | * there is more than one file to grep, we will print the filenames. */ |
624 | if (argc > 1) | 622 | if (argv[0] && argv[1]) |
625 | print_filename = 1; | 623 | print_filename = 1; |
626 | /* -H / -h of course override */ | 624 | /* -H / -h of course override */ |
627 | if (option_mask32 & OPT_H) | 625 | if (option_mask32 & OPT_H) |
@@ -633,7 +631,7 @@ int grep_main(int argc, char **argv) | |||
633 | * stdin. Otherwise, we grep through all the files specified. */ | 631 | * stdin. Otherwise, we grep through all the files specified. */ |
634 | matched = 0; | 632 | matched = 0; |
635 | do { | 633 | do { |
636 | cur_file = *argv++; | 634 | cur_file = *argv; |
637 | file = stdin; | 635 | file = stdin; |
638 | if (!cur_file || LONE_DASH(cur_file)) { | 636 | if (!cur_file || LONE_DASH(cur_file)) { |
639 | cur_file = "(standard input)"; | 637 | cur_file = "(standard input)"; |
@@ -659,7 +657,7 @@ int grep_main(int argc, char **argv) | |||
659 | matched += grep_file(file); | 657 | matched += grep_file(file); |
660 | fclose_if_not_stdin(file); | 658 | fclose_if_not_stdin(file); |
661 | grep_done: ; | 659 | grep_done: ; |
662 | } while (--argc > 0); | 660 | } while (*argv && *++argv); |
663 | 661 | ||
664 | /* destroy all the elments in the pattern list */ | 662 | /* destroy all the elments in the pattern list */ |
665 | if (ENABLE_FEATURE_CLEAN_UP) { | 663 | if (ENABLE_FEATURE_CLEAN_UP) { |
diff --git a/init/mesg.c b/init/mesg.c index ca230f363..2e8b16e5d 100644 --- a/init/mesg.c +++ b/init/mesg.c | |||
@@ -16,21 +16,23 @@ | |||
16 | #endif | 16 | #endif |
17 | 17 | ||
18 | int mesg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 18 | int mesg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
19 | int mesg_main(int argc, char **argv) | 19 | int mesg_main(int argc UNUSED_PARAM, char **argv) |
20 | { | 20 | { |
21 | struct stat sb; | 21 | struct stat sb; |
22 | const char *tty; | 22 | const char *tty; |
23 | char c = 0; | 23 | char c = 0; |
24 | 24 | ||
25 | if (--argc == 0 | 25 | argv++; |
26 | || (argc == 1 && ((c = **++argv) == 'y' || c == 'n')) | 26 | |
27 | if (!argv[0] | ||
28 | || (!argv[1] && ((c = argv[0][0]) == 'y' || c == 'n')) | ||
27 | ) { | 29 | ) { |
28 | tty = xmalloc_ttyname(STDERR_FILENO); | 30 | tty = xmalloc_ttyname(STDERR_FILENO); |
29 | if (tty == NULL) { | 31 | if (tty == NULL) { |
30 | tty = "ttyname"; | 32 | tty = "ttyname"; |
31 | } else if (stat(tty, &sb) == 0) { | 33 | } else if (stat(tty, &sb) == 0) { |
32 | mode_t m; | 34 | mode_t m; |
33 | if (argc == 0) { | 35 | if (c == 0) { |
34 | puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n"); | 36 | puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n"); |
35 | return EXIT_SUCCESS; | 37 | return EXIT_SUCCESS; |
36 | } | 38 | } |
diff --git a/miscutils/last.c b/miscutils/last.c index f8c301395..6e3ed9093 100644 --- a/miscutils/last.c +++ b/miscutils/last.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 37 | int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
38 | int last_main(int argc, char **argv UNUSED_PARAM) | 38 | int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
39 | { | 39 | { |
40 | struct utmp ut; | 40 | struct utmp ut; |
41 | int n, file = STDIN_FILENO; | 41 | int n, file = STDIN_FILENO; |
@@ -56,7 +56,7 @@ int last_main(int argc, char **argv UNUSED_PARAM) | |||
56 | TYPE_OLD_TIME /* OLD_TIME, 4 */ | 56 | TYPE_OLD_TIME /* OLD_TIME, 4 */ |
57 | }; | 57 | }; |
58 | 58 | ||
59 | if (argc > 1) { | 59 | if (argv[1]) { |
60 | bb_show_usage(); | 60 | bb_show_usage(); |
61 | } | 61 | } |
62 | file = xopen(bb_path_wtmp_file, O_RDONLY); | 62 | file = xopen(bb_path_wtmp_file, O_RDONLY); |
diff --git a/miscutils/readahead.c b/miscutils/readahead.c index fb71ce85f..f3b21a2fc 100644 --- a/miscutils/readahead.c +++ b/miscutils/readahead.c | |||
@@ -13,11 +13,13 @@ | |||
13 | #include "libbb.h" | 13 | #include "libbb.h" |
14 | 14 | ||
15 | int readahead_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 15 | int readahead_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
16 | int readahead_main(int argc, char **argv) | 16 | int readahead_main(int argc UNUSED_PARAM, char **argv) |
17 | { | 17 | { |
18 | int retval = EXIT_SUCCESS; | 18 | int retval = EXIT_SUCCESS; |
19 | 19 | ||
20 | if (argc == 1) bb_show_usage(); | 20 | if (!argv[1]) { |
21 | bb_show_usage(); | ||
22 | } | ||
21 | 23 | ||
22 | while (*++argv) { | 24 | while (*++argv) { |
23 | int fd = open_or_warn(*argv, O_RDONLY); | 25 | int fd = open_or_warn(*argv, O_RDONLY); |
diff --git a/miscutils/ttysize.c b/miscutils/ttysize.c index 05455543d..ca9a2ec8d 100644 --- a/miscutils/ttysize.c +++ b/miscutils/ttysize.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include "libbb.h" | 12 | #include "libbb.h" |
13 | 13 | ||
14 | int ttysize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 14 | int ttysize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
15 | int ttysize_main(int argc, char **argv) | 15 | int ttysize_main(int argc UNUSED_PARAM, char **argv) |
16 | { | 16 | { |
17 | unsigned w, h; | 17 | unsigned w, h; |
18 | struct winsize wsz; | 18 | struct winsize wsz; |
@@ -24,7 +24,7 @@ int ttysize_main(int argc, char **argv) | |||
24 | h = wsz.ws_row; | 24 | h = wsz.ws_row; |
25 | } | 25 | } |
26 | 26 | ||
27 | if (argc == 1) { | 27 | if (!argv[1]) { |
28 | printf("%u %u", w, h); | 28 | printf("%u %u", w, h); |
29 | } else { | 29 | } else { |
30 | const char *fmt, *arg; | 30 | const char *fmt, *arg; |
diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 863d6e44a..1e960d45c 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c | |||
@@ -260,7 +260,7 @@ static int in_ether(const char *bufp, struct sockaddr *sap); | |||
260 | * Our main function. | 260 | * Our main function. |
261 | */ | 261 | */ |
262 | int ifconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 262 | int ifconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
263 | int ifconfig_main(int argc, char **argv) | 263 | int ifconfig_main(int argc UNUSED_PARAM, char **argv) |
264 | { | 264 | { |
265 | struct ifreq ifr; | 265 | struct ifreq ifr; |
266 | struct sockaddr_in sai; | 266 | struct sockaddr_in sai; |
@@ -291,19 +291,17 @@ int ifconfig_main(int argc, char **argv) | |||
291 | 291 | ||
292 | /* skip argv[0] */ | 292 | /* skip argv[0] */ |
293 | ++argv; | 293 | ++argv; |
294 | --argc; | ||
295 | 294 | ||
296 | #if ENABLE_FEATURE_IFCONFIG_STATUS | 295 | #if ENABLE_FEATURE_IFCONFIG_STATUS |
297 | if (argc > 0 && (argv[0][0] == '-' && argv[0][1] == 'a' && !argv[0][2])) { | 296 | if (argv[0] && (argv[0][0] == '-' && argv[0][1] == 'a' && !argv[0][2])) { |
298 | interface_opt_a = 1; | 297 | interface_opt_a = 1; |
299 | --argc; | ||
300 | ++argv; | 298 | ++argv; |
301 | } | 299 | } |
302 | #endif | 300 | #endif |
303 | 301 | ||
304 | if (argc <= 1) { | 302 | if (!argv[0] || !argv[1]) { /* one or no args */ |
305 | #if ENABLE_FEATURE_IFCONFIG_STATUS | 303 | #if ENABLE_FEATURE_IFCONFIG_STATUS |
306 | return display_interfaces(argc ? *argv : NULL); | 304 | return display_interfaces(argv[0] /* can be NULL */); |
307 | #else | 305 | #else |
308 | bb_error_msg_and_die("no support for status display"); | 306 | bb_error_msg_and_die("no support for status display"); |
309 | #endif | 307 | #endif |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index d28c0b867..51b36263f 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -1142,7 +1142,7 @@ static llist_t *read_iface_state(void) | |||
1142 | 1142 | ||
1143 | 1143 | ||
1144 | int ifupdown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 1144 | int ifupdown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
1145 | int ifupdown_main(int argc, char **argv) | 1145 | int ifupdown_main(int argc UNUSED_PARAM, char **argv) |
1146 | { | 1146 | { |
1147 | int (*cmds)(struct interface_defn_t *); | 1147 | int (*cmds)(struct interface_defn_t *); |
1148 | struct interfaces_file_t *defn; | 1148 | struct interfaces_file_t *defn; |
@@ -1161,7 +1161,8 @@ int ifupdown_main(int argc, char **argv) | |||
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | getopt32(argv, OPTION_STR, &interfaces); | 1163 | getopt32(argv, OPTION_STR, &interfaces); |
1164 | if (argc - optind > 0) { | 1164 | argv += optind; |
1165 | if (argv[0]) { | ||
1165 | if (DO_ALL) bb_show_usage(); | 1166 | if (DO_ALL) bb_show_usage(); |
1166 | } else { | 1167 | } else { |
1167 | if (!DO_ALL) bb_show_usage(); | 1168 | if (!DO_ALL) bb_show_usage(); |
@@ -1175,7 +1176,7 @@ int ifupdown_main(int argc, char **argv) | |||
1175 | if (DO_ALL) { | 1176 | if (DO_ALL) { |
1176 | target_list = defn->autointerfaces; | 1177 | target_list = defn->autointerfaces; |
1177 | } else { | 1178 | } else { |
1178 | llist_add_to_end(&target_list, argv[optind]); | 1179 | llist_add_to_end(&target_list, argv[0]); |
1179 | } | 1180 | } |
1180 | 1181 | ||
1181 | /* Update the interfaces */ | 1182 | /* Update the interfaces */ |
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c index ad98bed30..9d7c23dee 100644 --- a/networking/nc_bloaty.c +++ b/networking/nc_bloaty.c | |||
@@ -673,7 +673,7 @@ Debug("wrote %d to net, errno %d", rr, errno); | |||
673 | 673 | ||
674 | /* main: now we pull it all together... */ | 674 | /* main: now we pull it all together... */ |
675 | int nc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 675 | int nc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
676 | int nc_main(int argc, char **argv) | 676 | int nc_main(int argc UNUSED_PARAM, char **argv) |
677 | { | 677 | { |
678 | char *str_p, *str_s; | 678 | char *str_p, *str_s; |
679 | IF_NC_EXTRA(char *str_i, *str_o;) | 679 | IF_NC_EXTRA(char *str_i, *str_o;) |
@@ -702,7 +702,6 @@ int nc_main(int argc, char **argv) | |||
702 | while (*++proggie) { | 702 | while (*++proggie) { |
703 | if (strcmp(*proggie, "-e") == 0) { | 703 | if (strcmp(*proggie, "-e") == 0) { |
704 | *proggie = NULL; | 704 | *proggie = NULL; |
705 | argc = proggie - argv; | ||
706 | proggie++; | 705 | proggie++; |
707 | goto e_found; | 706 | goto e_found; |
708 | } | 707 | } |
diff --git a/networking/zcip.c b/networking/zcip.c index df4c0ec2d..a4da5cbcd 100644 --- a/networking/zcip.c +++ b/networking/zcip.c | |||
@@ -182,7 +182,7 @@ static ALWAYS_INLINE unsigned random_delay_ms(unsigned secs) | |||
182 | * main program | 182 | * main program |
183 | */ | 183 | */ |
184 | int zcip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 184 | int zcip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
185 | int zcip_main(int argc, char **argv) | 185 | int zcip_main(int argc UNUSED_PARAM, char **argv) |
186 | { | 186 | { |
187 | int state; | 187 | int state; |
188 | char *r_opt; | 188 | char *r_opt; |
@@ -241,7 +241,6 @@ int zcip_main(int argc, char **argv) | |||
241 | bb_error_msg_and_die("invalid link address"); | 241 | bb_error_msg_and_die("invalid link address"); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | argc -= optind; | ||
245 | argv += optind - 1; | 244 | argv += optind - 1; |
246 | 245 | ||
247 | /* Now: argv[0]:junk argv[1]:intf argv[2]:script argv[3]:NULL */ | 246 | /* Now: argv[0]:junk argv[1]:intf argv[2]:script argv[3]:NULL */ |
diff --git a/procps/free.c b/procps/free.c index e76dd21a5..b13859103 100644 --- a/procps/free.c +++ b/procps/free.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include "libbb.h" | 12 | #include "libbb.h" |
13 | 13 | ||
14 | int free_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 14 | int free_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
15 | int free_main(int argc, char **argv) | 15 | int free_main(int argc UNUSED_PARAM, char **argv) |
16 | { | 16 | { |
17 | struct sysinfo info; | 17 | struct sysinfo info; |
18 | sysinfo(&info); | 18 | sysinfo(&info); |
@@ -46,7 +46,7 @@ int free_main(int argc, char **argv) | |||
46 | info.bufferram*=info.mem_unit; | 46 | info.bufferram*=info.mem_unit; |
47 | } | 47 | } |
48 | 48 | ||
49 | if (argc > 1 && *argv[1] == '-') | 49 | if (argv[1] && argv[1][0] == '-') |
50 | bb_show_usage(); | 50 | bb_show_usage(); |
51 | 51 | ||
52 | printf("%6s%13s%13s%13s%13s%13s\n", "", "total", "used", "free", | 52 | printf("%6s%13s%13s%13s%13s%13s\n", "", "total", "used", "free", |
diff --git a/procps/nmeter.c b/procps/nmeter.c index 5c3525dc7..bb1e819a6 100644 --- a/procps/nmeter.c +++ b/procps/nmeter.c | |||
@@ -785,7 +785,7 @@ static init_func *const init_functions[] = { | |||
785 | }; | 785 | }; |
786 | 786 | ||
787 | int nmeter_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 787 | int nmeter_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
788 | int nmeter_main(int argc, char **argv) | 788 | int nmeter_main(int argc UNUSED_PARAM, char **argv) |
789 | { | 789 | { |
790 | char buf[32]; | 790 | char buf[32]; |
791 | s_stat *first = NULL; | 791 | s_stat *first = NULL; |
@@ -797,7 +797,7 @@ int nmeter_main(int argc, char **argv) | |||
797 | 797 | ||
798 | xchdir("/proc"); | 798 | xchdir("/proc"); |
799 | 799 | ||
800 | if (argc != 2) | 800 | if (!argv[1]) |
801 | bb_show_usage(); | 801 | bb_show_usage(); |
802 | 802 | ||
803 | if (open_read_close("version", buf, sizeof(buf)-1) > 0) { | 803 | if (open_read_close("version", buf, sizeof(buf)-1) > 0) { |
diff --git a/selinux/load_policy.c b/selinux/load_policy.c index 4bc873e81..ea7c9132a 100644 --- a/selinux/load_policy.c +++ b/selinux/load_policy.c | |||
@@ -7,11 +7,11 @@ | |||
7 | #include "libbb.h" | 7 | #include "libbb.h" |
8 | 8 | ||
9 | int load_policy_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 9 | int load_policy_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
10 | int load_policy_main(int argc, char **argv UNUSED_PARAM) | 10 | int load_policy_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
11 | { | 11 | { |
12 | int rc; | 12 | int rc; |
13 | 13 | ||
14 | if (argc != 1) { | 14 | if (argv[1]) { |
15 | bb_show_usage(); | 15 | bb_show_usage(); |
16 | } | 16 | } |
17 | 17 | ||
diff --git a/selinux/setenforce.c b/selinux/setenforce.c index a2d04288b..45f82238c 100644 --- a/selinux/setenforce.c +++ b/selinux/setenforce.c | |||
@@ -21,11 +21,11 @@ static const char *const setenforce_cmd[] = { | |||
21 | }; | 21 | }; |
22 | 22 | ||
23 | int setenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 23 | int setenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
24 | int setenforce_main(int argc, char **argv) | 24 | int setenforce_main(int argc UNUSED_PARAM, char **argv) |
25 | { | 25 | { |
26 | int i, rc; | 26 | int i, rc; |
27 | 27 | ||
28 | if (argc != 2) | 28 | if (!argv[1] || argv[2]) |
29 | bb_show_usage(); | 29 | bb_show_usage(); |
30 | 30 | ||
31 | selinux_or_die(); | 31 | selinux_or_die(); |
diff --git a/selinux/setfiles.c b/selinux/setfiles.c index 0a4643784..4686d8042 100644 --- a/selinux/setfiles.c +++ b/selinux/setfiles.c | |||
@@ -490,7 +490,7 @@ static int process_one(char *name) | |||
490 | } | 490 | } |
491 | 491 | ||
492 | int setfiles_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 492 | int setfiles_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
493 | int setfiles_main(int argc, char **argv) | 493 | int setfiles_main(int argc UNUSED_PARAM, char **argv) |
494 | { | 494 | { |
495 | struct stat sb; | 495 | struct stat sb; |
496 | int rc, i = 0; | 496 | int rc, i = 0; |
@@ -549,6 +549,7 @@ int setfiles_main(int argc, char **argv) | |||
549 | IF_FEATURE_SETFILES_CHECK_OPTION(&policyfile,) | 549 | IF_FEATURE_SETFILES_CHECK_OPTION(&policyfile,) |
550 | &verbose); | 550 | &verbose); |
551 | } | 551 | } |
552 | argv += optind; | ||
552 | 553 | ||
553 | #if ENABLE_FEATURE_SETFILES_CHECK_OPTION | 554 | #if ENABLE_FEATURE_SETFILES_CHECK_OPTION |
554 | if ((applet_name[0] == 's') && (flags & OPT_c)) { | 555 | if ((applet_name[0] == 's') && (flags & OPT_c)) { |
@@ -595,24 +596,20 @@ int setfiles_main(int argc, char **argv) | |||
595 | we can support either checking against the active policy or | 596 | we can support either checking against the active policy or |
596 | checking against a binary policy file. */ | 597 | checking against a binary policy file. */ |
597 | set_matchpathcon_canoncon(&canoncon); | 598 | set_matchpathcon_canoncon(&canoncon); |
598 | if (argc == 1) | 599 | if (!argv[0]) |
599 | bb_show_usage(); | 600 | bb_show_usage(); |
600 | if (stat(argv[optind], &sb) < 0) { | 601 | xstat(argv[0], &sb); |
601 | bb_simple_perror_msg_and_die(argv[optind]); | ||
602 | } | ||
603 | if (!S_ISREG(sb.st_mode)) { | 602 | if (!S_ISREG(sb.st_mode)) { |
604 | bb_error_msg_and_die("spec file %s is not a regular file", argv[optind]); | 603 | bb_error_msg_and_die("spec file %s is not a regular file", argv[0]); |
605 | } | 604 | } |
606 | /* Load the file contexts configuration and check it. */ | 605 | /* Load the file contexts configuration and check it. */ |
607 | rc = matchpathcon_init(argv[optind]); | 606 | rc = matchpathcon_init(argv[0]); |
608 | if (rc < 0) { | 607 | if (rc < 0) { |
609 | bb_simple_perror_msg_and_die(argv[optind]); | 608 | bb_simple_perror_msg_and_die(argv[0]); |
610 | } | 609 | } |
611 | |||
612 | optind++; | ||
613 | |||
614 | if (nerr) | 610 | if (nerr) |
615 | exit(EXIT_FAILURE); | 611 | exit(EXIT_FAILURE); |
612 | argv++; | ||
616 | } | 613 | } |
617 | 614 | ||
618 | if (input_filename) { | 615 | if (input_filename) { |
@@ -628,9 +625,9 @@ int setfiles_main(int argc, char **argv) | |||
628 | if (ENABLE_FEATURE_CLEAN_UP) | 625 | if (ENABLE_FEATURE_CLEAN_UP) |
629 | fclose_if_not_stdin(f); | 626 | fclose_if_not_stdin(f); |
630 | } else { | 627 | } else { |
631 | if (optind >= argc) | 628 | if (!argv[0]) |
632 | bb_show_usage(); | 629 | bb_show_usage(); |
633 | for (i = optind; i < argc; i++) { | 630 | for (i = 0; argv[i]; i++) { |
634 | errors |= process_one(argv[i]); | 631 | errors |= process_one(argv[i]); |
635 | } | 632 | } |
636 | } | 633 | } |
diff --git a/shell/bbsh.c b/shell/bbsh.c index c3726263a..83132f928 100644 --- a/shell/bbsh.c +++ b/shell/bbsh.c | |||
@@ -199,7 +199,7 @@ static void handle(char *command) | |||
199 | } | 199 | } |
200 | 200 | ||
201 | int bbsh_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 201 | int bbsh_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
202 | int bbsh_main(int argc, char **argv) | 202 | int bbsh_main(int argc UNUSED_PARAM, char **argv) |
203 | { | 203 | { |
204 | char *command=NULL; | 204 | char *command=NULL; |
205 | FILE *f; | 205 | FILE *f; |
diff --git a/sysklogd/logger.c b/sysklogd/logger.c index 759981c75..def833070 100644 --- a/sysklogd/logger.c +++ b/sysklogd/logger.c | |||
@@ -69,7 +69,7 @@ static int pencode(char *s) | |||
69 | #define strbuf bb_common_bufsiz1 | 69 | #define strbuf bb_common_bufsiz1 |
70 | 70 | ||
71 | int logger_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 71 | int logger_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
72 | int logger_main(int argc, char **argv) | 72 | int logger_main(int argc UNUSED_PARAM, char **argv) |
73 | { | 73 | { |
74 | char *str_p, *str_t; | 74 | char *str_p, *str_t; |
75 | int opt; | 75 | int opt; |
@@ -89,9 +89,8 @@ int logger_main(int argc, char **argv) | |||
89 | if (opt & 0x1) /* -p */ | 89 | if (opt & 0x1) /* -p */ |
90 | i = pencode(str_p); | 90 | i = pencode(str_p); |
91 | 91 | ||
92 | argc -= optind; | ||
93 | argv += optind; | 92 | argv += optind; |
94 | if (!argc) { | 93 | if (!argv[0]) { |
95 | while (fgets(strbuf, COMMON_BUFSIZE, stdin)) { | 94 | while (fgets(strbuf, COMMON_BUFSIZE, stdin)) { |
96 | if (strbuf[0] | 95 | if (strbuf[0] |
97 | && NOT_LONE_CHAR(strbuf, '\n') | 96 | && NOT_LONE_CHAR(strbuf, '\n') |
diff --git a/util-linux/acpid.c b/util-linux/acpid.c index 7dd4f5b15..342930964 100644 --- a/util-linux/acpid.c +++ b/util-linux/acpid.c | |||
@@ -74,6 +74,7 @@ int acpid_main(int argc, char **argv) | |||
74 | } | 74 | } |
75 | 75 | ||
76 | argv += optind; | 76 | argv += optind; |
77 | argc -= optind; | ||
77 | 78 | ||
78 | // goto configuration directory | 79 | // goto configuration directory |
79 | xchdir(opt_conf); | 80 | xchdir(opt_conf); |
@@ -102,7 +103,7 @@ int acpid_main(int argc, char **argv) | |||
102 | // evdev files given, use evdev interface | 103 | // evdev files given, use evdev interface |
103 | 104 | ||
104 | // open event devices | 105 | // open event devices |
105 | pfd = xzalloc(sizeof(*pfd) * (argc - optind)); | 106 | pfd = xzalloc(sizeof(*pfd) * argc); |
106 | nfd = 0; | 107 | nfd = 0; |
107 | while (*argv) { | 108 | while (*argv) { |
108 | pfd[nfd].fd = open_or_warn(*argv++, O_RDONLY | O_NONBLOCK); | 109 | pfd[nfd].fd = open_or_warn(*argv++, O_RDONLY | O_NONBLOCK); |