From 015db5800ca7c6dd2d201eacb2951e72e6782b30 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 19 Jun 2016 18:15:33 +0200 Subject: randomconfig fixes Signed-off-by: Denys Vlasenko --- archival/libarchive/get_header_tar.c | 23 ++++++++++++++++------- archival/tar.c | 6 ++++-- miscutils/Kbuild.src | 9 +++++++-- modutils/modprobe-small.c | 1 - scripts/kconfig/zconf.hash.c_shipped | 14 ++------------ scripts/randomtest | 20 ++++++++++++++++++++ testsuite/busybox.tests | 16 ++++++++++------ testsuite/du/du-m-works | 2 +- util-linux/fbset.c | 5 +++-- util-linux/fdisk_osf.c | 3 ++- util-linux/fdisk_sgi.c | 27 +++++++++++++++------------ 11 files changed, 80 insertions(+), 46 deletions(-) diff --git a/archival/libarchive/get_header_tar.c b/archival/libarchive/get_header_tar.c index ac2be726f..ea91a883e 100644 --- a/archival/libarchive/get_header_tar.c +++ b/archival/libarchive/get_header_tar.c @@ -60,13 +60,21 @@ static unsigned long long getOctal(char *str, int len) } #define GET_OCTAL(a) getOctal((a), sizeof(a)) +#define TAR_EXTD (ENABLE_FEATURE_TAR_GNU_EXTENSIONS || ENABLE_FEATURE_TAR_SELINUX) +#if !TAR_EXTD +#define process_pax_hdr(archive_handle, sz, global) \ + process_pax_hdr(archive_handle, sz) +#endif /* "global" is 0 or 1 */ static void process_pax_hdr(archive_handle_t *archive_handle, unsigned sz, int global) { +#if !TAR_EXTD + unsigned blk_sz = (sz + 511) & (~511); + seek_by_read(archive_handle->src_fd, blk_sz); +#else + unsigned blk_sz = (sz + 511) & (~511); char *buf, *p; - unsigned blk_sz; - blk_sz = (sz + 511) & (~511); p = buf = xmalloc(blk_sz + 1); xread(archive_handle->src_fd, buf, blk_sz); archive_handle->offset += blk_sz; @@ -104,30 +112,31 @@ static void process_pax_hdr(archive_handle_t *archive_handle, unsigned sz, int g p[-1] = '\0'; value = end + 1; -#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS +# if ENABLE_FEATURE_TAR_GNU_EXTENSIONS if (!global && is_prefixed_with(value, "path=")) { value += sizeof("path=") - 1; free(archive_handle->tar__longname); archive_handle->tar__longname = xstrdup(value); continue; } -#endif +# endif -#if ENABLE_FEATURE_TAR_SELINUX +# if ENABLE_FEATURE_TAR_SELINUX /* Scan for SELinux contexts, via "RHT.security.selinux" keyword. * This is what Red Hat's patched version of tar uses. */ -# define SELINUX_CONTEXT_KEYWORD "RHT.security.selinux" +# define SELINUX_CONTEXT_KEYWORD "RHT.security.selinux" if (is_prefixed_with(value, SELINUX_CONTEXT_KEYWORD"=")) { value += sizeof(SELINUX_CONTEXT_KEYWORD"=") - 1; free(archive_handle->tar__sctx[global]); archive_handle->tar__sctx[global] = xstrdup(value); continue; } -#endif +# endif } free(buf); +#endif } char FAST_FUNC get_header_tar(archive_handle_t *archive_handle) diff --git a/archival/tar.c b/archival/tar.c index 346a9404e..7434e22e4 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -1199,9 +1199,10 @@ int tar_main(int argc UNUSED_PARAM, char **argv) // /* We need to know whether child (gzip/bzip/etc) exits abnormally */ // signal(SIGCHLD, check_errors_in_children); +#if ENABLE_FEATURE_TAR_CREATE /* Create an archive */ if (opt & OPT_CREATE) { -#if SEAMLESS_COMPRESSION +# if SEAMLESS_COMPRESSION const char *zipMode = NULL; if (opt & OPT_COMPRESS) zipMode = "compress"; @@ -1213,7 +1214,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv) zipMode = "lzma"; if (opt & OPT_XZ) zipMode = "xz"; -#endif +# endif /* NB: writeTarFile() closes tar_handle->src_fd */ return writeTarFile(tar_handle->src_fd, verboseFlag, (opt & OPT_DEREFERENCE ? ACTION_FOLLOWLINKS : 0) @@ -1221,6 +1222,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv) tar_handle->accept, tar_handle->reject, zipMode); } +#endif if (opt & OPT_ANY_COMPRESS) { USE_FOR_MMU(IF_DESKTOP(long long) int FAST_FUNC (*xformer)(transformer_state_t *xstate);) diff --git a/miscutils/Kbuild.src b/miscutils/Kbuild.src index 7b449e6e8..503f54904 100644 --- a/miscutils/Kbuild.src +++ b/miscutils/Kbuild.src @@ -25,8 +25,13 @@ lib-$(CONFIG_FLASH_UNLOCK) += flash_lock_unlock.o lib-$(CONFIG_IONICE) += ionice.o lib-$(CONFIG_HDPARM) += hdparm.o lib-$(CONFIG_INOTIFYD) += inotifyd.o -lib-$(CONFIG_FEATURE_LAST_SMALL)+= last.o -lib-$(CONFIG_FEATURE_LAST_FANCY)+= last_fancy.o + +ifeq ($(CONFIG_FEATURE_LAST_FANCY),y) +lib-$(CONFIG_FEATURE_LAST_FANCY) += last_fancy.o +else +lib-$(CONFIG_LAST) += last.o +endif + lib-$(CONFIG_LESS) += less.o lib-$(CONFIG_MAKEDEVS) += makedevs.o lib-$(CONFIG_MAN) += man.o diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index 9c941064b..ffb46e6be 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c @@ -21,7 +21,6 @@ extern int init_module(void *module, unsigned long len, const char *options); extern int delete_module(const char *module, unsigned flags); -extern int query_module(const char *name, int which, void *buf, size_t bufsize, size_t *ret); /* linux/include/linux/module.h has limit of 64 chars on module names */ #undef MODULE_NAME_LEN #define MODULE_NAME_LEN 64 diff --git a/scripts/kconfig/zconf.hash.c_shipped b/scripts/kconfig/zconf.hash.c_shipped index d39cf189a..29d9cf6cc 100644 --- a/scripts/kconfig/zconf.hash.c_shipped +++ b/scripts/kconfig/zconf.hash.c_shipped @@ -32,14 +32,7 @@ struct kconf_id; /* maximum key range = 45, duplicates = 0 */ -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static unsigned int +unsigned int kconf_id_hash (register const char *str, register unsigned int len) { static unsigned char asso_values[] = @@ -119,7 +112,7 @@ struct kconf_id_strings_t char kconf_id_strings_str41[sizeof("choice")]; char kconf_id_strings_str46[sizeof("prompt")]; }; -static struct kconf_id_strings_t kconf_id_strings_contents = +struct kconf_id_strings_t kconf_id_strings_contents = { "if", "int", @@ -153,9 +146,6 @@ static struct kconf_id_strings_t kconf_id_strings_contents = "prompt" }; #define kconf_id_strings ((const char *) &kconf_id_strings_contents) -#ifdef __GNUC__ -__inline -#endif struct kconf_id * kconf_id_lookup (register const char *str, register unsigned int len) { diff --git a/scripts/randomtest b/scripts/randomtest index e2513d058..41f252ad7 100755 --- a/scripts/randomtest +++ b/scripts/randomtest @@ -52,9 +52,18 @@ echo '# CONFIG_RFKILL is not set' >>.config if test x"$LIBC" = x"glibc"; then cat .config \ | grep -v CONFIG_STATIC \ + \ + | grep -v CONFIG_FEATURE_2_4_MODULES \ + | grep -v CONFIG_FEATURE_USE_BSS_TAIL \ + | grep -v CONFIG_DEBUG_SANITIZE \ >.config.new mv .config.new .config echo '# CONFIG_STATIC is not set' >>.config + # newer glibc (at least 2.23) no longer supply query_module() ABI. + # People who target 2.4 kernels would likely use older glibc (and older bbox). + echo '# CONFIG_FEATURE_2_4_MODULES is not set' >>.config + echo '# CONFIG_FEATURE_USE_BSS_TAIL is not set' >>.config + echo '# CONFIG_DEBUG_SANITIZE is not set' >>.config fi # If uclibc, build static, and remove some things @@ -68,6 +77,11 @@ if test x"$LIBC" = x"uclibc"; then | grep -v CONFIG_FEATURE_2_4_MODULES \ | grep -v CONFIG_FEATURE_SYNC_FANCY \ | grep -v CONFIG_FEATURE_TOUCH_NODEREF \ + | grep -v CONFIG_NANDWRITE \ + | grep -v CONFIG_NANDDUMP \ + | grep -v CONFIG_BLKDISCARD \ + | grep -v CONFIG_NSENTER \ + | grep -v CONFIG_UNSHARE \ >.config.new mv .config.new .config echo 'CONFIG_STATIC=y' >>.config @@ -76,6 +90,12 @@ if test x"$LIBC" = x"uclibc"; then echo '# CONFIG_FEATURE_2_4_MODULES is not set' >>.config echo '# CONFIG_FEATURE_SYNC_FANCY is not set' >>.config echo '# CONFIG_FEATURE_TOUCH_NODEREF is not set' >>.config + # My uclibc installation does not support some needed APIs... + echo '# CONFIG_NANDWRITE is not set' >>.config + echo '# CONFIG_NANDDUMP is not set' >>.config + echo '# CONFIG_BLKDISCARD is not set' >>.config + echo '# CONFIG_NSENTER is not set' >>.config + echo '# CONFIG_UNSHARE is not set' >>.config fi # If STATIC, remove some things. diff --git a/testsuite/busybox.tests b/testsuite/busybox.tests index 04fea3ea2..545cad5c0 100755 --- a/testsuite/busybox.tests +++ b/testsuite/busybox.tests @@ -6,6 +6,16 @@ . ./testing.sh +ln -s `which busybox` unknown + +testing "busybox as unknown name" "./unknown 2>&1" \ + "unknown: applet not found\n" "" "" +rm unknown + +# We need busybox --help to be enabled for the rest of tests +test x"$CONFIG_BUSYBOX" = x"y" \ +|| { echo "SKIPPED: busybox --help"; exit 0; } + HELPDUMP=`true | busybox 2>&1 | cat` # We need to test under calling the binary under other names. @@ -38,10 +48,4 @@ do done rm busybox-suffix -ln -s `which busybox` unknown - -testing "busybox as unknown name" "./unknown 2>&1" \ - "unknown: applet not found\n" "" "" -rm unknown - exit $FAILCOUNT diff --git a/testsuite/du/du-m-works b/testsuite/du/du-m-works index 9fa7437ac..c96c3b359 100644 --- a/testsuite/du/du-m-works +++ b/testsuite/du/du-m-works @@ -1,4 +1,4 @@ # FEATURE: CONFIG_FEATURE_HUMAN_READABLE dd if=/dev/zero of=file bs=1M count=1 2>/dev/null -test x"`busybox du -m .`" = x"1 ." +test x"`busybox du -m file`" = x"1 ." diff --git a/util-linux/fbset.c b/util-linux/fbset.c index 09e96b763..b75ec1921 100644 --- a/util-linux/fbset.c +++ b/util-linux/fbset.c @@ -164,6 +164,7 @@ static const struct cmdoptions_t { const unsigned char code; } g_cmdoptions[] = { /*"12345678" + NUL */ +//TODO: convert to index_in_strings() { "fb" , 1, CMD_FB }, { "db" , 1, CMD_DB }, { "a" , 0, CMD_ALL }, @@ -416,7 +417,7 @@ int fbset_main(int argc, char **argv) unsigned options = 0; const char *fbdev = DEFAULTFBDEV; - const char *modefile = DEFAULTFBMODE; + IF_FEATURE_FBSET_READMODE(const char *modefile = DEFAULTFBMODE;) char *thisarg; char *mode = mode; /* for compiler */ @@ -444,7 +445,7 @@ int fbset_main(int argc, char **argv) fbdev = argv[1]; break; case CMD_DB: - modefile = argv[1]; + IF_FEATURE_FBSET_READMODE(modefile = argv[1];) break; case CMD_ALL: options |= OPT_ALL; diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c index af04cfcc8..89f1f323c 100644 --- a/util-linux/fdisk_osf.c +++ b/util-linux/fdisk_osf.c @@ -366,10 +366,11 @@ bsd_select(void) } printf("Reading disklabel of %s at sector %u\n", partname(disk_device, t+1, 0), ss + BSD_LABELSECTOR); - if (xbsd_readlabel(xbsd_part) == 0) + if (xbsd_readlabel(xbsd_part) == 0) { if (xbsd_create_disklabel() == 0) return; break; + } } } diff --git a/util-linux/fdisk_sgi.c b/util-linux/fdisk_sgi.c index 23ebc56ef..30def09c6 100644 --- a/util-linux/fdisk_sgi.c +++ b/util-linux/fdisk_sgi.c @@ -504,17 +504,19 @@ verify_sgi(int verbose) if (sgi_get_sysid(Index[0]) == SGI_ENTIRE_DISK) { if ((Index[0] != 10) && verbose) printf("IRIX likes when Partition 11 covers the entire disk\n"); - if ((sgi_get_start_sector(Index[0]) != 0) && verbose) + if ((sgi_get_start_sector(Index[0]) != 0) && verbose) { printf("The entire disk partition should start " "at block 0,\n" "not at diskblock %u\n", sgi_get_start_sector(Index[0])); - if (SGI_DEBUG) /* I do not understand how some disks fulfil it */ + } + if (SGI_DEBUG) { /* I do not understand how some disks fulfil it */ if ((sgi_get_num_sectors(Index[0]) != lastblock) && verbose) printf("The entire disk partition is only %u diskblock large,\n" "but the disk is %u diskblocks long\n", sgi_get_num_sectors(Index[0]), lastblock); lastblock = sgi_get_num_sectors(Index[0]); + } } else { if (verbose) printf("One Partition (#11) should cover the entire disk\n"); @@ -669,16 +671,17 @@ sgi_set_volhdr(void) int n; for (n = 8; n < g_partitions; n++) { - if (!sgi_get_num_sectors(n)) { - /* - * 5 cylinders is an arbitrary value I like - * IRIX 5.3 stored files in the volume header - * (like sash, symmon, fx, ide) with ca. 3200 - * sectors. - */ - if (g_heads * g_sectors * 5 < sgi_get_lastblock()) - sgi_set_partition(n, 0, g_heads * g_sectors * 5, SGI_VOLHDR); - break; + if (!sgi_get_num_sectors(n)) { + /* + * 5 cylinders is an arbitrary value I like + * IRIX 5.3 stored files in the volume header + * (like sash, symmon, fx, ide) with ca. 3200 + * sectors. + */ + if (g_heads * g_sectors * 5 < sgi_get_lastblock()) { + sgi_set_partition(n, 0, g_heads * g_sectors * 5, SGI_VOLHDR); + break; + } } } } -- cgit v1.2.3