From fe7cd642b0b732f5d41403c2f6983ad676b69dd9 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sat, 18 Aug 2007 15:32:12 +0000 Subject: don't pass argc in getopt32, it's superfluous (add/remove: 0/0 grow/shrink: 12/131 up/down: 91/-727) Total: -636 bytes text data bss dec hex filename 773469 1058 11092 785619 bfcd3 busybox_old 772644 1058 11092 784794 bf99a busybox_unstripped --- archival/ar.c | 2 +- archival/bbunzip.c | 8 ++++---- archival/cpio.c | 2 +- archival/dpkg.c | 2 +- archival/dpkg_deb.c | 2 +- archival/gzip.c | 2 +- archival/tar.c | 2 +- console-tools/setconsole.c | 2 +- coreutils/cal.c | 2 +- coreutils/cat.c | 2 +- coreutils/catv.c | 2 +- coreutils/chmod.c | 2 +- coreutils/chown.c | 2 +- coreutils/comm.c | 2 +- coreutils/cp.c | 2 +- coreutils/cut.c | 2 +- coreutils/date.c | 2 +- coreutils/df.c | 4 ++-- coreutils/dos2unix.c | 2 +- coreutils/du.c | 4 ++-- coreutils/env.c | 2 +- coreutils/expand.c | 4 ++-- coreutils/fold.c | 2 +- coreutils/id.c | 2 +- coreutils/install.c | 2 +- coreutils/libcoreutils/getopt_mk_fifo_nod.c | 2 +- coreutils/ln.c | 2 +- coreutils/ls.c | 4 ++-- coreutils/md5_sha1_sum.c | 2 +- coreutils/mkdir.c | 2 +- coreutils/mv.c | 2 +- coreutils/od_bloaty.c | 2 +- coreutils/readlink.c | 2 +- coreutils/rm.c | 2 +- coreutils/rmdir.c | 2 +- coreutils/sort.c | 2 +- coreutils/split.c | 2 +- coreutils/stat.c | 2 +- coreutils/sum.c | 2 +- coreutils/tail.c | 2 +- coreutils/tee.c | 2 +- coreutils/touch.c | 2 +- coreutils/tty.c | 2 +- coreutils/uname.c | 2 +- coreutils/uniq.c | 2 +- coreutils/uudecode.c | 2 +- coreutils/uuencode.c | 2 +- coreutils/wc.c | 2 +- debianutils/mktemp.c | 2 +- debianutils/run_parts.c | 2 +- debianutils/start_stop_daemon.c | 2 +- e2fsprogs/lsattr.c | 2 +- e2fsprogs/old_e2fsprogs/lsattr.c | 2 +- editors/awk.c | 2 +- editors/cmp.c | 2 +- editors/diff.c | 2 +- editors/patch.c | 2 +- editors/sed.c | 2 +- findutils/grep.c | 4 ++-- findutils/xargs.c | 2 +- init/halt.c | 2 +- ipsvd/tcpudp.c | 4 ++-- libbb/getopt32.c | 31 +++++++++++++++++------------ loginutils/addgroup.c | 2 +- loginutils/adduser.c | 2 +- loginutils/chpasswd.c | 2 +- loginutils/cryptpw.c | 2 +- loginutils/getty.c | 2 +- loginutils/login.c | 2 +- loginutils/passwd.c | 2 +- loginutils/su.c | 2 +- loginutils/sulogin.c | 2 +- loginutils/vlock.c | 2 +- miscutils/adjtimex.c | 2 +- miscutils/chrt.c | 2 +- miscutils/eject.c | 2 +- miscutils/less.c | 2 +- miscutils/makedevs.c | 2 +- miscutils/mountpoint.c | 2 +- miscutils/strings.c | 2 +- miscutils/taskset.c | 2 +- miscutils/watchdog.c | 2 +- modutils/insmod.c | 2 +- modutils/modprobe.c | 2 +- modutils/rmmod.c | 2 +- networking/arp.c | 2 +- networking/arping.c | 2 +- networking/dnsd.c | 2 +- networking/ether-wake.c | 2 +- networking/ftpgetput.c | 2 +- networking/hostname.c | 2 +- networking/httpd.c | 2 +- networking/ifupdown.c | 2 +- networking/inetd.c | 2 +- networking/ipcalc.c | 2 +- networking/isrv_identd.c | 2 +- networking/nameif.c | 2 +- networking/nc_bloaty.c | 2 +- networking/netstat.c | 2 +- networking/ping.c | 2 +- networking/pscan.c | 2 +- networking/route.c | 2 +- networking/slattach.c | 2 +- networking/telnet.c | 2 +- networking/telnetd.c | 2 +- networking/tftp.c | 2 +- networking/traceroute.c | 2 +- networking/udhcp/dhcpc.c | 2 +- networking/udhcp/dhcpd.c | 2 +- networking/udhcp/dumpleases.c | 2 +- networking/wget.c | 2 +- networking/zcip.c | 2 +- procps/pidof.c | 2 +- procps/ps.c | 6 +++--- procps/top.c | 2 +- procps/watch.c | 2 +- runit/chpst.c | 4 ++-- runit/sv.c | 2 +- runit/svlogd.c | 2 +- selinux/chcon.c | 2 +- selinux/getsebool.c | 2 +- selinux/matchpathcon.c | 2 +- selinux/runcon.c | 2 +- selinux/setfiles.c | 4 ++-- shell/bbsh.c | 2 +- sysklogd/klogd.c | 2 +- sysklogd/logger.c | 2 +- sysklogd/logread.c | 2 +- sysklogd/syslogd.c | 2 +- util-linux/dmesg.c | 2 +- util-linux/fdformat.c | 2 +- util-linux/fdisk.c | 2 +- util-linux/getopt.c | 4 ++-- util-linux/hwclock.c | 2 +- util-linux/ipcs.c | 2 +- util-linux/losetup.c | 2 +- util-linux/mkfs_minix.c | 2 +- util-linux/mount.c | 2 +- util-linux/rdate.c | 2 +- util-linux/readprofile.c | 2 +- util-linux/swaponoff.c | 2 +- util-linux/switch_root.c | 2 +- util-linux/umount.c | 2 +- 143 files changed, 174 insertions(+), 169 deletions(-) diff --git a/archival/ar.c b/archival/ar.c index 7b16c2b59..db23c2b73 100644 --- a/archival/ar.c +++ b/archival/ar.c @@ -52,7 +52,7 @@ int ar_main(int argc, char **argv) /* Prepend '-' to the first argument if required */ opt_complementary = "--:p:t:x:-1:p--tx:t--px:x--pt"; - opt = getopt32(argc, argv, "ptxovcr"); + opt = getopt32(argv, "ptxovcr"); if (opt & AR_CTX_PRINT) { archive_handle->action_data = data_extract_to_stdout; diff --git a/archival/bbunzip.c b/archival/bbunzip.c index f824fcf67..56c742a49 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c @@ -161,7 +161,7 @@ USE_DESKTOP(long long) int unpack_bunzip2(void) int bunzip2_main(int argc, char **argv); int bunzip2_main(int argc, char **argv) { - getopt32(argc, argv, "cf"); + getopt32(argv, "cf"); argv += optind; if (applet_name[2] == 'c') option_mask32 |= OPT_STDOUT; @@ -260,7 +260,7 @@ USE_DESKTOP(long long) int unpack_gunzip(void) int gunzip_main(int argc, char **argv); int gunzip_main(int argc, char **argv) { - getopt32(argc, argv, "cfvdt"); + getopt32(argv, "cfvdt"); argv += optind; /* if called as zcat */ if (applet_name[1] == 'c') @@ -298,7 +298,7 @@ USE_DESKTOP(long long) int unpack_unlzma(void) int unlzma_main(int argc, char **argv); int unlzma_main(int argc, char **argv) { - getopt32(argc, argv, "c"); + getopt32(argv, "c"); argv += optind; /* lzmacat? */ if (applet_name[4] == 'c') @@ -340,7 +340,7 @@ USE_DESKTOP(long long) int unpack_uncompress(void) int uncompress_main(int argc, char **argv); int uncompress_main(int argc, char **argv) { - getopt32(argc, argv, "cf"); + getopt32(argv, "cf"); argv += optind; return bbunpack(argv, make_new_name_uncompress, unpack_uncompress); diff --git a/archival/cpio.c b/archival/cpio.c index 72d31c35d..9188e09f1 100644 --- a/archival/cpio.c +++ b/archival/cpio.c @@ -35,7 +35,7 @@ int cpio_main(int argc, char **argv) archive_handle->seek = seek_by_read; archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE; - opt = getopt32(argc, argv, "ituvF:dm", &cpio_filename); + opt = getopt32(argv, "ituvF:dm", &cpio_filename); /* One of either extract or test options must be given */ if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) { diff --git a/archival/dpkg.c b/archival/dpkg.c index b5fc06d3d..337576ccd 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c @@ -1579,7 +1579,7 @@ int dpkg_main(int argc, char **argv) OPT_unpack = 0x40, }; - opt = getopt32(argc, argv, "CF:ilPru", &str_f); + opt = getopt32(argv, "CF:ilPru", &str_f); //if (opt & OPT_configure) ... // -C if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg) if (strcmp(str_f, "depends")) diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c index 6dd817101..9781b54e5 100644 --- a/archival/dpkg_deb.c +++ b/archival/dpkg_deb.c @@ -42,7 +42,7 @@ int dpkg_deb_main(int argc, char **argv) #endif opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX"; - opt = getopt32(argc, argv, "cefXx"); + opt = getopt32(argv, "cefXx"); if (opt & DPKG_DEB_OPT_CONTENTS) { tar_archive->action_header = header_verbose_list; diff --git a/archival/gzip.c b/archival/gzip.c index 83d78e47c..bda4ae102 100644 --- a/archival/gzip.c +++ b/archival/gzip.c @@ -2031,7 +2031,7 @@ int gzip_main(int argc, char **argv) unsigned opt; /* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */ - opt = getopt32(argc, argv, "cfv" USE_GUNZIP("d") "q123456789" ); + opt = getopt32(argv, "cfv" USE_GUNZIP("d") "q123456789" ); option_mask32 &= 0x7; /* Clear -d, ignore -q, -0..9 */ //if (opt & 0x1) // -c //if (opt & 0x2) // -f diff --git a/archival/tar.c b/archival/tar.c index bed8cf24c..9bf9058d8 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -788,7 +788,7 @@ int tar_main(int argc, char **argv) #if ENABLE_FEATURE_TAR_LONG_OPTIONS applet_long_options = tar_longopts; #endif - opt = getopt32(argc, argv, + opt = getopt32(argv, "txC:f:Opvk" USE_FEATURE_TAR_CREATE( "ch" ) USE_FEATURE_TAR_BZIP2( "j" ) diff --git a/console-tools/setconsole.c b/console-tools/setconsole.c index a9bbc78d5..32218ae8f 100644 --- a/console-tools/setconsole.c +++ b/console-tools/setconsole.c @@ -27,7 +27,7 @@ int setconsole_main(int argc, char **argv) #if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS applet_long_options = setconsole_longopts; #endif - flags = getopt32(argc, argv, "r"); + flags = getopt32(argv, "r"); if (argc - optind > 1) bb_show_usage(); diff --git a/coreutils/cal.c b/coreutils/cal.c index 317099385..35a563145 100644 --- a/coreutils/cal.c +++ b/coreutils/cal.c @@ -86,7 +86,7 @@ int cal_main(int argc, char **argv) char day_headings[28]; /* 28 for julian, 21 for nonjulian */ char buf[40]; - flags = getopt32(argc, argv, "jy"); + flags = getopt32(argv, "jy"); julian = flags & 1; month = 0; argv += optind; diff --git a/coreutils/cat.c b/coreutils/cat.c index 64e697eb3..cd5277819 100644 --- a/coreutils/cat.c +++ b/coreutils/cat.c @@ -46,7 +46,7 @@ int bb_cat(char **argv) int cat_main(int argc, char **argv); int cat_main(int argc, char **argv) { - getopt32(argc, argv, "u"); + getopt32(argv, "u"); argv += optind; return bb_cat(argv); } diff --git a/coreutils/catv.c b/coreutils/catv.c index 0ca73a0c9..ce927465b 100644 --- a/coreutils/catv.c +++ b/coreutils/catv.c @@ -19,7 +19,7 @@ int catv_main(int argc, char **argv) int fd; unsigned flags; - flags = getopt32(argc, argv, "etv"); + flags = getopt32(argv, "etv"); #define CATV_OPT_e (1<<0) #define CATV_OPT_t (1<<1) #define CATV_OPT_v (1<<2) diff --git a/coreutils/chmod.c b/coreutils/chmod.c index 52cc40d97..8b214991a 100644 --- a/coreutils/chmod.c +++ b/coreutils/chmod.c @@ -93,7 +93,7 @@ int chmod_main(int argc, char **argv) /* Parse options */ opt_complementary = "-2"; - getopt32(argc, argv, ("-"OPT_STR) + 1); /* Reuse string */ + getopt32(argv, ("-"OPT_STR) + 1); /* Reuse string */ argv += optind; /* Restore option-like mode if needed */ diff --git a/coreutils/chown.c b/coreutils/chown.c index eb8d8c450..cfd373456 100644 --- a/coreutils/chown.c +++ b/coreutils/chown.c @@ -69,7 +69,7 @@ int chown_main(int argc, char **argv) chown_fptr chown_func; opt_complementary = "-2"; - getopt32(argc, argv, OPT_STR); + getopt32(argv, OPT_STR); argv += optind; /* This matches coreutils behavior (almost - see below) */ diff --git a/coreutils/comm.c b/coreutils/comm.c index 3be6760dc..a4ab14826 100644 --- a/coreutils/comm.c +++ b/coreutils/comm.c @@ -47,7 +47,7 @@ int comm_main(int argc, char **argv) unsigned flags; opt_complementary = "=2"; - flags = getopt32(argc, argv, "123"); + flags = getopt32(argv, "123"); argv += optind; for (i = 0; i < 2; ++i) { diff --git a/coreutils/cp.c b/coreutils/cp.c index 78bd73c0f..884fbf70f 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c @@ -45,7 +45,7 @@ int cp_main(int argc, char **argv) // -r and -R are the same // -a = -pdR opt_complementary = "l--s:s--l:Pd:rR:apdR"; - flags = getopt32(argc, argv, FILEUTILS_CP_OPTSTR "arPHL"); + flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPHL"); /* Default behavior of cp is to dereference, so we don't have to do * anything special when we are given -L. * The behavior of -H is *almost* like -L, but not quite, so let's diff --git a/coreutils/cut.c b/coreutils/cut.c index 2598a9a7c..1cf49c2af 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c @@ -171,7 +171,7 @@ int cut_main(int argc, char **argv) char *sopt, *ltok; opt_complementary = "b--bcf:c--bcf:f--bcf"; - getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, <ok); + getopt32(argv, optstring, &sopt, &sopt, &sopt, <ok); // argc -= optind; argv += optind; if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS))) diff --git a/coreutils/date.c b/coreutils/date.c index 5ee70f703..e33a9777d 100644 --- a/coreutils/date.c +++ b/coreutils/date.c @@ -53,7 +53,7 @@ int date_main(int argc, char **argv) opt_complementary = "d--s:s--d" USE_FEATURE_DATE_ISOFMT(":R--I:I--R"); - opt = getopt32(argc, argv, "Rs:ud:r:" + opt = getopt32(argv, "Rs:ud:r:" USE_FEATURE_DATE_ISOFMT("I::D:"), &date_str, &date_str, &filename USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg)); diff --git a/coreutils/df.c b/coreutils/df.c index fba59e791..7eb82cd46 100644 --- a/coreutils/df.c +++ b/coreutils/df.c @@ -47,7 +47,7 @@ int df_main(int argc, char **argv) #if ENABLE_FEATURE_HUMAN_READABLE opt_complementary = "h-km:k-hm:m-hk"; - opt = getopt32(argc, argv, "hmk"); + opt = getopt32(argv, "hmk"); if (opt & 1) { df_disp_hr = 0; disp_units_hdr = " Size"; @@ -57,7 +57,7 @@ int df_main(int argc, char **argv) disp_units_hdr = "1M-blocks"; } #else - opt = getopt32(argc, argv, "k"); + opt = getopt32(argv, "k"); #endif printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n", diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c index 1bfdf0cde..28110980a 100644 --- a/coreutils/dos2unix.c +++ b/coreutils/dos2unix.c @@ -92,7 +92,7 @@ int dos2unix_main(int argc, char **argv) /* -u convert to unix, -d convert to dos */ opt_complementary = "u--d:d--u"; /* mutually exclusive */ - o = getopt32(argc, argv, "du"); + o = getopt32(argv, "du"); /* Do the conversion requested by an argument else do the default * conversion depending on our name. */ diff --git a/coreutils/du.c b/coreutils/du.c index 19748719a..757fa14cc 100644 --- a/coreutils/du.c +++ b/coreutils/du.c @@ -170,7 +170,7 @@ int du_main(int argc, char **argv) */ #if ENABLE_FEATURE_HUMAN_READABLE opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s"; - opt = getopt32(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth); + opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth); if (opt & (1 << 9)) { /* -h opt */ disp_hr = 0; @@ -185,7 +185,7 @@ int du_main(int argc, char **argv) } #else opt_complementary = "H-L:L-H:s-d:d-s"; - opt = getopt32(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth); + opt = getopt32(argv, "aHkLsx" "d:" "lc", &smax_print_depth); #if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K if (opt & (1 << 2)) { /* -k opt */ diff --git a/coreutils/env.c b/coreutils/env.c index dc8667181..8d2d881fa 100644 --- a/coreutils/env.c +++ b/coreutils/env.c @@ -54,7 +54,7 @@ int env_main(int argc, char** argv) #if ENABLE_FEATURE_ENV_LONG_OPTIONS applet_long_options = env_longopts; #endif - opt = getopt32(argc, argv, "+iu:", &unset_env); + opt = getopt32(argv, "+iu:", &unset_env); argv += optind; if (*argv && LONE_DASH(argv[0])) { opt |= 1; diff --git a/coreutils/expand.c b/coreutils/expand.c index 4b5fa1038..274753fd4 100644 --- a/coreutils/expand.c +++ b/coreutils/expand.c @@ -153,12 +153,12 @@ int expand_main(int argc, char **argv) if (ENABLE_EXPAND && (!ENABLE_UNEXPAND || applet_name[0] == 'e')) { USE_FEATURE_EXPAND_LONG_OPTIONS(applet_long_options = expand_longopts); - opt = getopt32(argc, argv, "it:", &opt_t); + opt = getopt32(argv, "it:", &opt_t); } else if (ENABLE_UNEXPAND) { USE_FEATURE_UNEXPAND_LONG_OPTIONS(applet_long_options = unexpand_longopts); /* -t NUM sets also -a */ opt_complementary = "ta"; - opt = getopt32(argc, argv, "ft:a", &opt_t); + opt = getopt32(argv, "ft:a", &opt_t); /* -f --first-only is the default */ if (!(opt & OPT_ALL)) opt |= OPT_INITIAL; } diff --git a/coreutils/fold.c b/coreutils/fold.c index 11b880969..01849615e 100644 --- a/coreutils/fold.c +++ b/coreutils/fold.c @@ -63,7 +63,7 @@ int fold_main(int argc, char **argv) } } - flags = getopt32(argc, argv, "bsw:", &w_opt); + flags = getopt32(argv, "bsw:", &w_opt); if (flags & FLAG_WIDTH) width = xatoul_range(w_opt, 1, 10000); diff --git a/coreutils/id.c b/coreutils/id.c index 614d6d064..1cc8c4d1d 100644 --- a/coreutils/id.c +++ b/coreutils/id.c @@ -50,7 +50,7 @@ int id_main(int argc, char **argv) /* Don't allow -n -r -nr -ug -rug -nug -rnug */ /* Don't allow more than one username */ opt_complementary = "?1:u--g:g--u:r?ug:n?ug" USE_SELINUX(":u--Z:Z--u:g--Z:Z--g"); - flags = getopt32(argc, argv, "rnug" USE_SELINUX("Z")); + flags = getopt32(argv, "rnug" USE_SELINUX("Z")); /* This values could be overwritten later */ uid = geteuid(); diff --git a/coreutils/install.c b/coreutils/install.c index 79cd02036..cf62a0022 100644 --- a/coreutils/install.c +++ b/coreutils/install.c @@ -101,7 +101,7 @@ int install_main(int argc, char **argv) opt_complementary = "s--d:d--s" USE_SELINUX(":Z--\xff:\xff--Z"); /* -c exists for backwards compatibility, it's needed */ - flags = getopt32(argc, argv, "cdpsg:m:o:" USE_SELINUX("Z:"), + flags = getopt32(argv, "cdpsg:m:o:" USE_SELINUX("Z:"), &gid_str, &mode_str, &uid_str USE_SELINUX(, &scontext)); #if ENABLE_SELINUX diff --git a/coreutils/libcoreutils/getopt_mk_fifo_nod.c b/coreutils/libcoreutils/getopt_mk_fifo_nod.c index 6fd2de73f..377621568 100644 --- a/coreutils/libcoreutils/getopt_mk_fifo_nod.c +++ b/coreutils/libcoreutils/getopt_mk_fifo_nod.c @@ -31,7 +31,7 @@ mode_t getopt_mk_fifo_nod(int argc, char **argv) security_context_t scontext; #endif int opt; - opt = getopt32(argc, argv, "m:" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext)); + opt = getopt32(argv, "m:" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext)); if (opt & 1) { if (bb_parse_mode(smode, &mode)) umask(0); diff --git a/coreutils/ln.c b/coreutils/ln.c index cffd4fdb5..a6499039e 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c @@ -34,7 +34,7 @@ int ln_main(int argc, char **argv) struct stat statbuf; int (*link_func)(const char *, const char *); - flag = getopt32(argc, argv, "sfnbS:", &suffix); + flag = getopt32(argv, "sfnbS:", &suffix); if (argc == optind) { bb_show_usage(); diff --git a/coreutils/ls.c b/coreutils/ls.c index 2b2925557..4adf523d3 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -820,14 +820,14 @@ int ls_main(int argc, char **argv) /* process options */ USE_FEATURE_LS_COLOR(applet_long_options = ls_color_opt;) #if ENABLE_FEATURE_AUTOWIDTH - opt = getopt32(argc, argv, ls_options, &tabstops_str, &terminal_width_str + opt = getopt32(argv, ls_options, &tabstops_str, &terminal_width_str USE_FEATURE_LS_COLOR(, &color_opt)); if (tabstops_str) tabstops = xatou(tabstops_str); if (terminal_width_str) terminal_width = xatou(terminal_width_str); #else - opt = getopt32(argc, argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt)); + opt = getopt32(argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt)); #endif for (i = 0; opt_flags[i] != (1U<<31); i++) { if (opt & (1 << i)) { diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c index 8bc203486..7f8b08497 100644 --- a/coreutils/md5_sha1_sum.c +++ b/coreutils/md5_sha1_sum.c @@ -88,7 +88,7 @@ int md5_sha1_sum_main(int argc, char **argv) : HASH_SHA1; if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK) - flags = getopt32(argc, argv, "scw"); + flags = getopt32(argv, "scw"); else optind = 1; if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && !(flags & FLAG_CHECK)) { diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c index 22a070c31..d1a4380ad 100644 --- a/coreutils/mkdir.c +++ b/coreutils/mkdir.c @@ -49,7 +49,7 @@ int mkdir_main(int argc, char **argv) #if ENABLE_FEATURE_MKDIR_LONG_OPTIONS applet_long_options = mkdir_longopts; #endif - opt = getopt32(argc, argv, "m:p" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext)); + opt = getopt32(argv, "m:p" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext)); if (opt & 1) { mode = 0777; if (!bb_parse_mode(smode, &mode)) { diff --git a/coreutils/mv.c b/coreutils/mv.c index 4cd0fcfba..553bb6ecb 100644 --- a/coreutils/mv.c +++ b/coreutils/mv.c @@ -48,7 +48,7 @@ int mv_main(int argc, char **argv) applet_long_options = mv_longopts; #endif opt_complementary = "f-i:i-f"; - flags = getopt32(argc, argv, "fi"); + flags = getopt32(argv, "fi"); if (optind + 2 > argc) { bb_show_usage(); } diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c index d3c9f9a17..8174ab6c9 100644 --- a/coreutils/od_bloaty.c +++ b/coreutils/od_bloaty.c @@ -1259,7 +1259,7 @@ int od_main(int argc, char **argv) #if ENABLE_GETOPT_LONG applet_long_options = od_longopts; #endif - opt = getopt32(argc, argv, "A:N:abcdfhij:lot:vxsS:" + opt = getopt32(argv, "A:N:abcdfhij:lot:vxsS:" "w::", // -w with optional param // -S was -s and also had optional parameter // but in coreutils 6.3 it was renamed and now has diff --git a/coreutils/readlink.c b/coreutils/readlink.c index d454cbf19..39edc0569 100644 --- a/coreutils/readlink.c +++ b/coreutils/readlink.c @@ -21,7 +21,7 @@ int readlink_main(int argc, char **argv) unsigned opt; /* We need exactly one non-option argument. */ opt_complementary = "=1"; - opt = getopt32(argc, argv, "f"); + opt = getopt32(argv, "f"); fname = argv[optind]; ) SKIP_FEATURE_READLINK_FOLLOW( diff --git a/coreutils/rm.c b/coreutils/rm.c index cc2264770..ba37762a8 100644 --- a/coreutils/rm.c +++ b/coreutils/rm.c @@ -27,7 +27,7 @@ int rm_main(int argc, char **argv) unsigned opt; opt_complementary = "f-i:i-f"; - opt = getopt32(argc, argv, "fiRr"); + opt = getopt32(argv, "fiRr"); argv += optind; if (opt & 1) flags |= FILEUTILS_FORCE; diff --git a/coreutils/rmdir.c b/coreutils/rmdir.c index c1b89e427..315401e0e 100644 --- a/coreutils/rmdir.c +++ b/coreutils/rmdir.c @@ -24,7 +24,7 @@ int rmdir_main(int argc, char **argv) int do_dot; char *path; - flags = getopt32(argc, argv, "p"); + flags = getopt32(argv, "p"); argv += optind; if (!*argv) { diff --git a/coreutils/sort.c b/coreutils/sort.c index 98c1bc34a..311c774ae 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c @@ -290,7 +290,7 @@ int sort_main(int argc, char **argv) /* -o and -t can be given at most once */ opt_complementary = "o--o:t--t:" /* -t, -o: maximum one of each */ "k::"; /* -k takes list */ - getopt32(argc, argv, OPT_STR, &str_ignored, &str_ignored, &str_o, &lst_k, &str_t); + getopt32(argv, OPT_STR, &str_ignored, &str_ignored, &str_o, &lst_k, &str_t); #if ENABLE_FEATURE_SORT_BIG if (option_mask32 & FLAG_o) outfile = xfopen(str_o, "w"); if (option_mask32 & FLAG_t) { diff --git a/coreutils/split.c b/coreutils/split.c index d1eb82955..3ec539a6a 100644 --- a/coreutils/split.c +++ b/coreutils/split.c @@ -69,7 +69,7 @@ int split_main(int argc, char **argv) char *src; opt_complementary = "?2"; - opt = getopt32(argc, argv, "l:b:a:", &count_p, &count_p, &sfx); + opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &sfx); if (opt & SPLIT_OPT_l) cnt = xatoul(count_p); diff --git a/coreutils/stat.c b/coreutils/stat.c index 0fddea2bb..18e8e076c 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c @@ -614,7 +614,7 @@ int stat_main(int argc, char **argv) int ok = 1; bool (*statfunc)(char const *, char const *) = do_stat; - getopt32(argc, argv, "ftL" + getopt32(argv, "ftL" USE_SELINUX("Z") USE_FEATURE_STAT_FORMAT("c:", &format) ); diff --git a/coreutils/sum.c b/coreutils/sum.c index 5799d142d..4a3760bb4 100644 --- a/coreutils/sum.c +++ b/coreutils/sum.c @@ -80,7 +80,7 @@ int sum_main(int argc, char **argv) unsigned n; unsigned type = SUM_BSD; - n = getopt32(argc, argv, "sr"); + n = getopt32(argv, "sr"); if (n & 1) type = SUM_SYSV; /* give the bsd priority over sysv func */ if (n & 2) type = SUM_BSD; diff --git a/coreutils/tail.c b/coreutils/tail.c index ec21c4234..74e14232d 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c @@ -107,7 +107,7 @@ int tail_main(int argc, char **argv) } #endif - opt = getopt32(argc, argv, "fc:n:" USE_FEATURE_FANCY_TAIL("qs:v"), + opt = getopt32(argv, "fc:n:" USE_FEATURE_FANCY_TAIL("qs:v"), &str_c, &str_n USE_FEATURE_FANCY_TAIL(,&str_s)); #define FOLLOW (opt & 0x1) #define COUNT_BYTES (opt & 0x2) diff --git a/coreutils/tee.c b/coreutils/tee.c index 2160141c9..d253028cc 100644 --- a/coreutils/tee.c +++ b/coreutils/tee.c @@ -28,7 +28,7 @@ int tee_main(int argc, char **argv) #else int c; #endif - retval = getopt32(argc, argv, "ia"); /* 'a' must be 2nd */ + retval = getopt32(argv, "ia"); /* 'a' must be 2nd */ argc -= optind; argv += optind; diff --git a/coreutils/touch.c b/coreutils/touch.c index 7b82339fc..7a1dd3599 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c @@ -26,7 +26,7 @@ int touch_main(int argc, char **argv) { int fd; int status = EXIT_SUCCESS; - int flags = getopt32(argc, argv, "c"); + int flags = getopt32(argv, "c"); argv += optind; diff --git a/coreutils/tty.c b/coreutils/tty.c index 2c77c9960..d8ce78c00 100644 --- a/coreutils/tty.c +++ b/coreutils/tty.c @@ -21,7 +21,7 @@ int tty_main(int argc, char **argv) xfunc_error_retval = 2; /* SUSv3 requires > 1 for error. */ - USE_INCLUDE_SUSv2(silent = getopt32(argc, argv, "s");) + USE_INCLUDE_SUSv2(silent = getopt32(argv, "s");) /* gnu tty outputs a warning that it is ignoring all args. */ bb_warn_ignoring_args(argc - optind); diff --git a/coreutils/uname.c b/coreutils/uname.c index 8f07f1960..e4724c8f1 100644 --- a/coreutils/uname.c +++ b/coreutils/uname.c @@ -58,7 +58,7 @@ int uname_main(int argc, char **argv) const unsigned short int *delta; char toprint; - toprint = getopt32(argc, argv, options); + toprint = getopt32(argv, options); if (argc != optind) { bb_show_usage(); diff --git a/coreutils/uniq.c b/coreutils/uniq.c index a7caef991..719bbb5e3 100644 --- a/coreutils/uniq.c +++ b/coreutils/uniq.c @@ -45,7 +45,7 @@ int uniq_main(int argc, char **argv) skip_fields = skip_chars = 0; - opt = getopt32(argc, argv, "cduf:s:", &s0, &s1); + opt = getopt32(argv, "cduf:s:", &s0, &s1); if (opt & OPT_f) skip_fields = xatoul(s0); if (opt & OPT_s) diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 2dd8f9457..4c918ff02 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c @@ -134,7 +134,7 @@ int uudecode_main(int argc, char **argv) char *line; opt_complementary = "?1"; /* 1 argument max */ - getopt32(argc, argv, "o:", &outname); + getopt32(argv, "o:", &outname); argv += optind; if (argv[0]) diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c index c1458f7fb..56d68820e 100644 --- a/coreutils/uuencode.c +++ b/coreutils/uuencode.c @@ -28,7 +28,7 @@ int uuencode_main(int argc, char **argv) tbl = bb_uuenc_tbl_std; mode = 0666 & ~umask(0666); opt_complementary = "-1:?2"; /* must have 1 or 2 args */ - if (getopt32(argc, argv, "m")) { + if (getopt32(argv, "m")) { tbl = bb_uuenc_tbl_base64; } argv += optind; diff --git a/coreutils/wc.c b/coreutils/wc.c index 627267d42..e86b7d4d2 100644 --- a/coreutils/wc.c +++ b/coreutils/wc.c @@ -86,7 +86,7 @@ int wc_main(int argc, char **argv) smallint in_word; unsigned print_type; - print_type = getopt32(argc, argv, "lwcL"); + print_type = getopt32(argv, "lwcL"); if (print_type == 0) { print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS); diff --git a/debianutils/mktemp.c b/debianutils/mktemp.c index 9e7ef7b4c..1c71c2e43 100644 --- a/debianutils/mktemp.c +++ b/debianutils/mktemp.c @@ -14,7 +14,7 @@ int mktemp_main(int argc, char **argv); int mktemp_main(int argc, char **argv) { - unsigned long flags = getopt32(argc, argv, "dqt"); + unsigned long flags = getopt32(argv, "dqt"); char *chp; if (optind + 1 != argc) diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c index 5066742cf..0104eb111 100644 --- a/debianutils/run_parts.c +++ b/debianutils/run_parts.c @@ -121,7 +121,7 @@ int run_parts_main(int argc, char **argv) #if ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS applet_long_options = runparts_longopts; #endif - tmp = getopt32(argc, argv, "a:u:t"USE_FEATURE_RUN_PARTS_FANCY("l"), &arg_list, &umask_p); + tmp = getopt32(argv, "a:u:t"USE_FEATURE_RUN_PARTS_FANCY("l"), &arg_list, &umask_p); G.mode = tmp &~ (RUN_PARTS_OPT_a|RUN_PARTS_OPT_u); if (tmp & RUN_PARTS_OPT_u) { /* Check and set the umask of the program executed. diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c index f24168e33..7633cb057 100644 --- a/debianutils/start_stop_daemon.c +++ b/debianutils/start_stop_daemon.c @@ -252,7 +252,7 @@ int start_stop_daemon_main(int argc, char **argv) /* Check required one context option was given */ opt_complementary = "K:S:K--S:S--K:m?p:K?xpun:S?xa"; - opt = getopt32(argc, argv, "KSbqma:n:s:u:c:x:p:" + opt = getopt32(argv, "KSbqma:n:s:u:c:x:p:" USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:"), // USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:R:"), &startas, &cmdname, &signame, &userspec, &chuid, &execname, &pidfile diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c index fbfbea2bc..dd6efc812 100644 --- a/e2fsprogs/lsattr.c +++ b/e2fsprogs/lsattr.c @@ -98,7 +98,7 @@ static void lsattr_args(const char *name) int lsattr_main(int argc, char **argv); int lsattr_main(int argc, char **argv) { - getopt32(argc, argv, "Radlv"); + getopt32(argv, "Radlv"); argv += optind; if (!*argv) diff --git a/e2fsprogs/old_e2fsprogs/lsattr.c b/e2fsprogs/old_e2fsprogs/lsattr.c index b418f6bad..920146496 100644 --- a/e2fsprogs/old_e2fsprogs/lsattr.c +++ b/e2fsprogs/old_e2fsprogs/lsattr.c @@ -117,7 +117,7 @@ int lsattr_main(int argc, char **argv) { int i; - flags = getopt32(argc, argv, "Radlv"); + flags = getopt32(argv, "Radlv"); if (optind > argc - 1) lsattr_args("."); diff --git a/editors/awk.c b/editors/awk.c index 4ec3d4652..a820c7a17 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -2817,7 +2817,7 @@ int awk_main(int argc, char **argv) } } opt_complementary = "v::"; - opt = getopt32(argc, argv, "F:v:f:W:", &opt_F, &opt_v, &g_progname, &opt_W); + opt = getopt32(argv, "F:v:f:W:", &opt_F, &opt_v, &g_progname, &opt_W); argv += optind; argc -= optind; if (opt & 0x1) diff --git a/editors/cmp.c b/editors/cmp.c index ffdfb9103..34a0de50a 100644 --- a/editors/cmp.c +++ b/editors/cmp.c @@ -61,7 +61,7 @@ int cmp_main(int argc, char **argv) USE_DESKTOP(":?4") SKIP_DESKTOP(":?2") ":l--s:s--l"; - opt = getopt32(argc, argv, opt_chars); + opt = getopt32(argv, opt_chars); argv += optind; filename1 = *argv; diff --git a/editors/diff.c b/editors/diff.c index 41808b1ac..3a694e087 100644 --- a/editors/diff.c +++ b/editors/diff.c @@ -1219,7 +1219,7 @@ int diff_main(int argc, char **argv) /* exactly 2 params; collect multiple -L