Commit Graph

13 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
dff2bd733f libarchive: treat one "FIXME: avoid seek"
function                                             old     new   delta
xmalloc_read_with_initial_buf                          -     205    +205
setup_transformer_on_fd                              154     150      -4
xmalloc_open_zipped_read_close                       143     135      -8
xmalloc_read                                         201      10    -191
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 205/-203)            Total: 2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-24 17:03:28 +02:00
Ron Yorston
61d6ae244a libbb: remove unnecessary argument to nonblock_immune_read
The loop_on_EINTR argument to nonblock_immune_read is always set to 1.

function                                             old     new   delta
xmalloc_reads                                        200     195      -5
pgetc                                                488     483      -5
argstr                                              1313    1308      -5
nonblock_immune_read                                 123      86     -37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-52)             Total: -52 bytes

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-20 13:41:32 +02:00
Denys Vlasenko
59655077c5 preparatory cleanups for seamless uncompression improvements
unpack_gz_stream_with_info: fix buggy error check
man: fix possible accesses past the end of a string
move seamless uncompression helpers from read_printf.c to open_transformer.c

function                                             old     new   delta
show_manpage                                         153     212     +59
unpack_gz_stream_with_info                           520     539     +19

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-06 16:23:50 +01:00
Denys Vlasenko
d184a728cf rename archive.h to bb_archive.h. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-22 12:45:14 +02:00
Denys Vlasenko
80542bad2f hush: make read builtin interruptible.
function                                             old     new   delta
builtin_read                                         185     471    +286
check_and_run_traps                                  200     262     +62
nonblock_immune_read                                  73     119     +46
sigismember                                            -      44     +44
record_signal                                          -      21     +21
sigisemptyset                                          -      16     +16
...
------------------------------------------------------------------------------
(add/remove: 5/0 grow/shrink: 7/5 up/down: 483/-46)           Total: 437 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-08 21:23:43 +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
833d4e7f84 rename archival/libunarchive -> archival/libarchive; move bz/ into it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-03 02:38:31 +01: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
Denys Vlasenko
cd0f6b0c93 consolidate xz format comment. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-01 10:38:10 +02:00
Denys Vlasenko
45f66167fe xz compression detection: avoid the need to seek
function                                             old     new   delta
unpack_unxz                                           12      67     +55
unpack_xz_stream                                    2357    2373     +16
xmalloc_read                                         197     199      +2
setup_unzip_on_fd                                    118      99     -19
rpm2cpio_main                                        222     203     -19
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 73/-38)             Total: 35 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-01 05:12:28 +02:00
Denys Vlasenko
894fa0ad62 fix breakage in compressed file detection
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-26 05:01:16 +02:00
Denys Vlasenko
19ced5c425 pipe_progress: make it independent of printf machinery
function                                             old     new   delta
bb_putchar_stderr                                      -      24     +24
ParseField                                           494     471     -23
progress_meter                                       212     188     -24
xargs_main                                           888     842     -46
pipe_progress_main                                   151     105     -46
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/4 up/down: 24/-139)          Total: -115 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-06 21:53:09 +02:00