From 82d1c1f84ae23793d81b50aa0a753ad7c4db4f51 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 31 Dec 2017 17:30:02 +0100 Subject: [PATCH] randomconfig fixes Signed-off-by: Denys Vlasenko --- coreutils/cat.c | 5 ++++- coreutils/ls.c | 7 +++---- coreutils/stat.c | 7 +++++-- coreutils/uname.c | 6 ++---- libbb/Kbuild.src | 1 + libbb/lineedit.c | 3 ++- loginutils/addgroup.c | 7 ++++++- make_single_applets.sh | 3 ++- networking/tftp.c | 3 ++- procps/kill.c | 7 ++++++- scripts/randomtest.loop | 1 + shell/ash.c | 2 +- shell/hush.c | 13 ++++++++----- 13 files changed, 43 insertions(+), 22 deletions(-) diff --git a/coreutils/cat.c b/coreutils/cat.c index 7e35fa5ee..5f02233ca 100644 --- a/coreutils/cat.c +++ b/coreutils/cat.c @@ -168,9 +168,12 @@ static int catv(unsigned opts, char **argv) int cat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int cat_main(int argc UNUSED_PARAM, char **argv) { +#if ENABLE_FEATURE_CATV || ENABLE_FEATURE_CATN unsigned opts; - opts = getopt32(argv, IF_FEATURE_CATV("^") + opts = +#endif + getopt32(argv, IF_FEATURE_CATV("^") /* -u is ignored ("unbuffered") */ IF_FEATURE_CATV("etvA")IF_FEATURE_CATN("nb")"u" IF_FEATURE_CATV("\0" "Aetv" /* -A == -vet */) diff --git a/coreutils/ls.c b/coreutils/ls.c index a4e324b00..4be499088 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -482,12 +482,11 @@ static NOINLINE unsigned display_single(const struct dnode *dn) int opt; #if ENABLE_FEATURE_LS_FILETYPES || ENABLE_FEATURE_LS_COLOR struct stat statbuf; - char append; +#endif +#if ENABLE_FEATURE_LS_FILETYPES + char append = append_char(dn->dn_mode); #endif -#if ENABLE_FEATURE_LS_FILETYPES - append = append_char(dn->dn_mode); -#endif opt = option_mask32; /* Do readlink early, so that if it fails, error message diff --git a/coreutils/stat.c b/coreutils/stat.c index dafbd4e9f..7ba3db155 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c @@ -759,10 +759,13 @@ int stat_main(int argc UNUSED_PARAM, char **argv) IF_FEATURE_STAT_FORMAT(char *format = NULL;) int i; int ok; - unsigned opts; statfunc_ptr statfunc = do_stat; +#if ENABLE_FEATURE_STAT_FILESYSTEM || ENABLE_SELINUX + unsigned opts; - opts = getopt32(argv, "^" + opts = +#endif + getopt32(argv, "^" "tL" IF_FEATURE_STAT_FILESYSTEM("f") IF_SELINUX("Z") diff --git a/coreutils/uname.c b/coreutils/uname.c index 57039b1bf..765809658 100644 --- a/coreutils/uname.c +++ b/coreutils/uname.c @@ -127,11 +127,9 @@ int uname_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) { uname_info_t uname_info; IF_UNAME(const char *unknown_str = "unknown";) - unsigned toprint; - - toprint = (1 << 4); /* "arch" = "uname -m" */ - #if ENABLE_UNAME + unsigned toprint = (1 << 4); /* "arch" = "uname -m" */ + if (!ENABLE_BB_ARCH || applet_name[0] == 'u') { # if ENABLE_LONG_OPTS static const char uname_longopts[] ALIGN1 = diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index 73201a6bd..6e6d71ad5 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src @@ -124,6 +124,7 @@ lib-$(CONFIG_UNICODE_SUPPORT) += unicode.o lib-$(CONFIG_FEATURE_CHECK_NAMES) += die_if_bad_username.o lib-$(CONFIG_NC) += udp_io.o +lib-$(CONFIG_NETCAT) += udp_io.o lib-$(CONFIG_DNSD) += udp_io.o lib-$(CONFIG_NTPD) += udp_io.o lib-$(CONFIG_TFTP) += udp_io.o diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 5624a7fc3..896bbc88c 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -90,7 +90,8 @@ static bool BB_ispunct(CHAR_T c) { return ((unsigned)c < 256 && ispunct(c)); } # define CHAR_T char # define BB_isspace(c) isspace(c) # if ENABLE_FEATURE_EDITING_VI -static bool BB_isalnum_or_underscore(CHAR_T c) { +static bool BB_isalnum_or_underscore(CHAR_T c) +{ return ((unsigned)c < 256 && isalnum(c)) || c == '_'; } # endif diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c index ec11b30ca..6839eafbd 100644 --- a/loginutils/addgroup.c +++ b/loginutils/addgroup.c @@ -142,7 +142,9 @@ static const char addgroup_longopts[] ALIGN1 = int addgroup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int addgroup_main(int argc UNUSED_PARAM, char **argv) { +#if ENABLE_FEATURE_ADDUSER_TO_GROUP unsigned opts; +#endif const char *gid = "0"; /* need to be root */ @@ -154,7 +156,10 @@ int addgroup_main(int argc UNUSED_PARAM, char **argv) * addgroup --gid num group * addgroup user group * Check for min, max and missing args */ - opts = getopt32long(argv, "^" "g:S" "\0" "-1:?2", addgroup_longopts, +#if ENABLE_FEATURE_ADDUSER_TO_GROUP + opts = +#endif + getopt32long(argv, "^" "g:S" "\0" "-1:?2", addgroup_longopts, &gid ); /* move past the commandline options */ diff --git a/make_single_applets.sh b/make_single_applets.sh index 329a27d32..aa1ace265 100755 --- a/make_single_applets.sh +++ b/make_single_applets.sh @@ -12,8 +12,9 @@ makeopts="-j9" test -f include/applets.h || { echo "No include/applets.h file"; exit 1; } apps="` grep ^IF_ include/applets.h \ -| grep -v ^IF_FEATURE_ \ +| grep -v '^IF_FEATURE_' \ | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ +| grep -v '^BUSYBOX$' \ | sort | uniq `" diff --git a/networking/tftp.c b/networking/tftp.c index 73a9829aa..4cd39186a 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -208,7 +208,7 @@ struct globals { #define G_error_pkt_reason (G.error_pkt[3]) #define G_error_pkt_str ((char*)(G.error_pkt + 4)) -#if ENABLE_FEATURE_TFTP_PROGRESS_BAR +#if ENABLE_FEATURE_TFTP_PROGRESS_BAR && ENABLE_FEATURE_TFTP_BLOCKSIZE static void tftp_progress_update(void) { bb_progress_update(&G.pmt, 0, G.pos, G.size); @@ -227,6 +227,7 @@ static void tftp_progress_done(void) } } #else +# define tftp_progress_update() ((void)0) # define tftp_progress_init() ((void)0) # define tftp_progress_done() ((void)0) #endif diff --git a/procps/kill.c b/procps/kill.c index 24cc903fc..c95afb8b3 100644 --- a/procps/kill.c +++ b/procps/kill.c @@ -108,7 +108,10 @@ int kill_main(int argc UNUSED_PARAM, char **argv) { char *arg; pid_t pid; - int signo = SIGTERM, errors = 0, quiet = 0; + int signo = SIGTERM, errors = 0; +#if ENABLE_KILL || ENABLE_KILLALL + int quiet = 0; +#endif #if KILL_APPLET_CNT == 1 # define is_killall ENABLE_KILLALL @@ -170,7 +173,9 @@ int kill_main(int argc UNUSED_PARAM, char **argv) /* The -q quiet option */ if (is_killall && arg[1] == 'q' && arg[2] == '\0') { +#if ENABLE_KILL || ENABLE_KILLALL quiet = 1; +#endif arg = *++argv; if (!arg) bb_show_usage(); diff --git a/scripts/randomtest.loop b/scripts/randomtest.loop index 4d14b652f..edfbc5c58 100755 --- a/scripts/randomtest.loop +++ b/scripts/randomtest.loop @@ -66,6 +66,7 @@ while sleep 1; do continue fi fi + grep -i 'warning:' "$dir/make.log" rm -rf -- "$dir" let cnt++ done diff --git a/shell/ash.c b/shell/ash.c index e69ddb4ff..dfb7d4d8e 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -9952,7 +9952,7 @@ evalcommand(union node *cmd, int flags) switch (cmdentry.cmdtype) { default: { -#if ENABLE_FEATURE_SH_NOFORK +#if ENABLE_FEATURE_SH_NOFORK && NUM_APPLETS > 1 /* (1) BUG: if variables are set, we need to fork, or save/restore them * around run_nofork_applet() call. * (2) Should this check also be done in forkshell()? diff --git a/shell/hush.c b/shell/hush.c index 708555ac4..df1b046ab 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -2278,7 +2278,7 @@ static int unset_local_var_len(const char *name, int name_len) return EXIT_SUCCESS; } -#if ENABLE_HUSH_UNSET +#if ENABLE_HUSH_UNSET || ENABLE_HUSH_GETOPTS static int unset_local_var(const char *name) { return unset_local_var_len(name, strlen(name)); @@ -2300,7 +2300,7 @@ static void unset_vars(char **strings) free(strings); } -#if BASH_HOSTNAME_VAR || ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_READ +#if BASH_HOSTNAME_VAR || ENABLE_FEATURE_SH_MATH || ENABLE_HUSH_READ || ENABLE_HUSH_GETOPTS static void FAST_FUNC set_local_var_from_halves(const char *name, const char *val) { char *var = xasprintf("%s=%s", name, val); @@ -5534,7 +5534,7 @@ static int expand_on_ifs(int *ended_with_ifs, o_string *output, int n, const cha static char *encode_then_expand_string(const char *str, int process_bkslash, int do_unbackslash) { #if !BASH_PATTERN_SUBST - const int do_unbackslash = 1; + enum { do_unbackslash = 1 }; #endif char *exp_str; struct in_str input; @@ -8139,7 +8139,7 @@ static NOINLINE int run_pipe(struct pipe *pi) return rcode; } - if (ENABLE_FEATURE_SH_NOFORK) { + if (ENABLE_FEATURE_SH_NOFORK && NUM_APPLETS > 1) { int n = find_applet_by_name(argv_expanded[0]); if (n >= 0 && APPLET_IS_NOFORK(n)) { rcode = redirect_and_varexp_helper(&new_env, &old_vars, command, &squirrel, argv_expanded); @@ -8387,7 +8387,10 @@ static int run_list(struct pipe *pi) rword, cond_code, last_rword); sv_errexit_depth = G.errexit_depth; - if (IF_HAS_KEYWORDS(rword == RES_IF || rword == RES_ELIF ||) + if ( +#if ENABLE_HUSH_IF + rword == RES_IF || rword == RES_ELIF || +#endif pi->followup != PIPE_SEQ ) { G.errexit_depth++;