From ec16c030bd5527137f95a1c30e6a1f3c9054dcf7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 29 Nov 2020 11:37:34 +0100 Subject: libbb: introduce and use sleep1() function old new delta sleep1 - 9 +9 run_shutdown_and_kill_processes 97 95 -2 restore_state_and_exit 116 114 -2 reread_partition_table 67 65 -2 flush_buffer_cache 80 78 -2 chat_main 1302 1300 -2 timeout_main 310 307 -3 telnet_main 1235 1232 -3 stop_handler 86 83 -3 process_action 1078 1075 -3 nbdclient_main 1185 1182 -3 init_main 789 786 -3 getty_main 1541 1538 -3 do_time 410 407 -3 runsv_main 1682 1677 -5 pause_and_low_level_reboot 59 54 -5 inetd_main 1917 1911 -6 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/16 up/down: 9/-50) Total: -41 bytes Signed-off-by: Denys Vlasenko --- runit/runsv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runit') diff --git a/runit/runsv.c b/runit/runsv.c index 36d85101e..7e22862cd 100644 --- a/runit/runsv.c +++ b/runit/runsv.c @@ -651,7 +651,7 @@ int runsv_main(int argc UNUSED_PARAM, char **argv) gettimeofday_ns(&svd[0].start); update_status(&svd[0]); if (LESS(svd[0].start.tv_sec, deadline)) - sleep(1); + sleep1(); } if (haslog) { if (child == svd[1].pid) { @@ -664,7 +664,7 @@ int runsv_main(int argc UNUSED_PARAM, char **argv) gettimeofday_ns(&svd[1].start); update_status(&svd[1]); if (LESS(svd[1].start.tv_sec, deadline)) - sleep(1); + sleep1(); } } } /* for (;;) */ -- cgit v1.2.3-55-g6feb From 965b795b87c59ed45cc7f16a62301dbae65b1627 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 30 Nov 2020 13:03:03 +0100 Subject: decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nilly text data bss dec hex filename 1021988 559 5052 1027599 fae0f busybox_old 1021236 559 5052 1026847 fab1f busybox_unstripped Signed-off-by: Denys Vlasenko --- archival/dpkg.c | 2 +- archival/libarchive/bz/blocksort.c | 2 +- archival/libarchive/data_extract_to_command.c | 2 +- coreutils/od_bloaty.c | 4 ++-- coreutils/split.c | 2 +- coreutils/stat.c | 2 +- coreutils/stty.c | 4 ++-- coreutils/test.c | 2 +- e2fsprogs/e2fs_lib.c | 2 +- editors/awk.c | 2 +- findutils/find.c | 2 +- include/libbb.h | 3 ++- include/platform.h | 2 ++ libbb/capability.c | 2 +- libbb/duration.c | 2 +- libbb/hash_md5_sha.c | 22 +++++++++++----------- libbb/mode_string.c | 2 +- libbb/pw_encrypt_des.c | 15 +++++++-------- libbb/speed_table.c | 2 +- libbb/xatonum.c | 6 +++--- miscutils/crond.c | 2 +- miscutils/dc.c | 2 +- miscutils/hdparm.c | 2 +- miscutils/i2c_tools.c | 15 +++++---------- miscutils/mt.c | 2 +- miscutils/setserial.c | 3 +-- miscutils/ubi_tools.c | 2 +- miscutils/watchdog.c | 2 +- modutils/modinfo.c | 2 +- networking/ifplugd.c | 2 +- networking/interface.c | 2 +- networking/ip.c | 2 +- networking/libiproute/rt_names.c | 2 +- networking/route.c | 6 +++--- networking/tls.c | 2 +- networking/udhcp/dhcpd.c | 2 +- procps/nmeter.c | 2 +- procps/ps.c | 2 +- runit/svlogd.c | 2 +- shell/ash.c | 6 +++--- shell/hush.c | 12 ++++++------ shell/shell_common.c | 2 +- util-linux/acpid.c | 4 ++-- util-linux/fbset.c | 2 +- util-linux/fdisk.c | 2 +- util-linux/fdisk_osf.c | 4 ++-- util-linux/fdisk_sgi.c | 2 +- util-linux/fdisk_sun.c | 4 ++-- util-linux/mkfs_ext2.c | 2 +- util-linux/mount.c | 2 +- util-linux/volume_id/volume_id.c | 8 ++++---- 51 files changed, 92 insertions(+), 96 deletions(-) (limited to 'runit') diff --git a/archival/dpkg.c b/archival/dpkg.c index 68a40bf6e..bf070a001 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c @@ -1304,7 +1304,7 @@ postrm abort-install postrm abort-upgrade postrm disappear */ -static const char *const all_control_files[] = { +static const char *const all_control_files[] ALIGN_PTR = { "preinst", "postinst", "prerm", "postrm", "list", "md5sums", "shlibs", "conffiles", "config", "templates" diff --git a/archival/libarchive/bz/blocksort.c b/archival/libarchive/bz/blocksort.c index 92d6d8251..062fd0f54 100644 --- a/archival/libarchive/bz/blocksort.c +++ b/archival/libarchive/bz/blocksort.c @@ -459,7 +459,7 @@ int mainGtU(EState* state, * usually small, typically <= 20. */ static -const uint32_t incs[14] = { +const uint32_t incs[14] ALIGN4 = { 1, 4, 13, 40, 121, 364, 1093, 3280, 9841, 29524, 88573, 265720, 797161, 2391484 diff --git a/archival/libarchive/data_extract_to_command.c b/archival/libarchive/data_extract_to_command.c index 0fcabb4a9..f8b2ff8d2 100644 --- a/archival/libarchive/data_extract_to_command.c +++ b/archival/libarchive/data_extract_to_command.c @@ -20,7 +20,7 @@ enum { TAR_MAX, }; -static const char *const tar_var[] = { +static const char *const tar_var[] ALIGN_PTR = { // "FILETYPE", "MODE", "FILENAME", diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c index e9c071f3a..d5bd7bfe8 100644 --- a/coreutils/od_bloaty.c +++ b/coreutils/od_bloaty.c @@ -627,7 +627,7 @@ decode_one_format(const char *s_orig, const char *s, struct tspec *tspec) bytes_to_unsigned_dec_digits, bytes_to_hex_digits, }; - static const char doux_fmtstring[][sizeof(" %%0%u%s")] = { + static const char doux_fmtstring[][sizeof(" %%0%u%s")] ALIGN1 = { " %%%u%s", " %%0%u%s", " %%%u%s", @@ -1148,7 +1148,7 @@ dump_strings(off_t address, off_t end_offset) static int parse_old_offset(const char *s, off_t *offset) { - static const struct suffix_mult Bb[] = { + static const struct suffix_mult Bb[] ALIGN_SUFFIX = { { "B", 1024 }, { "b", 512 }, { "", 0 } diff --git a/coreutils/split.c b/coreutils/split.c index ecbc9d2d8..3fcfd95f2 100644 --- a/coreutils/split.c +++ b/coreutils/split.c @@ -44,7 +44,7 @@ #include "common_bufsiz.h" #if ENABLE_FEATURE_SPLIT_FANCY -static const struct suffix_mult split_suffixes[] = { +static const struct suffix_mult split_suffixes[] ALIGN_SUFFIX = { { "b", 512 }, { "k", 1024 }, { "m", 1024*1024 }, diff --git a/coreutils/stat.c b/coreutils/stat.c index 8a23d687b..ee5e03edd 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c @@ -208,7 +208,7 @@ FS_TYPE(0x62656572, "sysfs") static const char *human_fstype(uint32_t f_type) { # define FS_TYPE(type, name) type, - static const uint32_t fstype[] = { + static const uint32_t fstype[] ALIGN4 = { FS_TYPE_LIST }; # undef FS_TYPE diff --git a/coreutils/stty.c b/coreutils/stty.c index 40e812799..19253964c 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c @@ -487,7 +487,7 @@ static const char mode_name[] ALIGN1 = #undef MI_ENTRY #define MI_ENTRY(N,T,F,B,M) { T, F, M, B }, -static const struct mode_info mode_info[] = { +static const struct mode_info mode_info[] ALIGN4 = { /* This should be verbatim cut-n-paste copy of the above MI_ENTRYs */ MI_ENTRY("evenp", combination, REV | OMIT, 0, 0 ) MI_ENTRY("parity", combination, REV | OMIT, 0, 0 ) @@ -905,7 +905,7 @@ static void display_window_size(int fancy) } } -static const struct suffix_mult stty_suffixes[] = { +static const struct suffix_mult stty_suffixes[] ALIGN_SUFFIX = { { "b", 512 }, { "k", 1024 }, { "B", 1024 }, diff --git a/coreutils/test.c b/coreutils/test.c index ac7b546a3..7c6574334 100644 --- a/coreutils/test.c +++ b/coreutils/test.c @@ -306,7 +306,7 @@ struct operator_t { unsigned char op_num, op_type; }; -static const struct operator_t ops_table[] = { +static const struct operator_t ops_table[] ALIGN2 = { { /* "-r" */ FILRD , UNOP }, { /* "-w" */ FILWR , UNOP }, { /* "-x" */ FILEX , UNOP }, diff --git a/e2fsprogs/e2fs_lib.c b/e2fsprogs/e2fs_lib.c index 6ce655be3..8bd4da622 100644 --- a/e2fsprogs/e2fs_lib.c +++ b/e2fsprogs/e2fs_lib.c @@ -127,7 +127,7 @@ int fgetsetflags(const char *name, unsigned long *get_flags, unsigned long set_f /* Print file attributes on an ext2 file system */ -const uint32_t e2attr_flags_value[] = { +const uint32_t e2attr_flags_value[] ALIGN4 = { #ifdef ENABLE_COMPRESSION EXT2_COMPRBLK_FL, EXT2_DIRTY_FL, diff --git a/editors/awk.c b/editors/awk.c index 59dae4770..d56d6330d 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -405,7 +405,7 @@ static const char tokenlist[] ALIGN1 = #define OC_B OC_BUILTIN -static const uint32_t tokeninfo[] = { +static const uint32_t tokeninfo[] ALIGN4 = { 0, 0, OC_REGEXP, diff --git a/findutils/find.c b/findutils/find.c index e2947afb4..a8c3fa346 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -1441,7 +1441,7 @@ static action*** parse_params(char **argv) #else #define XATOU_SFX xatoul_sfx #endif - static const struct suffix_mult find_suffixes[] = { + static const struct suffix_mult find_suffixes[] ALIGN_SUFFIX = { { "c", 1 }, { "w", 2 }, { "", 512 }, diff --git a/include/libbb.h b/include/libbb.h index 18dc9f935..9872dc1fb 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1026,8 +1026,9 @@ void generate_uuid(uint8_t *buf) FAST_FUNC; /* Last element is marked by mult == 0 */ struct suffix_mult { char suffix[4]; - unsigned mult; + uint32_t mult; }; +#define ALIGN_SUFFIX ALIGN4 extern const struct suffix_mult bkm_suffixes[]; #define km_suffixes (bkm_suffixes + 1) extern const struct suffix_mult cwbkMG_suffixes[]; diff --git a/include/platform.h b/include/platform.h index 43bb391bd..085387fd8 100644 --- a/include/platform.h +++ b/include/platform.h @@ -342,6 +342,8 @@ typedef unsigned smalluint; # define ALIGN2 # define ALIGN4 #endif +#define ALIGN8 __attribute__((aligned(8))) +#define ALIGN_PTR __attribute__((aligned(sizeof(void*)))) /* * For 0.9.29 and svn, __ARCH_USE_MMU__ indicates no-mmu reliably. diff --git a/libbb/capability.c b/libbb/capability.c index 23afd8eb9..e3c252a5a 100644 --- a/libbb/capability.c +++ b/libbb/capability.c @@ -17,7 +17,7 @@ extern int capget(cap_user_header_t header, const cap_user_data_t data); // This way, libcap needs not be installed in build environment. #include "libbb.h" -static const char *const capabilities[] = { +static const char *const capabilities[] ALIGN_PTR = { "chown", "dac_override", "dac_read_search", diff --git a/libbb/duration.c b/libbb/duration.c index 22b209f4d..086da15fb 100644 --- a/libbb/duration.c +++ b/libbb/duration.c @@ -21,7 +21,7 @@ #include "libbb.h" -static const struct suffix_mult duration_suffixes[] = { +static const struct suffix_mult duration_suffixes[] ALIGN_SUFFIX = { { "s", 1 }, { "m", 60 }, { "h", 60*60 }, diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c index d8f210173..e0db8ce67 100644 --- a/libbb/hash_md5_sha.c +++ b/libbb/hash_md5_sha.c @@ -111,7 +111,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) They are defined in RFC 1321 as T[i] = (int)(2^32 * fabs(sin(i))), i=1..64 */ - static const uint32_t C_array[] = { + static const uint32_t C_array[] ALIGN4 = { /* round 1 */ 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, @@ -492,7 +492,7 @@ unsigned FAST_FUNC md5_end(md5_ctx_t *ctx, void *resbuf) static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx) { - static const uint32_t rconsts[] = { + static const uint32_t rconsts[] ALIGN4 = { 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 }; int i, j; @@ -567,7 +567,7 @@ typedef uint64_t sha_K_int; typedef uint32_t sha_K_int; # define K(v) (uint32_t)(v >> 32) #endif -static const sha_K_int sha_K[] = { +static const sha_K_int sha_K[] ALIGN8 = { K(0x428a2f98d728ae22ULL), K(0x7137449123ef65cdULL), K(0xb5c0fbcfec4d3b2fULL), K(0xe9b5dba58189dbbcULL), K(0x3956c25bf348b538ULL), K(0x59f111f1b605d019ULL), @@ -760,7 +760,7 @@ void FAST_FUNC sha1_begin(sha1_ctx_t *ctx) ctx->process_block = sha1_process_block64; } -static const uint32_t init256[] = { +static const uint32_t init256[] ALIGN4 = { 0, 0, 0x6a09e667, @@ -773,7 +773,7 @@ static const uint32_t init256[] = { 0x5be0cd19, }; #if NEED_SHA512 -static const uint32_t init512_lo[] = { +static const uint32_t init512_lo[] ALIGN4 = { 0, 0, 0xf3bcc908, @@ -1009,7 +1009,7 @@ static void sha3_process_block72(uint64_t *state) #if OPTIMIZE_SHA3_FOR_32 /* - static const uint32_t IOTA_CONST_0[NROUNDS] = { + static const uint32_t IOTA_CONST_0[NROUNDS] ALIGN4 = { 0x00000001UL, 0x00000000UL, 0x00000000UL, @@ -1038,7 +1038,7 @@ static void sha3_process_block72(uint64_t *state) ** bits are in lsb: 0101 0000 1111 0100 1111 0001 */ uint32_t IOTA_CONST_0bits = (uint32_t)(0x0050f4f1); - static const uint32_t IOTA_CONST_1[NROUNDS] = { + static const uint32_t IOTA_CONST_1[NROUNDS] ALIGN4 = { 0x00000000UL, 0x00000089UL, 0x8000008bUL, @@ -1174,7 +1174,7 @@ static void sha3_process_block72(uint64_t *state) combine_halves(state); #else /* Native 64-bit algorithm */ - static const uint16_t IOTA_CONST[NROUNDS] = { + static const uint16_t IOTA_CONST[NROUNDS] ALIGN2 = { /* Elements should be 64-bit, but top half is always zero * or 0x80000000. We encode 63rd bits in a separate word below. * Same is true for 31th bits, which lets us use 16-bit table @@ -1210,15 +1210,15 @@ static void sha3_process_block72(uint64_t *state) /* bit for CONST[0] is in msb: 0001 0110 0011 1000 0001 1011 */ const uint32_t IOTA_CONST_bit31 = (uint32_t)(0x16381b00); - static const uint8_t ROT_CONST[24] = { + static const uint8_t ROT_CONST[24] ALIGN1 = { 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14, 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44, }; - static const uint8_t PI_LANE[24] = { + static const uint8_t PI_LANE[24] ALIGN1 = { 10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4, 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1, }; - /*static const uint8_t MOD5[10] = { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, };*/ + /*static const uint8_t MOD5[10] ALIGN1 = { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, };*/ unsigned x; unsigned round; diff --git a/libbb/mode_string.c b/libbb/mode_string.c index 5ffd5683e..9a286f3ff 100644 --- a/libbb/mode_string.c +++ b/libbb/mode_string.c @@ -27,7 +27,7 @@ #define mode_t unsigned short #endif -static const mode_t mode_flags[] = { +static const mode_t mode_flags[] ALIGN4 = { S_IRUSR, S_IWUSR, S_IXUSR, S_ISUID, S_IRGRP, S_IWGRP, S_IXGRP, S_ISGID, S_IROTH, S_IWOTH, S_IXOTH, S_ISVTX diff --git a/libbb/pw_encrypt_des.c b/libbb/pw_encrypt_des.c index 19a9ab15b..c6fc328d8 100644 --- a/libbb/pw_encrypt_des.c +++ b/libbb/pw_encrypt_des.c @@ -65,25 +65,25 @@ /* A pile of data */ -static const uint8_t IP[64] = { +static const uint8_t IP[64] ALIGN1 = { 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7 }; -static const uint8_t key_perm[56] = { +static const uint8_t key_perm[56] ALIGN1 = { 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4 }; -static const uint8_t key_shifts[16] = { +static const uint8_t key_shifts[16] ALIGN1 = { 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 }; -static const uint8_t comp_perm[48] = { +static const uint8_t comp_perm[48] ALIGN1 = { 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, @@ -181,13 +181,12 @@ static const uint8_t u_sbox[8][32] = { }; #endif -static const uint8_t pbox[32] = { +static const uint8_t pbox[32] ALIGN1 = { 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 }; -static const uint32_t bits32[32] = -{ +static const uint32_t bits32[32] ALIGN4 = { 0x80000000, 0x40000000, 0x20000000, 0x10000000, 0x08000000, 0x04000000, 0x02000000, 0x01000000, 0x00800000, 0x00400000, 0x00200000, 0x00100000, @@ -198,7 +197,7 @@ static const uint32_t bits32[32] = 0x00000008, 0x00000004, 0x00000002, 0x00000001 }; -static const uint8_t bits8[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; +static const uint8_t bits8[8] ALIGN1 = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; static int diff --git a/libbb/speed_table.c b/libbb/speed_table.c index 967cf8de8..cf7101e64 100644 --- a/libbb/speed_table.c +++ b/libbb/speed_table.c @@ -28,7 +28,7 @@ struct speed_map { }; /* On Linux, Bxx constants are 0..15 (up to B38400) and 0x1001..0x100f */ -static const struct speed_map speeds[] = { +static const struct speed_map speeds[] ALIGN4 = { {B0, 0}, {B50, 50}, {B75, 75}, diff --git a/libbb/xatonum.c b/libbb/xatonum.c index 7639a62aa..36b06c849 100644 --- a/libbb/xatonum.c +++ b/libbb/xatonum.c @@ -68,14 +68,14 @@ uint16_t FAST_FUNC xatou16(const char *numstr) return xatou_range(numstr, 0, 0xffff); } -const struct suffix_mult bkm_suffixes[] = { +const struct suffix_mult bkm_suffixes[] ALIGN_SUFFIX = { { "b", 512 }, { "k", 1024 }, { "m", 1024*1024 }, { "", 0 } }; -const struct suffix_mult cwbkMG_suffixes[] = { +const struct suffix_mult cwbkMG_suffixes[] ALIGN_SUFFIX = { { "c", 1 }, { "w", 2 }, { "b", 512 }, @@ -96,7 +96,7 @@ const struct suffix_mult cwbkMG_suffixes[] = { { "", 0 } }; -const struct suffix_mult kmg_i_suffixes[] = { +const struct suffix_mult kmg_i_suffixes[] ALIGN_SUFFIX = { { "KiB", 1024 }, { "kiB", 1024 }, { "K", 1024 }, diff --git a/miscutils/crond.c b/miscutils/crond.c index 2e8ca8b68..fb3adc180 100644 --- a/miscutils/crond.c +++ b/miscutils/crond.c @@ -492,7 +492,7 @@ static void load_crontab(const char *fileName) const char *name; const char tokens[8]; } SpecialEntry; - static const SpecialEntry SpecAry[] = { + static const SpecialEntry SpecAry[] ALIGN8 = { /* hour day month weekday */ { "yearly", "0\0" "1\0" "1\0" "*" }, { "annually", "0\0" "1\0" "1\0" "*" }, diff --git a/miscutils/dc.c b/miscutils/dc.c index ef93c20ba..51376dd75 100644 --- a/miscutils/dc.c +++ b/miscutils/dc.c @@ -195,7 +195,7 @@ struct op { void (*function) (void); }; -static const struct op operators[] = { +static const struct op operators[] ALIGN_PTR = { #if ENABLE_FEATURE_DC_LIBM {"^", power}, // {"exp", power}, diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 431a0ad96..01b4e8e2e 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c @@ -1366,7 +1366,7 @@ static NOINLINE void dump_identity(const struct hd_driveid *id) } if (id->capability & 1) { if (id->dma_1word | id->dma_mword) { - static const int dma_wmode_masks[] = { 0x100, 1, 0x200, 2, 0x400, 4, 0xf800, 0xf8 }; + static const int dma_wmode_masks[] ALIGN4 = { 0x100, 1, 0x200, 2, 0x400, 4, 0xf800, 0xf8 }; printf("\n DMA modes: "); print_flags_separated(dma_wmode_masks, "*\0""sdma0 \0""*\0""sdma1 \0""*\0""sdma2 \0""*\0""sdma? \0", diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index cc8b99a92..09364e396 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c @@ -1053,18 +1053,13 @@ struct adap_desc { }; static const struct adap_desc adap_descs[] = { - { .funcs = "dummy", - .algo = "Dummy bus", }, - { .funcs = "isa", - .algo = "ISA bus", }, - { .funcs = "i2c", - .algo = "I2C adapter", }, - { .funcs = "smbus", - .algo = "SMBus adapter", }, + { .funcs = "dummy", .algo = "Dummy bus", }, + { .funcs = "isa", .algo = "ISA bus", }, + { .funcs = "i2c", .algo = "I2C adapter", }, + { .funcs = "smbus", .algo = "SMBus adapter", }, }; -struct i2c_func -{ +struct i2c_func { long value; const char* name; }; diff --git a/miscutils/mt.c b/miscutils/mt.c index 9f1aecfca..dbb8c13ad 100644 --- a/miscutils/mt.c +++ b/miscutils/mt.c @@ -30,7 +30,7 @@ #include /* missing: eod/seod, stoptions, stwrthreshold, densities */ -static const short opcode_value[] = { +static const short opcode_value[] ALIGN2 = { MTBSF, MTBSFM, MTBSR, diff --git a/miscutils/setserial.c b/miscutils/setserial.c index 1e75bf433..2006861e2 100644 --- a/miscutils/setserial.c +++ b/miscutils/setserial.c @@ -381,8 +381,7 @@ static bool cmd_needs_arg(int cmd) # error "Unexpected flags size" #endif -static const uint16_t setbits[CMD_FLAG_LAST + 1] = -{ +static const uint16_t setbits[CMD_FLAG_LAST + 1] ALIGN2 = { 0, ASYNC_SPD_HI, ASYNC_SPD_VHI, diff --git a/miscutils/ubi_tools.c b/miscutils/ubi_tools.c index 94a637eee..69ead7a13 100644 --- a/miscutils/ubi_tools.c +++ b/miscutils/ubi_tools.c @@ -97,7 +97,7 @@ static unsigned get_num_from_file(const char *path, unsigned max) int ubi_tools_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int ubi_tools_main(int argc UNUSED_PARAM, char **argv) { - static const struct suffix_mult size_suffixes[] = { + static const struct suffix_mult size_suffixes[] ALIGN_SUFFIX = { { "KiB", 1024 }, { "MiB", 1024*1024 }, { "GiB", 1024*1024*1024 }, diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c index 971b777a3..0ed10bcf1 100644 --- a/miscutils/watchdog.c +++ b/miscutils/watchdog.c @@ -88,7 +88,7 @@ int watchdog_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int watchdog_main(int argc UNUSED_PARAM, char **argv) { static const int enable = WDIOS_ENABLECARD; - static const struct suffix_mult suffixes[] = { + static const struct suffix_mult suffixes[] ALIGN_SUFFIX = { { "ms", 1 }, { "", 1000 }, { "", 0 } diff --git a/modutils/modinfo.c b/modutils/modinfo.c index c5cdc7980..d15772f0d 100644 --- a/modutils/modinfo.c +++ b/modutils/modinfo.c @@ -20,7 +20,7 @@ #include "libbb.h" #include "modutils.h" -static const char *const shortcuts[] = { +static const char *const shortcuts[] ALIGN_PTR = { "filename", // -n "author", // -a "description", // -d diff --git a/networking/ifplugd.c b/networking/ifplugd.c index 60916eae6..18dcaff96 100644 --- a/networking/ifplugd.c +++ b/networking/ifplugd.c @@ -304,7 +304,7 @@ static const char api_modes[] ALIGN1 = "empwia"; static const struct { const char *name; smallint (*func)(void); -} method_table[] = { +} method_table[] ALIGN_PTR = { { "SIOCETHTOOL" , &detect_link_ethtool }, { "SIOCGMIIPHY" , &detect_link_mii }, { "SIOCDEVPRIVATE" , &detect_link_priv }, diff --git a/networking/interface.c b/networking/interface.c index e5e55d8d4..ea6a2c8a8 100644 --- a/networking/interface.c +++ b/networking/interface.c @@ -746,7 +746,7 @@ static const struct hwtype *const hwtypes[] = { }; #ifdef IFF_PORTSEL -static const char *const if_port_text[] = { +static const char *const if_port_text[] ALIGN_PTR = { /* Keep in step with */ "unknown", "10base2", diff --git a/networking/ip.c b/networking/ip.c index 33bea5f49..85b1ba080 100644 --- a/networking/ip.c +++ b/networking/ip.c @@ -400,7 +400,7 @@ int ip_main(int argc UNUSED_PARAM, char **argv) IF_FEATURE_IP_RULE("rule\0") IF_FEATURE_IP_NEIGH("neigh\0") ; - static const ip_func_ptr_t ip_func_ptrs[] = { + static const ip_func_ptr_t ip_func_ptrs[] ALIGN_PTR = { ip_print_help, IF_FEATURE_IP_ADDRESS(do_ipaddr,) IF_FEATURE_IP_ROUTE(do_iproute,) diff --git a/networking/libiproute/rt_names.c b/networking/libiproute/rt_names.c index 51f2e9bdb..3c2fad912 100644 --- a/networking/libiproute/rt_names.c +++ b/networking/libiproute/rt_names.c @@ -77,7 +77,7 @@ static rtnl_tab_t *rtnl_rtprot_tab; static void rtnl_rtprot_initialize(void) { - static const char *const init_tab[] = { + static const char *const init_tab[] ALIGN_PTR = { "none", "redirect", "kernel", diff --git a/networking/route.c b/networking/route.c index 4d9aad6cc..4901109f1 100644 --- a/networking/route.c +++ b/networking/route.c @@ -460,9 +460,9 @@ static NOINLINE void INET6_setroute(int action, char **args) #endif static const -IF_NOT_FEATURE_IPV6(uint16_t) -IF_FEATURE_IPV6(unsigned) -flagvals[] = { /* Must agree with flagchars[]. */ +IF_NOT_FEATURE_IPV6(uint16_t flagvals[] ALIGN2 = ) +IF_FEATURE_IPV6(uint32_t flagvals[] ALIGN4 = ) +{ /* Must agree with flagchars[]. */ RTF_UP, RTF_GATEWAY, RTF_HOST, diff --git a/networking/tls.c b/networking/tls.c index 341225207..e34acd69f 100644 --- a/networking/tls.c +++ b/networking/tls.c @@ -1953,7 +1953,7 @@ static void send_client_key_exchange(tls_state_t *tls) premaster_size = sizeof(rsa_premaster); } else { /* ECDHE */ - static const uint8_t basepoint9[CURVE25519_KEYSIZE] = {9}; + static const uint8_t basepoint9[CURVE25519_KEYSIZE] ALIGN1 = {9}; uint8_t privkey[CURVE25519_KEYSIZE]; //[32] if (!(tls->flags & GOT_EC_KEY)) diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index acfdaa8c3..de16cf955 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c @@ -398,7 +398,7 @@ struct config_keyword { #define OFS(field) offsetof(struct server_data_t, field) -static const struct config_keyword keywords[] = { +static const struct config_keyword keywords[] ALIGN_PTR = { /* keyword handler variable address default */ {"start" , udhcp_str2nip , OFS(start_ip ), "192.168.0.20"}, {"end" , udhcp_str2nip , OFS(end_ip ), "192.168.0.254"}, diff --git a/procps/nmeter.c b/procps/nmeter.c index 856ce0202..07b7abe2f 100644 --- a/procps/nmeter.c +++ b/procps/nmeter.c @@ -838,7 +838,7 @@ static void FAST_FUNC collect_info(s_stat *s) typedef s_stat* init_func(const char *param); static const char options[] ALIGN1 = "ncmsfixptTbr"; -static init_func *const init_functions[] = { +static init_func *const init_functions[] ALIGN_PTR = { init_if, init_cpu, init_mem, diff --git a/procps/ps.c b/procps/ps.c index 48f96209f..711b180a0 100644 --- a/procps/ps.c +++ b/procps/ps.c @@ -375,7 +375,7 @@ static void func_pcpu(char *buf, int size, const procps_status_t *ps) } */ -static const ps_out_t out_spec[] = { +static const ps_out_t out_spec[] ALIGN_PTR = { /* Mandated by http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html: */ { 8 , "user" ,"USER" ,func_user ,PSSCAN_UIDGID }, { 8 , "group" ,"GROUP" ,func_group ,PSSCAN_UIDGID }, diff --git a/runit/svlogd.c b/runit/svlogd.c index a250058a1..040e71104 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c @@ -775,7 +775,7 @@ static NOINLINE unsigned logdir_open(struct logdir *ld, const char *fn) ld->nmin = xatoi_positive(&s[1]); break; case 't': { - static const struct suffix_mult mh_suffixes[] = { + static const struct suffix_mult mh_suffixes[] ALIGN_SUFFIX = { { "m", 60 }, { "h", 60*60 }, /*{ "d", 24*60*60 },*/ diff --git a/shell/ash.c b/shell/ash.c index 8c9a590d1..40695dee0 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -2091,7 +2091,7 @@ static const struct { int flags; const char *var_text; void (*var_func)(const char *) FAST_FUNC; -} varinit_data[] = { +} varinit_data[] ALIGN_PTR = { /* * Note: VEXPORT would not work correctly here for NOFORK applets: * some environment strings may be constant. @@ -4811,7 +4811,7 @@ static char *cmdnextc; static void cmdputs(const char *s) { - static const char vstype[VSTYPE + 1][3] = { + static const char vstype[VSTYPE + 1][3] ALIGN1 = { "", "}", "-", "+", "?", "=", "%", "%%", "#", "##" IF_BASH_SUBSTR(, ":") @@ -8510,7 +8510,7 @@ enum { , /* thus far 29 bits used */ }; -static const char *const tokname_array[] = { +static const char *const tokname_array[] ALIGN_PTR = { "end of file", "newline", "redirection", diff --git a/shell/hush.c b/shell/hush.c index f1a7e07ee..b6d9d7abb 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -596,10 +596,10 @@ typedef struct in_str { /* The descrip member of this structure is only used to make * debugging output pretty */ static const struct { - int mode; + int32_t mode; signed char default_fd; char descrip[3]; -} redir_table[] = { +} redir_table[] ALIGN4 = { { O_RDONLY, 0, "<" }, { O_CREAT|O_TRUNC|O_WRONLY, 1, ">" }, { O_CREAT|O_APPEND|O_WRONLY, 1, ">>" }, @@ -1143,7 +1143,7 @@ struct built_in_command { #endif }; -static const struct built_in_command bltins1[] = { +static const struct built_in_command bltins1[] ALIGN_PTR = { BLTIN("." , builtin_source , "Run commands in file"), BLTIN(":" , builtin_true , NULL), #if ENABLE_HUSH_JOB @@ -1228,7 +1228,7 @@ static const struct built_in_command bltins1[] = { /* These builtins won't be used if we are on NOMMU and need to re-exec * (it's cheaper to run an external program in this case): */ -static const struct built_in_command bltins2[] = { +static const struct built_in_command bltins2[] ALIGN_PTR = { #if ENABLE_HUSH_TEST BLTIN("[" , builtin_test , NULL), #endif @@ -3895,7 +3895,7 @@ struct reserved_combo { char literal[6]; unsigned char res; unsigned char assignment_flag; - int flag; + uint32_t flag; }; enum { FLAG_END = (1 << RES_NONE ), @@ -3928,7 +3928,7 @@ static const struct reserved_combo* match_reserved_word(o_string *word) * to turn the compound list into a command. * FLAG_START means the word must start a new compound list. */ - static const struct reserved_combo reserved_list[] = { + static const struct reserved_combo reserved_list[] ALIGN4 = { # if ENABLE_HUSH_IF { "!", RES_NONE, NOT_ASSIGNMENT , 0 }, { "if", RES_IF, MAYBE_ASSIGNMENT, FLAG_THEN | FLAG_START }, diff --git a/shell/shell_common.c b/shell/shell_common.c index 42c4c9c97..dcbe0d109 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c @@ -324,7 +324,7 @@ struct limits { uint8_t factor_shift; /* shift by to get rlim_{cur,max} values */ }; -static const struct limits limits_tbl[] = { +static const struct limits limits_tbl[] ALIGN2 = { { RLIMIT_CORE, 9, }, // -c { RLIMIT_DATA, 10, }, // -d { RLIMIT_NICE, 0, }, // -e diff --git a/util-linux/acpid.c b/util-linux/acpid.c index d473e24fc..00613f8e3 100644 --- a/util-linux/acpid.c +++ b/util-linux/acpid.c @@ -99,7 +99,7 @@ struct acpi_event { const char *desc; }; -static const struct acpi_event f_evt_tab[] = { +static const struct acpi_event f_evt_tab[] ALIGN_PTR = { { "EV_KEY", 0x01, "KEY_POWER", 116, 1, "button/power PWRF 00000080" }, { "EV_KEY", 0x01, "KEY_POWER", 116, 1, "button/power PWRB 00000080" }, { "EV_SW", 0x05, "SW_LID", 0x00, 1, "button/lid LID0 00000080" }, @@ -110,7 +110,7 @@ struct acpi_action { const char *action; }; -static const struct acpi_action f_act_tab[] = { +static const struct acpi_action f_act_tab[] ALIGN_PTR = { { "PWRF", "PWRF/00000080" }, { "LID0", "LID/00000080" }, }; diff --git a/util-linux/fbset.c b/util-linux/fbset.c index 0b9a9a6bc..cc5413b40 100644 --- a/util-linux/fbset.c +++ b/util-linux/fbset.c @@ -193,7 +193,7 @@ static const struct cmdoptions_t { const char name[9]; const unsigned char param_count; const unsigned char code; -} g_cmdoptions[] = { +} g_cmdoptions[] ALIGN1 = { /*"12345678" + NUL */ //TODO: convert to index_in_strings() { "fb" , 1, CMD_FB }, diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 0df3ebf7d..6454baab8 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c @@ -303,7 +303,7 @@ static sector_t get_nr_sects(const struct partition *p); /* DOS partition types */ -static const char *const i386_sys_types[] = { +static const char *const i386_sys_types[] ALIGN_PTR = { "\x00" "Empty", "\x01" "FAT12", "\x04" "FAT16 <32M", diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c index 92180b2bc..765740ff1 100644 --- a/util-linux/fdisk_osf.c +++ b/util-linux/fdisk_osf.c @@ -144,7 +144,7 @@ struct xbsd_disklabel { #define BSD_DSTYPE_DOSPART(s) ((s) & 3) /* dos partition number */ #define BSD_DSTYPE_GEOMETRY 0x10 /* drive params in label */ -static const char *const xbsd_dktypenames[] = { +static const char *const xbsd_dktypenames[] ALIGN_PTR = { "unknown", "SMD", "MSCP", @@ -190,7 +190,7 @@ static const char *const xbsd_dktypenames[] = { #define BSD_FS_MSDOS 8 /* MS-DOS file system */ #endif -static const char *const xbsd_fstypes[] = { +static const char *const xbsd_fstypes[] ALIGN_PTR = { "\x00" "unused", /* BSD_FS_UNUSED */ "\x01" "swap", /* BSD_FS_SWAP */ "\x02" "Version 6", /* BSD_FS_V6 */ diff --git a/util-linux/fdisk_sgi.c b/util-linux/fdisk_sgi.c index c90c801e2..acb438ac0 100644 --- a/util-linux/fdisk_sgi.c +++ b/util-linux/fdisk_sgi.c @@ -174,7 +174,7 @@ isinfreelist(unsigned int b) * end of free blocks section */ -static const char *const sgi_sys_types[] = { +static const char *const sgi_sys_types[] ALIGN_PTR = { /* SGI_VOLHDR */ "\x00" "SGI volhdr" , /* 0x01 */ "\x01" "SGI trkrepl" , /* 0x02 */ "\x02" "SGI secrepl" , diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c index 29d7c283a..427b9487b 100644 --- a/util-linux/fdisk_sun.c +++ b/util-linux/fdisk_sun.c @@ -61,7 +61,7 @@ guess_device_type(void) } } -static const char *const sun_sys_types[] = { +static const char *const sun_sys_types[] ALIGN_PTR = { "\x00" "Empty" , /* 0 */ "\x01" "Boot" , /* 1 */ "\x02" "SunOS root" , /* 2 */ @@ -133,7 +133,7 @@ static const struct sun_predefined_drives { unsigned short ntrks; unsigned short nsect; unsigned short rspeed; -} sun_drives[] = { +} sun_drives[] ALIGN_PTR = { { "Quantum","ProDrive 80S",1,832,2,834,6,34,3662}, { "Quantum","ProDrive 105S",1,974,2,1019,6,35,3662}, { "CDC","Wren IV 94171-344",3,1545,2,1549,9,46,3600}, diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index 1f525d75b..fcf374b2d 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c @@ -131,7 +131,7 @@ static void allocate(uint8_t *bitmap, uint32_t blocksize, uint32_t start, uint32 static uint32_t has_super(uint32_t x) { // 0, 1 and powers of 3, 5, 7 up to 2^32 limit - static const uint32_t supers[] = { + static const uint32_t supers[] ALIGN4 = { 0, 1, 3, 5, 7, 9, 25, 27, 49, 81, 125, 243, 343, 625, 729, 2187, 2401, 3125, 6561, 15625, 16807, 19683, 59049, 78125, 117649, 177147, 390625, 531441, 823543, 1594323, 1953125, diff --git a/util-linux/mount.c b/util-linux/mount.c index fc5161d7f..aa38847ec 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -323,7 +323,7 @@ enum { // Standard mount options (from -o options or --options), // with corresponding flags -static const int32_t mount_options[] = { +static const int32_t mount_options[] ALIGN4 = { // MS_FLAGS set a bit. ~MS_FLAGS disable that bit. 0 flags are NOPs. IF_FEATURE_MOUNT_LOOP( diff --git a/util-linux/volume_id/volume_id.c b/util-linux/volume_id/volume_id.c index 99150a5b7..8ceb61bde 100644 --- a/util-linux/volume_id/volume_id.c +++ b/util-linux/volume_id/volume_id.c @@ -49,7 +49,7 @@ typedef int FAST_FUNC (*raid_probe_fptr)(struct volume_id *id, /*uint64_t off,*/ uint64_t size); typedef int FAST_FUNC (*probe_fptr)(struct volume_id *id /*, uint64_t off*/); -static const raid_probe_fptr raid1[] = { +static const raid_probe_fptr raid1[] ALIGN_PTR = { #if ENABLE_FEATURE_VOLUMEID_LINUXRAID volume_id_probe_linux_raid, #endif @@ -76,7 +76,7 @@ static const raid_probe_fptr raid1[] = { #endif }; -static const probe_fptr raid2[] = { +static const probe_fptr raid2[] ALIGN_PTR = { #if ENABLE_FEATURE_VOLUMEID_LVM volume_id_probe_lvm1, volume_id_probe_lvm2, @@ -90,7 +90,7 @@ static const probe_fptr raid2[] = { }; /* signature in the first block, only small buffer needed */ -static const probe_fptr fs1[] = { +static const probe_fptr fs1[] ALIGN_PTR = { #if ENABLE_FEATURE_VOLUMEID_FAT volume_id_probe_vfat, #endif @@ -118,7 +118,7 @@ static const probe_fptr fs1[] = { }; /* fill buffer with maximum */ -static const probe_fptr fs2[] = { +static const probe_fptr fs2[] ALIGN_PTR = { #if ENABLE_FEATURE_VOLUMEID_LINUXSWAP volume_id_probe_linux_swap, #endif -- cgit v1.2.3-55-g6feb From 77a51a2709de1b646ab493f0bf771d896de6efc2 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 29 Dec 2020 16:53:11 +0100 Subject: randomconfig fixes Signed-off-by: Denys Vlasenko --- libbb/procps.c | 2 +- loginutils/login.c | 4 ++-- miscutils/dc.c | 2 +- miscutils/devfsd.c | 4 ++-- miscutils/i2c_tools.c | 6 ++++-- networking/libiproute/ipaddress.c | 6 ++++++ networking/telnet.c | 4 ++++ networking/traceroute.c | 2 +- runit/runsv.c | 18 +++++++++++++----- shell/hush.c | 4 +++- testsuite/mount.tests | 2 ++ testsuite/xargs.tests | 2 +- util-linux/fdisk.c | 7 +++++-- 13 files changed, 45 insertions(+), 18 deletions(-) (limited to 'runit') diff --git a/libbb/procps.c b/libbb/procps.c index 975e0d4dc..75969947b 100644 --- a/libbb/procps.c +++ b/libbb/procps.c @@ -177,6 +177,7 @@ static char *skip_fields(char *str, int count) } #endif +#if ENABLE_FEATURE_TOPMEM || ENABLE_PMAP static char* skip_whitespace_if_prefixed_with(char *buf, const char *prefix) { char *tp = is_prefixed_with(buf, prefix); @@ -186,7 +187,6 @@ static char* skip_whitespace_if_prefixed_with(char *buf, const char *prefix) return tp; } -#if ENABLE_FEATURE_TOPMEM || ENABLE_PMAP int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total, void (*cb)(struct smaprec *, void *), void *data) { diff --git a/loginutils/login.c b/loginutils/login.c index de05631d2..21c32fc25 100644 --- a/loginutils/login.c +++ b/loginutils/login.c @@ -341,7 +341,7 @@ int login_main(int argc UNUSED_PARAM, char **argv) #if ENABLE_LOGIN_SESSION_AS_CHILD pid_t child_pid; #endif - pid_t my_pid; + IF_FEATURE_UTMP(pid_t my_pid;) INIT_G(); @@ -524,7 +524,7 @@ int login_main(int argc UNUSED_PARAM, char **argv) if (pw->pw_uid != 0) die_if_nologin(); - my_pid = getpid(); + IF_FEATURE_UTMP(my_pid = getpid();) update_utmp(my_pid, USER_PROCESS, short_tty, username, run_by_root ? opt_host : NULL); #if ENABLE_LOGIN_SESSION_AS_CHILD diff --git a/miscutils/dc.c b/miscutils/dc.c index 51376dd75..e94dc39e0 100644 --- a/miscutils/dc.c +++ b/miscutils/dc.c @@ -100,7 +100,7 @@ static void mod(void) * 0 */ if (d == 0) { - bb_error_msg("remainder by zero"); + bb_simple_error_msg("remainder by zero"); pop(); push(0); return; diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index 17d8fb6b9..e5bb8a2d8 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c @@ -362,7 +362,7 @@ static const char bb_msg_variable_not_found[] ALIGN1 = "variable: %s not found"; static void safe_memcpy(char *dest, const char *src, int len) { - memcpy(dest , src, len); + memcpy(dest, src, len); dest[len] = '\0'; } @@ -1106,7 +1106,7 @@ static int copy_inode(const char *destpath, const struct stat *dest_stat, do_chown: if (chown(destpath, source_stat->st_uid, source_stat->st_gid) == 0) return TRUE; - /*break;*/ + /*break;*/ } return FALSE; } /* End Function copy_inode */ diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index 57cac5d47..cda17ee00 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c @@ -273,7 +273,7 @@ static int i2c_bus_lookup(const char *bus_str) return xstrtou_range(bus_str, 10, 0, 0xfffff); } -#if ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP || ENABLE_I2CTRANSFER +#if ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP static int i2c_parse_bus_addr(const char *addr_str) { /* Slave address must be in range 0x03 - 0x77. */ @@ -286,14 +286,16 @@ static void i2c_set_pec(int fd, int pec) itoptr(pec ? 1 : 0), "can't set PEC"); } +#endif +#if ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP || ENABLE_I2CTRANSFER static void i2c_set_slave_addr(int fd, int addr, int force) { ioctl_or_perror_and_die(fd, force ? I2C_SLAVE_FORCE : I2C_SLAVE, itoptr(addr), "can't set address to 0x%02x", addr); } -#endif /* ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP */ +#endif #if ENABLE_I2CGET || ENABLE_I2CSET static int i2c_parse_data_addr(const char *data_addr) diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 71e8fb6a7..91fabb1fd 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c @@ -21,6 +21,12 @@ #define IFF_LOWER_UP 0x10000 /* driver signals L1 up */ #endif +#ifndef IFA_F_NOPREFIXROUTE +# define IFA_FLAGS 8 +/* ifa_flags */ +# define IFA_F_NOPREFIXROUTE 0x200 +#endif + struct filter_t { char *label; /* Flush cmd buf. If !NULL, print_addrinfo() constructs flush commands in it */ diff --git a/networking/telnet.c b/networking/telnet.c index 19a414b30..7a0253525 100644 --- a/networking/telnet.c +++ b/networking/telnet.c @@ -368,12 +368,16 @@ static void put_iac2_msb_lsb(unsigned x_y) } #define put_iac2_x_y(x,y) put_iac2_msb_lsb(((x)<<8) + (y)) +#if ENABLE_FEATURE_TELNET_WIDTH \ + || ENABLE_FEATURE_TELNET_TTYPE \ + || ENABLE_FEATURE_TELNET_AUTOLOGIN static void put_iac4_msb_lsb(unsigned x_y_z_t) { put_iac2_msb_lsb(x_y_z_t >> 16); put_iac2_msb_lsb(x_y_z_t); /* "... & 0xffff" is implicit */ } #define put_iac4_x_y_z_t(x,y,z,t) put_iac4_msb_lsb(((x)<<24) + ((y)<<16) + ((z)<<8) + (t)) +#endif static void put_iac3_IAC_x_y_merged(unsigned wwdd_and_c) { diff --git a/networking/traceroute.c b/networking/traceroute.c index ec3ac8b6f..3f1a9ab46 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -483,7 +483,7 @@ wait_for_reply(unsigned *timestamp_us, int *left_ms) &G.from_lsa->u.sa, &G.from_lsa->len); #endif if (read_len < 0) - bb_perror_msg_and_die("recv"); + bb_simple_perror_msg_and_die("recv"); t = monotonic_us(); *left_ms -= (t - *timestamp_us) / 1000; *timestamp_us = t; diff --git a/runit/runsv.c b/runit/runsv.c index 7e22862cd..d395d4528 100644 --- a/runit/runsv.c +++ b/runit/runsv.c @@ -58,11 +58,19 @@ static void gettimeofday_ns(struct timespec *ts) #else static void gettimeofday_ns(struct timespec *ts) { - BUILD_BUG_ON(sizeof(struct timeval) != sizeof(struct timespec)); - BUILD_BUG_ON(sizeof(((struct timeval*)ts)->tv_usec) != sizeof(ts->tv_nsec)); - /* Cheat */ - gettimeofday((void*)ts, NULL); - ts->tv_nsec *= 1000; + if (sizeof(struct timeval) == sizeof(struct timespec) + && sizeof(((struct timeval*)ts)->tv_usec) == sizeof(ts->tv_nsec) + ) { + /* Cheat */ + gettimeofday((void*)ts, NULL); + ts->tv_nsec *= 1000; + } else { + /* For example, musl has "incompatible" layouts */ + struct timeval tv; + gettimeofday(&tv, NULL); + ts->tv_sec = tv.tv_sec; + ts->tv_nsec = tv.tv_usec * 1000; + } } #endif diff --git a/shell/hush.c b/shell/hush.c index f5cbbc39f..9fead37da 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -653,7 +653,7 @@ struct command { /* used for "[[ EXPR ]]" */ # define CMD_TEST2_SINGLEWORD_NOGLOB 2 #endif -#if ENABLE_HUSH_LOCAL || ENABLE_HUSH_EXPORT || ENABLE_HUSH_READONLY +#if BASH_TEST2 || ENABLE_HUSH_LOCAL || ENABLE_HUSH_EXPORT || ENABLE_HUSH_READONLY /* used to prevent word splitting and globbing in "export v=t*" */ # define CMD_SINGLEWORD_NOGLOB 3 #endif @@ -8762,6 +8762,7 @@ static int process_wait_result(struct pipe *fg_pipe, pid_t childpid, int status) */ if (WIFSIGNALED(status)) { int sig = WTERMSIG(status); +#if ENABLE_HUSH_JOB if (G.run_list_level == 1 /* ^^^^^ Do not print in nested contexts, example: * echo `sleep 1; sh -c 'kill -9 $$'` - prints "137", NOT "Killed 137" @@ -8771,6 +8772,7 @@ static int process_wait_result(struct pipe *fg_pipe, pid_t childpid, int status) /* strsignal() is for bash compat. ~600 bloat versus bbox's get_signame() */ puts(sig == SIGINT || sig == SIGPIPE ? "" : strsignal(sig)); } +#endif /* TODO: if (WCOREDUMP(status)) + " (core dumped)"; */ /* MIPS has 128 sigs (1..128), if sig==128, * 128 + sig would result in exitcode 256 -> 0! diff --git a/testsuite/mount.tests b/testsuite/mount.tests index 91c2e8b42..b6d5ebe08 100755 --- a/testsuite/mount.tests +++ b/testsuite/mount.tests @@ -34,6 +34,8 @@ umount -d "$testdir" 2>/dev/null # file input will be file called "input" # test can create a file "actual" instead of writing to stdout +# This will always fail on !CONFIG_MANDATORY_FILE_LOCKING kernels +test "$SKIP_MOUNT_MAND_TESTS" = "1" || \ testing "mount -o remount,mand" \ "mount -o loop mount.image1m $testdir "\ "&& grep -Fc $testdir Date: Wed, 30 Dec 2020 23:48:01 +0100 Subject: libbb: introduce and use xgettimeofday(), do not truncate 64-bit time_t in shells function old new delta xgettimeofday - 11 +11 get_local_var_value 280 281 +1 svlogd_main 1323 1322 -1 change_epoch 67 66 -1 timestamp_and_log 461 458 -3 hwclock_main 301 298 -3 fmt_time_bernstein_25 135 132 -3 step_time 331 326 -5 script_main 1207 1202 -5 machtime 34 28 -6 curtime 61 54 -7 ts_main 423 415 -8 nmeter_main 761 751 -10 gettime1900d 67 46 -21 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/12 up/down: 12/-73) Total: -61 bytes Signed-off-by: Denys Vlasenko --- include/libbb.h | 1 + libbb/time.c | 6 +++--- libbb/xfuncs_printf.c | 11 +++++++++++ miscutils/ts.c | 4 ++-- networking/inetd.c | 2 +- networking/ntpd.c | 4 ++-- networking/traceroute.c | 2 +- procps/nmeter.c | 8 ++++---- runit/runsv.c | 4 ++-- runit/svlogd.c | 4 ++-- shell/ash.c | 10 +++++----- shell/hush.c | 10 +++++----- sysklogd/syslogd.c | 2 +- util-linux/hwclock.c | 8 ++++---- util-linux/mdev.c | 2 +- util-linux/script.c | 2 +- 16 files changed, 46 insertions(+), 34 deletions(-) (limited to 'runit') diff --git a/include/libbb.h b/include/libbb.h index cae54658b..dad6fc687 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -657,6 +657,7 @@ void parse_datestr(const char *date_str, struct tm *ptm) FAST_FUNC; time_t validate_tm_time(const char *date_str, struct tm *ptm) FAST_FUNC; char *strftime_HHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC; char *strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC; +void xgettimeofday(struct timeval *tv) FAST_FUNC; void xsettimeofday(const struct timeval *tv) FAST_FUNC; diff --git a/libbb/time.c b/libbb/time.c index 74a69eefb..cf5f2e5c8 100644 --- a/libbb/time.c +++ b/libbb/time.c @@ -291,19 +291,19 @@ unsigned FAST_FUNC monotonic_sec(void) unsigned long long FAST_FUNC monotonic_ns(void) { struct timeval tv; - gettimeofday(&tv, NULL); + xgettimeofday(&tv); return tv.tv_sec * 1000000000ULL + tv.tv_usec * 1000; } unsigned long long FAST_FUNC monotonic_us(void) { struct timeval tv; - gettimeofday(&tv, NULL); + xgettimeofday(&tv); return tv.tv_sec * 1000000ULL + tv.tv_usec; } unsigned long long FAST_FUNC monotonic_ms(void) { struct timeval tv; - gettimeofday(&tv, NULL); + xgettimeofday(&tv); return tv.tv_sec * 1000ULL + tv.tv_usec / 1000; } unsigned FAST_FUNC monotonic_sec(void) diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index aea995a5c..99596b9d0 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c @@ -720,3 +720,14 @@ void FAST_FUNC xsettimeofday(const struct timeval *tv) if (settimeofday(tv, NULL)) bb_simple_perror_msg_and_die("settimeofday"); } + +void FAST_FUNC xgettimeofday(struct timeval *tv) +{ +#if 0 + if (gettimeofday(tv, NULL)) + bb_simple_perror_msg_and_die("gettimeofday"); +#else + /* Never fails on Linux */ + gettimeofday(tv, NULL); +#endif +} diff --git a/miscutils/ts.c b/miscutils/ts.c index f2d367654..6e5d77bda 100644 --- a/miscutils/ts.c +++ b/miscutils/ts.c @@ -47,13 +47,13 @@ int ts_main(int argc UNUSED_PARAM, char **argv) #define date_buf bb_common_bufsiz1 setup_common_bufsiz(); - gettimeofday(&base, NULL); + xgettimeofday(&base); while ((line = xmalloc_fgets(stdin)) != NULL) { struct timeval ts; struct tm tm_time; - gettimeofday(&ts, NULL); + xgettimeofday(&ts); if (opt) { /* -i and/or -s */ struct timeval ts1 = ts1; diff --git a/networking/inetd.c b/networking/inetd.c index 9f5a436d6..febfb7b73 100644 --- a/networking/inetd.c +++ b/networking/inetd.c @@ -1701,7 +1701,7 @@ static uint32_t machtime(void) { struct timeval tv; - gettimeofday(&tv, NULL); + xgettimeofday(&tv); return htonl((uint32_t)(tv.tv_sec + 2208988800U)); } /* ARGSUSED */ diff --git a/networking/ntpd.c b/networking/ntpd.c index 5a540a391..46d8f3495 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c @@ -560,7 +560,7 @@ static double gettime1900d(void) { struct timeval tv; - gettimeofday(&tv, NULL); /* never fails */ + xgettimeofday(&tv); G.cur_time = tv.tv_sec + (1.0e-6 * tv.tv_usec) + OFFSET_1900_1970; return G.cur_time; } @@ -1144,7 +1144,7 @@ step_time(double offset) char buf[sizeof("yyyy-mm-dd hh:mm:ss") + /*paranoia:*/ 4]; time_t tval; - gettimeofday(&tvc, NULL); /* never fails */ + xgettimeofday(&tvc); dtime = tvc.tv_sec + (1.0e-6 * tvc.tv_usec) + offset; d_to_tv(dtime, &tvn); xsettimeofday(&tvn); diff --git a/networking/traceroute.c b/networking/traceroute.c index 3f1a9ab46..bd63e4449 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -505,7 +505,7 @@ send_probe(int seq, int ttl) struct outdata6_t *pkt = (void *) outdata; pkt->ident6 = ident; pkt->seq6 = htonl(seq); - /*gettimeofday(&pkt->tv, &tz);*/ + /*xgettimeofday(&pkt->tv);*/ icp = outicmp6; } else #endif diff --git a/procps/nmeter.c b/procps/nmeter.c index 07b7abe2f..f08938654 100644 --- a/procps/nmeter.c +++ b/procps/nmeter.c @@ -952,11 +952,11 @@ int nmeter_main(int argc UNUSED_PARAM, char **argv) reset_outbuf(); if (G.delta >= 0) { - gettimeofday(&G.tv, NULL); + xgettimeofday(&G.tv); usleep(G.delta > 1000000 ? 1000000 : G.delta - G.tv.tv_usec % G.deltanz); } - gettimeofday(&G.start, NULL); + xgettimeofday(&G.start); G.tv = G.start; while (1) { collect_info(first); @@ -971,7 +971,7 @@ int nmeter_main(int argc UNUSED_PARAM, char **argv) if (G.delta >= 0) { int rem; // can be commented out, will sacrifice sleep time precision a bit - gettimeofday(&G.tv, NULL); + xgettimeofday(&G.tv); if (need_seconds) rem = G.delta - ((ullong)G.tv.tv_sec*1000000 + G.tv.tv_usec) % G.deltanz; else @@ -983,7 +983,7 @@ int nmeter_main(int argc UNUSED_PARAM, char **argv) } usleep(rem); } - gettimeofday(&G.tv, NULL); + xgettimeofday(&G.tv); } /*return 0;*/ diff --git a/runit/runsv.c b/runit/runsv.c index d395d4528..ecab8cdf5 100644 --- a/runit/runsv.c +++ b/runit/runsv.c @@ -62,12 +62,12 @@ static void gettimeofday_ns(struct timespec *ts) && sizeof(((struct timeval*)ts)->tv_usec) == sizeof(ts->tv_nsec) ) { /* Cheat */ - gettimeofday((void*)ts, NULL); + xgettimeofday((void*)ts); ts->tv_nsec *= 1000; } else { /* For example, musl has "incompatible" layouts */ struct timeval tv; - gettimeofday(&tv, NULL); + xgettimeofday(&tv); ts->tv_sec = tv.tv_sec; ts->tv_nsec = tv.tv_usec * 1000; } diff --git a/runit/svlogd.c b/runit/svlogd.c index 040e71104..294e31aca 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c @@ -351,7 +351,7 @@ static void fmt_time_human_30nul(char *s, char dt_delim) struct tm *ptm; struct timeval tv; - gettimeofday(&tv, NULL); + xgettimeofday(&tv); ptm = gmtime_r(&tv.tv_sec, &tm); /* ^^^ using gmtime_r() instead of gmtime() to not use static data */ sprintf(s, "%04u-%02u-%02u%c%02u:%02u:%02u.%06u000", @@ -376,7 +376,7 @@ static void fmt_time_bernstein_25(char *s) struct timeval tv; unsigned sec_hi; - gettimeofday(&tv, NULL); + xgettimeofday(&tv); sec_hi = (0x400000000000000aULL + tv.tv_sec) >> 32; tv.tv_sec = (time_t)(0x400000000000000aULL) + tv.tv_sec; tv.tv_usec *= 1000; diff --git a/shell/ash.c b/shell/ash.c index f16d7fb6a..54f004375 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -11371,10 +11371,10 @@ static void FAST_FUNC change_epoch(struct var *vepoch, const char *fmt) { struct timeval tv; - char buffer[sizeof("%lu.nnnnnn") + sizeof(long)*3]; + char buffer[sizeof("%llu.nnnnnn") + sizeof(long long)*3]; - gettimeofday(&tv, NULL); - sprintf(buffer, fmt, (unsigned long)tv.tv_sec, (unsigned)tv.tv_usec); + xgettimeofday(&tv); + sprintf(buffer, fmt, (unsigned long long)tv.tv_sec, (unsigned)tv.tv_usec); setvar(vepoch->var_text, buffer, VNOFUNC); vepoch->flags &= ~VNOFUNC; } @@ -11382,13 +11382,13 @@ change_epoch(struct var *vepoch, const char *fmt) static void FAST_FUNC change_seconds(const char *value UNUSED_PARAM) { - change_epoch(&vepochs, "%lu"); + change_epoch(&vepochs, "%llu"); } static void FAST_FUNC change_realtime(const char *value UNUSED_PARAM) { - change_epoch(&vepochr, "%lu.%06u"); + change_epoch(&vepochr, "%llu.%06u"); } #endif diff --git a/shell/hush.c b/shell/hush.c index 9fead37da..65f08659f 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -1027,7 +1027,7 @@ struct globals { struct sigaction sa; char optstring_buf[sizeof("eixcs")]; #if BASH_EPOCH_VARS - char epoch_buf[sizeof("%lu.nnnnnn") + sizeof(long)*3]; + char epoch_buf[sizeof("%llu.nnnnnn") + sizeof(long long)*3]; #endif #if ENABLE_FEATURE_EDITING char user_input_buf[CONFIG_FEATURE_EDITING_MAX_LEN]; @@ -2277,13 +2277,13 @@ static const char* FAST_FUNC get_local_var_value(const char *name) { const char *fmt = NULL; if (strcmp(name, "EPOCHSECONDS") == 0) - fmt = "%lu"; + fmt = "%llu"; else if (strcmp(name, "EPOCHREALTIME") == 0) - fmt = "%lu.%06u"; + fmt = "%llu.%06u"; if (fmt) { struct timeval tv; - gettimeofday(&tv, NULL); - sprintf(G.epoch_buf, fmt, (unsigned long)tv.tv_sec, + xgettimeofday(&tv); + sprintf(G.epoch_buf, fmt, (unsigned long long)tv.tv_sec, (unsigned)tv.tv_usec); return G.epoch_buf; } diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 598f28d0c..6ddfd771a 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c @@ -842,7 +842,7 @@ static void timestamp_and_log(int pri, char *msg, int len) #if ENABLE_FEATURE_SYSLOGD_PRECISE_TIMESTAMPS if (!timestamp) { struct timeval tv; - gettimeofday(&tv, NULL); + xgettimeofday(&tv); now = tv.tv_sec; timestamp = ctime(&now) + 4; /* skip day of week */ /* overwrite year by milliseconds, zero terminate */ diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 25db7cdad..723b09589 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -79,7 +79,7 @@ static time_t read_rtc(const char **pp_rtcname, struct timeval *sys_tv, int utc) int before = tm_time.tm_sec; while (1) { rtc_read_tm(&tm_time, fd); - gettimeofday(sys_tv, NULL); + xgettimeofday(sys_tv); if (before != (int)tm_time.tm_sec) break; } @@ -205,7 +205,7 @@ static void from_sys_clock(const char **pp_rtcname, int utc) int rtc; rtc = rtc_xopen(pp_rtcname, O_WRONLY); - gettimeofday(&tv, NULL); + xgettimeofday(&tv); /* Prepare tm_time */ if (sizeof(time_t) == sizeof(tv.tv_sec)) { if (utc) @@ -253,7 +253,7 @@ static void from_sys_clock(const char **pp_rtcname, int utc) unsigned rem_usec; time_t t; - gettimeofday(&tv, NULL); + xgettimeofday(&tv); t = tv.tv_sec; rem_usec = 1000000 - tv.tv_usec; @@ -274,7 +274,7 @@ static void from_sys_clock(const char **pp_rtcname, int utc) } /* gmtime/localtime took some time, re-get cur time */ - gettimeofday(&tv, NULL); + xgettimeofday(&tv); if (tv.tv_sec < t /* we are still in old second */ || (tv.tv_sec == t && tv.tv_usec < adj) /* not too far into next second */ diff --git a/util-linux/mdev.c b/util-linux/mdev.c index ebf83d1a3..dbbcbc655 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c @@ -963,7 +963,7 @@ static void load_firmware(const char *firmware, const char *sysfs_path) static char *curtime(void) { struct timeval tv; - gettimeofday(&tv, NULL); + xgettimeofday(&tv); sprintf( strftime_HHMMSS(G.timestr, sizeof(G.timestr), &tv.tv_sec), ".%06u", diff --git a/util-linux/script.c b/util-linux/script.c index 4eac5e94f..963435335 100644 --- a/util-linux/script.c +++ b/util-linux/script.c @@ -172,7 +172,7 @@ int script_main(int argc UNUSED_PARAM, char **argv) struct timeval tv; double newtime; - gettimeofday(&tv, NULL); + xgettimeofday(&tv); newtime = tv.tv_sec + (double) tv.tv_usec / 1000000; fprintf(timing_fp, "%f %u\n", newtime - oldtime, count); oldtime = newtime; -- cgit v1.2.3-55-g6feb