Commit Graph

22 Commits

Author SHA1 Message Date
James Byrne
6937487be7 libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d437 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().

This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.

Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.

This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.

The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):

Arm:     -92 bytes
MIPS:    -52 bytes
PPC:   -1836 bytes
x86_64: -938 bytes

Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 11:35:03 +02:00
Denys Vlasenko
8d634a08c4 sendfile: code shrink
function                                             old     new   delta
printstr_base64                                        -      22     +22
printbuf_base64                                        -      11     +11
printfile_base64                                       -       9      +9
makemime_main                                        305     294     -11
encode_n_base64                                      236     223     -13
sendmail_main                                       1380    1366     -14
encode_base64                                         36       -     -36
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 0/3 up/down: 42/-74)            Total: -32 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-31 17:30:08 +02:00
Raffaello D. Di Napoli
f28b8857a9 sendmail: support AUTH PLAIN in addition to AUTH LOGIN
Implement the -am argument to allow choosing an AUTH method.
For now only PLAIN and LOGIN are supported, but others can be added
easily in the future.

AUTH PLAIN required adding a new variant of encode_base64() capable of
handling NUL characters in the input string; the old function is now a
wrapper for the newer one.

function                                             old     new   delta
encode_n_base64                                        -     236    +236
sendmail_main                                       1199    1380    +181
packed_usage                                       32873   32877      +4
encode_base64                                        242      36    -206
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/1 up/down: 421/-206)          Total: 215 bytes

Signed-off-by: Raffaello D. Di Napoli <rafdev@dinapo.li>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-31 17:17:40 +02:00
Denys Vlasenko
17058a06c4 libbb: switch bb_ask_noecho() to "mallocing" string return API
function                                             old     new   delta
bb_ask_noecho                                        313     330     +17
get_cred_or_die                                      125     115     -10
passwd_main                                          995     958     -37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 17/-47)            Total: -30 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 15:50:30 +02:00
Denys Vlasenko
77cb6b99a4 libbb: rename bb_ask -> bb_ask_noecho, bb_ask_confirmation -> bb_ask_y_confirmation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-07 15:08:12 +02:00
Denys Vlasenko
e440b39416 *: stop using atexit in non-debug build: saves ~260 in bss with musl
"builtin" below is atexit's 32-element global array of functions to call.

function                                             old     new   delta
top_main                                             879     889     +10
launch_helper                                        185     193      +8
powertop_main                                       1555    1559      +4
sed_main                                             651     650      -1
slot                                                   4       -      -4
call                                                   4       -      -4
atexit                                                23       -     -23
kill_helper                                           31       -     -31
__funcs_on_exit                                      120       -    -120
__cxa_atexit                                         168       -    -168
builtin                                              260       -    -260
------------------------------------------------------------------------------
(add/remove: 0/8 grow/shrink: 3/1 up/down: 22/-611)          Total: -589 bytes
   text	   data	    bss	    dec	    hex	filename
 912364	    563	   6132	 919059	  e0613	busybox_old
 912035	    563	   5844	 918442	  e03aa	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-16 17:45:32 +02:00
Denys Vlasenko
d60752f8c9 build system: -fno-builtin-printf
Benefits are: drops reference to out-of-line putchar(), fixes a few cases
of failed string merge.

function                                             old     new   delta
i2cdump_main                                        1488    1502     +14
sha256_process_block64                               423     433     +10
sendmail_main                                       1183    1185      +2
list_table                                          1114    1116      +2
i2cdetect_main                                      1235    1237      +2
fdisk_main                                          2852    2854      +2
builtin_type                                         119     121      +2
unicode_conv_to_printable2                           325     324      -1
scan_recursive                                       380     378      -2
mkfs_minix_main                                     2687    2684      -3
buffer_fill_and_print                                178     169      -9
putchar                                              152       -    -152
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 7/4 up/down: 34/-167)          Total: -133 bytes
   text    data     bss     dec     hex filename
 937788     932   17676  956396   e97ec busybox_old
 937564     932   17676  956172   e970c busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-07 22:42:45 +02:00
Denys Vlasenko
41fea01066 sendmail: stop doing -t unconditionally; makemime: generate 76 char base64 lines
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-18 22:25:35 +01:00
Denys Vlasenko
34c469ae04 sendmail: don't talk until 220 code is seen. Closes 3487
function                                             old     new   delta
sendmail_main                                        934     939      +5
smtp_checkp                                          167     165      -2
packed_usage                                       28634   28621     -13

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-18 03:01:49 +02:00
Denys Vlasenko
80c5b6893d libbb: nonblock_safe_read->nonblock_immune_read, remove unused param of xmalloc_reads
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-08 21:21:10 +02:00
Denys Vlasenko
5707b52fd4 mailutils/*: add verbose option to sendmail; remove -m and -j from makemime
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-12-20 05:12:39 +01:00
Denys Vlasenko
c8f9a8d3c0 move read_base64 to libbb/uuencode.c
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-16 18:10:04 +02:00
Denys Vlasenko
9fe98f701d libbb: merge mail and uudecode's base64 decoders
function                                             old     new   delta
read_base64                                            -     378    +378
uudecode_main                                        306     315      +9
parse                                                953     958      +5
read_stduu                                           250     254      +4
base64_main                                          217     219      +2
read_base64                                          358       -    -358
decode_base64                                        371       -    -371
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 4/0 up/down: 398/-729)         Total: -331 bytes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-16 17:51:13 +02:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
This change retains "or later" state! No licensing _changes_ here,
only form is adjusted (article, space between "GPL" and "v2" and so on).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 20:14:46 +02:00
Pascal Bellard
926031b764 *: introduce and use xfork() and xvfork()
function                                             old     new   delta
launch_helper                                        170     169      -1
setup_heredoc                                        312     302     -10
handle_dir_common                                    367     354     -13
expand_vars_to_list                                 2456    2443     -13
open_transformer                                      89      74     -15
data_extract_to_command                              439     423     -16
do_ipaddr                                           1406    1389     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-85)             Total: -85 bytes

Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-04 15:32:38 +02:00
Pascal Bellard
21e8e8da64 libbb: introduce and use BB_EXECVP_or_die()
function                                             old     new   delta
BB_EXECVP_or_die                                       -      47     +47
time_main                                           1042    1043      +1
chrt_main                                            371     364      -7
ionice_main                                          292     282     -10
setsid_main                                           69      56     -13
nohup_main                                           236     223     -13
cttyhack_main                                        266     253     -13
chroot_main                                           94      81     -13
chpst_main                                           746     733     -13
timeout_main                                         297     279     -18
taskset_main                                         541     522     -19
vfork_child                                           67      45     -22
parse                                                975     953     -22
lpd_main                                             770     748     -22
launch_helper                                        192     170     -22
tcpudpsvd_main                                      1810    1782     -28
nice_main                                            190     156     -34
env_main                                             242     206     -36
run_command                                          221     174     -47
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/17 up/down: 48/-352)         Total: -304 bytes

Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-04 00:57:03 +02:00
Denys Vlasenko
41ddd9f606 *: make exec failure message more consistent
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-25 01:46:53 +02:00
Denys Vlasenko
8131eea3dc *: introduce and use ffulsh_all()
function                                             old     new   delta
buffer_fill_and_print                                179     196     +17
fflush_all                                             -       9      +9
spawn                                                 87      92      +5
rtcwake_main                                         455     453      -2
...
alarm_intr                                            93      84      -9
readcmd                                             1072    1062     -10
bb_ask                                               345     333     -12
more_main                                            845     832     -13
flush_stdout_stderr                                   42      23     -19
xfflush_stdout                                        27       -     -27
flush_stderr                                          30       -     -30
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/50 up/down: 31/-397)         Total: -366 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-02 14:19:51 +01:00
Denis Vlasenko
4774179cb9 mail.c: more robust handling of SIGCHLD
init: more robust signal handling
2009-03-10 16:01:57 +00:00
Denis Vlasenko
021de3f029 sendmail: document and fix usage of fd #4, fix check for helper failure.
function                                             old     new   delta
packed_usage                                       25663   25694     +31
signal_handler                                       191     215     +24
kill_helper                                           22      31      +9
launch_helper                                        194     184     -10
get_cred_or_die                                      142     129     -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 64/-23)             Total: 41 bytes
2009-03-04 17:56:00 +00:00
Bernhard Reutner-Fischer
82b1429966 - add new applet mkpasswd(1)
function                                             old     new   delta
bb_ask                                                 -     355    +355
mkpasswd_main                                          -     296    +296
.rodata                                           121746  121847    +101
packed_usage                                       24632   24689     +57
static.methods                                         -      21     +21
gmatch                                               229     248     +19
bb_ask_stdin                                           -      11     +11
applet_names                                        1949    1958      +9
applet_main                                         1172    1176      +4
sulogin_main                                         503     505      +2
applet_nameofs                                       586     588      +2
sha256_hash                                          329     327      -2
correct_password                                     208     206      -2
parse_command                                       1442    1439      -3
get_cred_or_die                                      145     141      -4
passwd_main                                         1054    1044     -10
bb_askpass                                           348       -    -348
------------------------------------------------------------------------------
(add/remove: 4/1 grow/shrink: 7/5 up/down: 877/-369)          Total: 508 bytes
2008-12-03 18:48:39 +00:00
Denis Vlasenko
239d06bd47 add mailutils/* 2008-11-06 23:42:42 +00:00