Commit Graph

89 Commits

Author SHA1 Message Date
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
Tomas Paukrt
4527273f1c route: fix output of "route -n -A inet6"
The output of the command "route -n -A inet6" may be corrupted
due to partially initialized structure snaddr6 in the function
INET6_displayroutes.

Signed-off-by: Tomas Paukrt <tomaspaukrt@email.cz>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-08 13:52:12 +02:00
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
b097a84d62 config: update size information
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-28 03:20:17 +01:00
Denys Vlasenko
46ba2468a3 ioctl(SIOCGIFINDEX) does not require clearing of entire ifr
function                                             old     new   delta
INET6_setroute                                       492     472     -20
do_iplink                                           1357    1330     -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-47)             Total: -47 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-27 23:55:43 +02:00
Denys Vlasenko
a02a4e9830 whitespace and comment format fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-10-05 15:19:25 +02:00
Denys Vlasenko
72089cf6b4 config: deindent all help texts
Those two spaces after tab have no effect, and always a nuisance when editing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-21 09:50:55 +02:00
Denys Vlasenko
4eed2c6c50 Update menuconfig items with approximate applet sizes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 22:01:24 +02:00
Denys Vlasenko
47367e1d50 Convert all networking/* applets to "new style" applet definitions
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-23 09:05:14 +01:00
Denys Vlasenko
e695ac97fd typo fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-19 17:48:55 +02:00
Denys Vlasenko
a75dcd4353 route: fix bogus read error when route table is empty
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-04 10:40:10 +01:00
Denys Vlasenko
09020b1aa8 route: improve -A inet6
Upstream route command shows non-up routes, it shows reject and nonexthop flags.
And we had "ref" and "use" values mixed up...

function                                             old     new   delta
flagvals                                              32      44     +12
flagchars                                              9      12      +3
INET_setroute                                        767     768      +1
INET6_setroute                                       495     496      +1
set_flags                                             43      39      -4
flags_ipvx                                            16       8      -8
route_main                                           632     623      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/3 up/down: 17/-21)             Total: -4 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-03 19:32:44 +01:00
Bartosz Golaszewski
5d2e409ef8 libbb: use a wrapper around sysconf(_SC_CLK_TCK) to save a few bytes
function                                             old     new   delta
bb_sc_clk_tck                                          -      10     +10
timescmd                                             118     113      -5
print_route                                         1763    1758      -5
mpstat_main                                         1288    1283      -5
iostat_main                                         1947    1942      -5
INET_setroute                                        879     871      -8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/5 up/down: 10/-28)            Total: -18 bytes
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-06-22 14:01:13 +02:00
Denys Vlasenko
31dc8603ee ifconfig: do not accept "ifconfig eth0 up 1.2.3.4/17" (ip with mask). Closes 5786
function                                             old     new   delta
ifconfig_main                                       1221    1237     +16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-20 18:10:12 +01:00
Denys Vlasenko
60cb48ca50 whitespace cleanup. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 15:57:44 +01:00
Denys Vlasenko
6967578728 whitespace fixes. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 01:34:48 +01:00
Denys Vlasenko
66426760be *: remove "Options:" string from help texts
function                                             old     new   delta
packed_usage                                       28706   28623     -83

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-05 03:58:28 +02:00
Pere Orga
5bc8c005a8 move remaining help text from include/usage.src.h
Signed-off-by: Pere Orga <gotrunks@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-11 03:29:49 +02:00
Denys Vlasenko
940c7206c2 convert "do {...} while (1);" -> "while (1) {...}"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-02 04:07:14 +01:00
Alexey Fomenko
708dd4c986 add missing fclose's
Signed-off-by: Alexey Fomenko <ext-alexey.fomenko@nokia.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-02 04:01:24 +01:00
Denys Vlasenko
b3b6c8bdf2 eliminate aliasing warning in networking/route.c
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-20 11:29:00 +01:00
Denys Vlasenko
0004e99493 better shared strings trick
text	   data	    bss	    dec	    hex	filename
 861980	    441	   7540	 869961	  d4649	busybox_old
 861914	    441	   7540	 869895	  d4607	busybox_unstripped

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2010-09-01 12:01:17 +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
Denys Vlasenko
238bf187ba ash: fix bug which causes signal6.tests to fail
function                                             old     new   delta
trapcmd                                              271     277      +6
localcmd                                             277     275      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-18 15:49:07 +02:00
Denys Vlasenko
adf922ec28 *: a few more NOINLINEs
function                                             old     new   delta
print_linkinfo                                         -     815    +815
do_msg                                                 -     783    +783
INET_setroute                                          -     757    +757
varvalue                                               -     746    +746
do_sem                                                 -     637    +637
inflate_codes                                          -     617    +617
INET6_setroute                                         -     491    +491
edir                                                   -     370    +370
sync_cursor                                            -     298    +298
update_utmp                                            -     246    +246
searchLines                                            -     165    +165
setup_alarm                                            -     144    +144
may_wakeup                                             -     101    +101
getNum                                               566     371    -195
refresh                                             1166     848    -318
rtcwake_main                                         809     479    -330
getty_main                                          2396    1921    -475
chpst_main                                          1373     746    -627
inflate_unzip_internal                              1335     567    -768
evalvar                                             1384     612    -772
ipaddr_list_or_flush                                2160    1246    -914
route_main                                          1585     245   -1340
ipcs_main                                           2523    1049   -1474
------------------------------------------------------------------------------
(add/remove: 13/0 grow/shrink: 0/10 up/down: 6170/-7213)    Total: -1043 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-08 14:35:37 +02:00
Denis Vlasenko
360d9661b6 libbb: add strncpy_IFNAMSIZ
function                                             old     new   delta
...
udhcp_read_interface                                 225     220      -5
brctl_main                                          1151    1146      -5
add_interface                                        109     104      -5
ipaddr_list_or_flush                                2174    2167      -7
do_add_ioctl                                          88      80      -8
vconfig_main                                         249     240      -9
do_del_ioctl                                          78      68     -10
do_iplink                                           1186    1173     -13
do_if_fetch                                          766     753     -13
buffer_fill_and_print                                196     179     -17
parse_args                                          1709    1684     -25
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/20 up/down: 11/-140)         Total: -129 bytes
2008-12-02 18:18:50 +00:00
Denis Vlasenko
58680706d7 route: fix for 64-bit BE machines by Seonghun Lim (wariua AT gmail.com) 2008-09-28 23:39:18 +00:00
Denis Vlasenko
5415c856ea libbb: [x]fopen_for_{read,write} introduced and used.
(by Valdimir)

function                                             old     new   delta
config_open2                                           -      41     +41
config_read                                          507     542     +35
find_pair                                            169     187     +18
fopen_for_write                                        -      14     +14
fopen_for_read                                         -      14     +14
find_main                                            406     418     +12
xfopen_for_write                                       -      10     +10
xfopen_for_read                                        -      10     +10
popstring                                            134     140      +6
parse_inittab                                        396     401      +5
next_token                                           923     928      +5
pack_gzip                                           1659    1661      +2
bb__parsespent                                       117     119      +2
fallbackSort                                        1719    1717      -2
evalvar                                             1376    1374      -2
qrealloc                                              36      33      -3
...
...
...
...
singlemount                                         4579    4569     -10
process_stdin                                        443     433     -10
patch_main                                          1111    1101     -10
ifupdown_main                                       2175    2165     -10
file_action_grep                                      90      80     -10
uuidcache_init                                       649     637     -12
hush_main                                            797     785     -12
read_config                                          230     217     -13
dpkg_main                                           3835    3820     -15
read_line_input                                     3134    3110     -24
sysctl_main                                          232     203     -29
config_open                                           40      10     -30
WARN_BAD_LINE                                         44       -     -44
login_main                                          1714    1575    -139
------------------------------------------------------------------------------
(add/remove: 5/1 grow/shrink: 8/74 up/down: 174/-737)        Total: -563 bytes
2008-07-21 23:05:26 +00:00
Denis Vlasenko
a46dd89e94 cpio: internalize archive_xread_all_eof. add a few paranoia checks
for corrupted cpio files.
modprobe-small: remove stray include
route: small code shrink

function                                             old     new   delta
get_header_cpio                                      958     980     +22
archive_xread_all_eof                                 33       -     -33
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 22/-33)            Total: -11 bytes
2008-07-12 09:20:44 +00:00
Denis Vlasenko
a60f84ebf0 *: rename ATTRIBUTE_XXX to just XXX. 2008-07-05 09:18:54 +00:00
Denis Vlasenko
defc1ea340 *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on
text    data     bss     dec     hex filename
 808035     611    6868  815514   c719a busybox_old
 804472     611    6868  811951   c63af busybox_unstripped
2008-06-27 02:52:20 +00:00
Denis Vlasenko
c93b162248 patch: shrink by Pascal Bellard <pascal.bellard AT ads-lu.com> (-80 bytes)
*: removal of #include <getopt.h>
2008-03-23 22:55:25 +00:00
Denis Vlasenko
68404f13d4 *: add -Wunused-parameter; fix resulting breakage
function                                             old     new   delta
procps_scan                                         1265    1298     +33
aliascmd                                             278     283      +5
parse_file_cmd                                       116     120      +4
dname_enc                                            373     377      +4
setcmd                                                90      93      +3
execcmd                                               57      60      +3
count_lines                                           72      74      +2
process_command_subs                                 340     339      -1
test_main                                            409     407      -2
mknod_main                                           179     177      -2
handle_incoming_and_exit                            2653    2651      -2
argstr                                              1312    1310      -2
shiftcmd                                             131     128      -3
exitcmd                                               46      43      -3
dotcmd                                               297     294      -3
breakcmd                                              86      83      -3
evalpipe                                             353     349      -4
evalcommand                                         1180    1176      -4
evalcmd                                              109     105      -4
send_tree                                            374     369      -5
mkfifo_main                                           82      77      -5
evalsubshell                                         152     147      -5
typecmd                                               75      69      -6
letcmd                                                61      55      -6
add_cmd                                             1190    1183      -7
main                                                 891     883      -8
ash_main                                            1415    1407      -8
parse_stream                                        1377    1367     -10
alloc_procps_scan                                     55       -     -55
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 7/21 up/down: 54/-148)          Total: -94 bytes
   text    data     bss     dec     hex filename
 797195     658    7428  805281   c49a1 busybox_old
 797101     658    7428  805187   c4943 busybox_unstripped
2008-03-17 09:00:54 +00:00
Denis Vlasenko
1bec1b980e telnet: use poll, it's shorter
*: style fixes
2007-11-06 02:23:39 +00:00
Denis Vlasenko
9b49a5ed85 add -fvisibility=hidden to CC flags, mark XXX_main functions
EXTERNALLY_VISIBLE. 5% size reduction of libbusybox.so
2007-10-11 10:05:36 +00:00
Denis Vlasenko
fe7cd642b0 don't pass argc in getopt32, it's superfluous
(add/remove: 0/0 grow/shrink: 12/131 up/down: 91/-727) Total: -636 bytes
   text    data     bss     dec     hex filename
 773469    1058   11092  785619   bfcd3 busybox_old
 772644    1058   11092  784794   bf99a busybox_unstripped
2007-08-18 15:32:12 +00:00
Denis Vlasenko
6ca409e0e4 trylink: produce even more info about final link stage
trylink: explain how to modify link and drastically decrease amount
  of padding (unfortunately, needs hand editing ATM).
*: add ALIGN1 / ALIGN2 to global strings and arrays of bytes and shorts

size saving: 0.5k
2007-08-12 20:58:27 +00:00
Denis Vlasenko
fb79a2e2cf xioctl and friends by Tito <farmatito@tiscali.it>
function                                             old     new   delta
do_iptunnel                                          203     977    +774
process_dev                                         5328    5494    +166
ioctl_or_perror                                        -      54     +54
ioctl_or_perror_and_die                                -      51     +51
ioctl_alt_func                                         -      49     +49
bb_ioctl_or_warn                                       -      47     +47
do_add_ioctl                                         102     145     +43
bb_xioctl                                              -      39     +39
print_value_on_off                                     -      31     +31
get_lcm                                              105     123     +18
arp_main                                            2155    2167     +12
..................
zcip_main                                           1576    1566     -10
setlogcons_main                                       92      82     -10
dumpkmap_main                                        263     253     -10
do_get_ioctl                                          85      75     -10
setkeycodes_main                                     165     154     -11
write_table                                          244     232     -12
vconfig_main                                         318     306     -12
do_del_ioctl                                          93      81     -12
set_address                                           75      62     -13
maybe_set_utc                                         30      16     -14
loadfont_main                                        495     479     -16
slattach_main                                        712     695     -17
do_loadfont                                          191     174     -17
do_iplink                                           1155    1136     -19
getty_main                                          2583    2562     -21
fbset_main                                          2058    2035     -23
do_time                                              588     565     -23
xioctl                                                25       -     -25
read_rtc                                             186     160     -26
parse_conf                                          1299    1270     -29
udhcp_read_interface                                 269     239     -30
bb_ioctl                                              45       -     -45
bb_ioctl_alt                                          70       -     -70
bb_ioctl_on_off                                       78       -     -78
.rodata                                           129370  129018    -352
do_show                                              799       -    -799
------------------------------------------------------------------------------
(add/remove: 6/5 grow/shrink: 13/49 up/down: 1316/-1864)     Total: -548 bytes
   text	   data	    bss	    dec	    hex	filename
 675352	   2740	  13968	 692060	  a8f5c	busybox_old
 674804	   2740	  13968	 691512	  a8d38	busybox_unstripped
2007-07-14 22:07:14 +00:00
Denis Vlasenko
6d9ea24611 networking/interface.c: huke remaining big statics; use malloc for INET[6]_rresolve
return value. Went thru callers and adjusted them - code got smaller too.

function                                             old     new   delta
ip_port_str                                            -     126    +126
INET6_rresolve                                       165     182     +17
static.cache                                          20      24      +4
route_main                                          2092    2091      -1
INET_sprint                                           61      59      -2
INET_nn                                                4       -      -4
INET6_sprint                                          59      53      -6
udp_do_one                                           518     508     -10
tcp_do_one                                           433     423     -10
raw_do_one                                           494     484     -10
traceroute_main                                     4117    4105     -12
INET_rresolve                                        334     321     -13
bb_displayroutes                                     494     456     -38
snprint_ip_port                                      244       -    -244
static.buff                                          264      16    -248
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/10 up/down: 147/-598)        Total: -451 bytes

size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 751073    3048   14688  768809   bbb29 busybox_old
 750873    3048   14440  768361   bb969 busybox_unstripped
2007-06-19 11:12:46 +00:00
Denis Vlasenko
b6adbf1be2 usage.c: remove reference to busybox.h
*: s/include "busybox.h"/include "libbb.h"
2007-05-26 19:00:18 +00:00
Denis Vlasenko
87468857f6 style fixes 2007-04-13 23:22:00 +00:00
Denis Vlasenko
51742f4bb0 style fixes. No code changes 2007-04-12 00:32:05 +00:00
Denis Vlasenko
ff131b980d style fixes. No code changes. 2007-04-10 15:42:06 +00:00
Denis Vlasenko
06af216528 suppress warnings about easch <applet>_main() having
no preceding prototype
2007-02-03 17:28:39 +00:00
Denis Vlasenko
b6aae0f381 preparatory patch for -Wwrite-strings #2 2007-01-29 22:51:25 +00:00
Bernhard Reutner-Fischer
bb8c7c041c - sed -i -e "/\$Id:/d;" 2007-01-22 17:04:53 +00:00
Denis Vlasenko
703e20235a cleanups: unnecessary casts, unified const_1, eliminate cross-.c file
prototypes (heresy!), add spaces in places like "flags&NETSTAT_CONNECTED",
removed unused #defines, #ifdef -> #if, use uint32_t for ipv4 addrs.
2007-01-22 14:12:08 +00:00
Denis Vlasenko
98ee06d3d4 stop using __u32 etc. uint32_t is there for a reason 2006-12-31 18:57:37 +00:00
Denis Vlasenko
229b3d2072 do not overflow ifr_name. maybe it was safe in some places,
but not everywhere. err to the safe side.
2006-11-27 23:44:57 +00:00
Denis Vlasenko
7ca3921e5e bb_INET_default[] is really just a const "default",
nothing INET-specific
2006-11-21 20:34:21 +00:00