Commit Graph

1532 Commits

Author SHA1 Message Date
Denys Vlasenko
c2788f88f4 libbb: introduce and use chdir_or_warn()
function                                             old     new   delta
chdir_or_warn                                          -      37     +37
send_cgi_and_exit                                    720     711      -9
xchdir                                                27      15     -12
setup_environment                                    233     217     -16
fork_job                                             449     433     -16
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/4 up/down: 37/-53)            Total: -16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-13 12:56:10 +01:00
Denys Vlasenko
931c55f9e2 libbb: invert the meaning of SETUP_ENV_NO_CHDIR -> SETUP_ENV_CHDIR
Double negatives are hard to grok.

function                                             old     new   delta
login_main                                           986     988      +2
su_main                                              474     470      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 2/-4)               Total: -2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-13 12:50:48 +01:00
Denys Vlasenko
db5546ca10 libbb: code shrink: introduce and use [_]exit_SUCCESS()
function                                             old     new   delta
exit_SUCCESS                                           -       7      +7
_exit_SUCCESS                                          -       7      +7
run_pipe                                            1562    1567      +5
pseudo_exec_argv                                     399     400      +1
finish                                                86      87      +1
start_stop_daemon_main                              1109    1107      -2
shutdown_on_signal                                    38      36      -2
runsv_main                                          1662    1660      -2
redirect                                            1070    1068      -2
read_line                                             79      77      -2
pause_and_low_level_reboot                            54      52      -2
list_i2c_busses_and_exit                             483     481      -2
less_exit                                             12      10      -2
identify                                            4123    4121      -2
grep_file                                           1161    1159      -2
getty_main                                          1519    1517      -2
fsck_minix_main                                     2681    2679      -2
free_session                                         132     130      -2
fdisk_main                                          4739    4737      -2
clean_up_and_exit                                     53      51      -2
bsd_select                                          1566    1564      -2
bb_daemonize_or_rexec                                198     196      -2
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/17 up/down: 21/-34)           Total: -13 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-05 22:16:06 +01:00
Denys Vlasenko
076f5e064f less: code shrink
function                                             old     new   delta
restore_tty                                            -      29     +29
less_main                                           2107    2105      -2
getch_nowait                                         253     251      -2
buffer_print                                         614     612      -2
less_exit                                             51      12     -39
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/4 up/down: 29/-45)            Total: -16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-05 22:04:21 +01:00
Denys Vlasenko
53b2fdcdba *: add NOINLINEs where code noticeably shrinks
function                                             old     new   delta
display                                               85    1463   +1378  -73 bytes
select_and_cluster                                     -    1088   +1088 -139 bytes
parse_reply                                            -     979    +979 -109 bytes
zbc_num_sqrt                                           -     632    +632 -191 bytes
show_bridge_port                                       -     585    +585  -56 bytes
sp_256_proj_point_add_8                                -     576    +576  -45 bytes
encode_then_append_var_plusminus                       -     554    +554 -118 bytes
read_mode_db                                           -     537    +537  -47 bytes
fbset_main                                          1331     747    -584
sp_256_ecc_mulmod_8                                 1157     536    -621
brctl_main                                          2189    1548    -641
expand_one_var                                      2544    1872    -672
zxc_vm_process                                      6412    5589    -823
send_queries                                        1813     725   -1088
recv_and_process_peer_pkt                           2245    1018   -1227
bb_dump_dump                                        1531      80   -1451
------------------------------------------------------------------------------
(add/remove: 7/0 grow/shrink: 1/8 up/down: 6329/-7107)       Total: -778 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-10 13:50:53 +02:00
Ismael Luceno
35727f5741 less: Ignore -X
The flag disables termcap init/deinit of the terminal, which the applet
doesn't do anyway.

Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-28 23:22:47 +02:00
Denys Vlasenko
4b032a4d6c chat: hopefully fix infinite spinning on input EOF
function                                             old     new   delta
chat_main                                           1295    1303      +8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-06 17:38:18 +02:00
Denys Vlasenko
34d79c9aa0 ascii: new applet
function                                             old     new   delta
.rodata                                           103397  103670    +273
ascii_main                                             -     177    +177
applet_names                                        2739    2745      +6
applet_main                                         1584    1588      +4
applet_suid                                           99     100      +1
applet_install_loc                                   198     199      +1
packed_usage                                       33716   33713      -3
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 5/1 up/down: 462/-3)            Total: 459 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-21 17:52:50 +02:00
Denys Vlasenko
4d4fc5ca5e man: fix segfault in "man 1"
function                                             old     new   delta
man_main                                             942     954     +12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-15 14:47:46 +02:00
Denys Vlasenko
e47000490c shuf: simplify check that we have at least one FILE
function                                             old     new   delta
.rodata                                           103190  103194      +4
packed_usage                                       33541   33537      -4
shred_main                                           354     337     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 4/-21)             Total: -17 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-15 10:39:33 +02:00
Denys Vlasenko
1f60d88cf6 *: more --help tweaks
function                                             old     new   delta
packed_usage                                       33552   33541     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-15 10:00:18 +02:00
Denys Vlasenko
e2b9215868 *: --help tweaks
function                                             old     new   delta
packed_usage                                       33589   33552     -37

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-14 20:47:20 +02:00
Denys Vlasenko
6f7b10cdab *: more --help tweaking
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-13 03:51:55 +02:00
Denys Vlasenko
1849285a20 *: more --help tweaks, mostly expanding ts --help
function                                             old     new   delta
packed_usage                                       33554   33596     +42

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-13 03:12:09 +02:00
Denys Vlasenko
6b6826f0b8 *: --help tweaks
function                                             old     new   delta
.rodata                                           103190  103189      -1
packed_usage                                       33590   33566     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-25)             Total: -25 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-13 01:08:48 +02:00
Denys Vlasenko
aece2c5f0f bc: tweak overflow detection in a^b
function                                             old     new   delta
zbc_num_p                                            506     510      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-12 14:03:24 +02:00
Denys Vlasenko
e36c39a46d bc: code shrink: combine init() and copy() where we can
function                                             old     new   delta
bc_num_init_and_copy                                   -      27     +27
zxc_program_popResultAndCopyToVar                    495     483     -12
zxc_num_printNum                                     518     506     -12
zbc_num_p                                            518     506     -12
zxc_program_assign                                   357     341     -16
zbc_num_m                                            298     267     -31
zxc_vm_process                                      6498    6412     -86
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/6 up/down: 27/-169)          Total: -142 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-12 12:35:15 +02:00
Denys Vlasenko
e5958f7dda bc: fix for mul overflow in scale calculation in a^b
function                                             old     new   delta
zbc_num_p                                            516     518      +2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-12 12:19:20 +02:00
Denys Vlasenko
c0943ac451 platform.h: fix for Bionic >= 21 not having wait3()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-14 22:14:36 +02:00
Denys Vlasenko
ba9f9c2d2c *: --help text tweaks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-14 15:15:45 +02:00
Rasmus Villemoes
50a37459ff watchdog: make open-write-close-open functionality a config knob
The behaviour introduced by commit 31c765081d ("watchdog: stop
watchdog first on startup") causes warnings in the kernel log when the
nowayout feature is enabled:

[   16.212184] watchdog: watchdog0: nowayout prevents watchdog being stopped!
[   16.212196] watchdog: watchdog0: watchdog did not stop!

The latter may also appear by itself in case the watchdog is of the
type that cannot be stopped once started (e.g. the common
always-running gpio_wdt kind).

These warnings can be somewhat ominous and distracting, so allow
configuring whether to use this open-write-close-open sequence rather
than just open. Also saves a bit of .text when disabled:

function                                             old     new   delta
shutdown_on_signal                                    31      58     +27
watchdog_main                                        339     306     -33
shutdown_watchdog                                     34       -     -34
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 27/-67)            Total: -40 bytes

Make it default n:

- It's a workaround for one specific type of watchdog (and
  that seems to be a defect in the kernel driver)
- Even when not enabled in busybox config, it can easily be
  implemented outside busybox
- Code size
- Commit 31c765081d should be considered a regression for all the
  boards that now end up with KERN_CRIT warnings in dmesg.
- The author of that commit said "This use case is evidently rare, so
  if it is indeed causing problems for other people I'd OK then I
  understand whatever needs to be done." in the v1 thread.

Cc: Matt Spinler <mspinler@linux.vnet.ibm.com>
Cc: deweloper@wp.pl
Cc: tito <farmatito@tiscali.it>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-13 16:05:27 +02:00
Denys Vlasenko
c2bd0b6806 timeout,top,watch,ping: parse NN.N fractional duration in locales with other separators
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-23 13:50:02 +01:00
Denys Vlasenko
9b6bcfda0e bc: typo fix in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-26 21:20:18 +01:00
Denys Vlasenko
9037757c5f dc: more docs in --help
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-26 17:11:55 +01:00
Denys Vlasenko
1a37aa7a88 dc: document what non-GNU commands do
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-26 14:48:04 +01:00
Denys Vlasenko
ace81cd46c bc/dc: fix length(0) and length(0.000nnn) result
function                                             old     new   delta
zxc_vm_process                                      6464    6498     +34

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-26 14:23:13 +01:00
Denys Vlasenko
3d88cc1d37 dc: correct --help text
before:

    Tiny RPN calculator. Operations:
    +, -, *, /, %, ~, ^, |,
    p - print top of the stack without popping
    f - print entire stack
    k - pop the value and set the precision
    i - pop the value and set input radix
    o - pop the value and set output radix

After:

    Tiny RPN calculator. Operations:
    Arithmetic: + - * / % ^
    ~ - divide with remainder
    | - modular exponentiation
    v - square root
    p - print top of the stack without popping
    f - print entire stack
    k - pop the value and set precision
    i - pop the value and set input radix
    o - pop the value and set output radix

function                                             old     new   delta
packed_usage                                       33519   33565     +46

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-26 13:32:29 +01:00
Ron Yorston
cad3fc743a libbb: introduce and use fputs_stdout
function                                             old     new   delta
fputs_stdout                                           -      12     +12
zxc_vm_process                                      7237    7230      -7
yes_main                                              85      78      -7
write_block                                          380     373      -7
wrapf                                                305     298      -7
strings_main                                         437     430      -7
show_bridge                                          353     346      -7
rev_main                                             384     377      -7
put_prompt_custom                                     58      51      -7
put_cur_glyph_and_inc_cursor                         168     161      -7
print_numbered_lines                                 152     145      -7
print_named_ascii                                    130     123      -7
print_name                                           135     128      -7
print_login_issue                                    386     379      -7
print_ascii                                          208     201      -7
powertop_main                                       1249    1242      -7
od_main                                             1789    1782      -7
logread_main                                         518     511      -7
head_main                                            804     797      -7
display_process_list                                1319    1312      -7
cut_main                                            1002     995      -7
bb_dump_dump                                        1550    1543      -7
bb_ask_noecho                                        393     386      -7
baseNUM_main                                         702     695      -7
expand_main                                          755     745     -10
dumpleases_main                                      497     487     -10
write1                                                12       -     -12
putcsi                                                37      23     -14
print_login_prompt                                    55      41     -14
paste_main                                           525     511     -14
cat_main                                             440     426     -14
print_it                                             245     230     -15
print_addrinfo                                      1188    1171     -17
print_rule                                           770     750     -20
print_linkinfo                                       842     822     -20
httpd_main                                           791     771     -20
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/34 up/down: 12/-341)         Total: -329 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-03 20:52:40 +01:00
Denys Vlasenko
cc4303f5e6 bc: code shrink
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-01-06 14:00:53 +01:00
Denys Vlasenko
0197fbffb7 bc: ^C on input line exits (unlike ^C during calculations, which does not)
function                                             old     new   delta
xc_read_line                                         353     344      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-01-04 14:41:20 +01:00
Denys Vlasenko
3c13da3dab 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 <vda.linux@googlemail.com>
2020-12-30 23:48:01 +01:00
Denys Vlasenko
b230ff9d8f *: use fopen helpers where appropriate
function                                             old     new   delta
finalize                                             348     343      -5
parse_resolvconf                                     306     299      -7
list_i2c_busses_and_exit                             495     483     -12
bootchartd_main                                     1091    1076     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-39)             Total: -39 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-30 00:16:27 +01:00
Denys Vlasenko
29a9043b36 bc,dc: make BC_LINE_LENGTH/DC_LINE_LENGTH more compatible with GNU
function                                             old     new   delta
xc_vm_init                                           640     682     +42

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-29 18:52:19 +01:00
Denys Vlasenko
40f9fe2160 bc: placate gcc (it thinks 's' can be uninitialized here)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-29 17:02:06 +01:00
Denys Vlasenko
77a51a2709 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-29 16:53:11 +01:00
Denys Vlasenko
1462673dde man: implement SECTION parameters
function                                             old     new   delta
man_main                                             807     942    +135
is_section_name                                        -      52     +52
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 187/0)             Total: 187 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-27 16:02:37 +01:00
Denys Vlasenko
00eb23b47a bc: do not allocate line editing state until needed
function                                             old     new   delta
xc_read_line                                         324     353     +29
free_line_input_t                                     34      39      +5
xc_vm_init                                           656     640     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 34/-16)             Total: 18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-21 21:36:58 +01:00
Denys Vlasenko
c7b858ff8d libbb: add and use infrastructure for fixed page size optimization
function                                             old     new   delta
procps_scan                                         1121    1118      -3
getpagesize                                            6       -      -6
rpm_main                                            1037    1027     -10
rpm2cpio_main                                        120     110     -10
ptok                                                  38      21     -17
time_main                                           1282    1261     -21
mkswap_main                                          317     278     -39
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/6 up/down: 0/-106)           Total: -106 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-14 18:54:30 +01:00
Denys Vlasenko
5d553bc558 more --help text tweaks
function                                             old     new   delta
packed_usage                                       33545   33581     +36

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13 19:18:28 +01:00
Denys Vlasenko
11f1a2553e help text tweaks
function                                             old     new   delta
packed_usage                                       33547   33545      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-13 19:04:19 +01:00
Denys Vlasenko
6cc4962b60 decrease padding: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nilly
text	   data	    bss	    dec	    hex	filename
1021236	    559	   5052	1026847	  fab1f	busybox_old
1021120	    559	   5052	1026731	  faaab	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-30 14:58:02 +01:00
Denys Vlasenko
965b795b87 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 <vda.linux@googlemail.com>
2020-11-30 13:03:03 +01:00
Denys Vlasenko
6a55b4e403 libbb: introduce and use msleep()
function                                             old     new   delta
msleep                                                 -      45     +45
watchdog_main                                        271     266      -5
common_traceroute_main                              3546    3530     -16
beep_main                                            277     248     -29
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 45/-50)             Total: -5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-29 12:40:25 +01:00
Denys Vlasenko
b86a9ed699 use write_str() functions where appropriate
function                                             old     new   delta
chat_main                                           1300    1295      -5
finalize_tty_attrs                                    80      70     -10
getty_main                                          1538    1519     -19
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-34)             Total: -34 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-29 11:49:37 +01:00
Denys Vlasenko
ec16c030bd 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 <vda.linux@googlemail.com>
2020-11-29 11:37:34 +01:00
Ron Yorston
5c69ad0ecd build system: drop PLATFORM_LINUX
PLATFORM_LINUX is a hidden configuration option which is disabled by
default and enabled at over a hundred locations for features that are
deemed to be Linux specific.

The only effect of PLATFORM_LINUX is to control compilation of
libbb/match_fstype.c.  This file is only needed by mount and umount.

Remove all references to PLATFORM_LINUX and compile match_fstype.c
if mount or umount is enabled.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-13 17:12:56 +02:00
Denys Vlasenko
2dd82f465e lsscsi: code shrink
function                                             old     new   delta
lsscsi_main                                          298     302      +4
get_line                                              56      45     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-11)              Total: -7 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-20 02:03:02 +02:00
Gray Wolf
051665ef69 crontab: Fix -e with editors saving using renaming strategy
Some editors (like vim) use renaming strategy to save file. That means
they save a file to some random name and then rename it to final
location. The advantage is that such save is atomic.

However, crontab -e holds open fd to the temporary file, meaning it
never sees the changes. The temporary file needs to be re-opened after
the editor terminates for the changes to properly save.

Fixes #12491

Signed-off-by: Gray Wolf <wolf@wolfsden.cz>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-07-11 17:02:37 +02:00
Denys Vlasenko
5663a17dab bc: placate a "defined but not used" warning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-24 15:05:29 +02:00
Denys Vlasenko
03ab212bff randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-23 03:43:39 +02:00